- Home
- Skills
- Scientiacapital
- Skills
- Ibkr Api Skill
ibkr-api-skill_skill
- Python
6
GitHub Stars
2
Bundled Files
2 months ago
Catalog Refreshed
3 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill scientiacapital/skills --skill ibkr-api-skill- config.json814 B
- SKILL.md8.5 KB
Overview
This skill provides a practical Python integration layer for Interactive Brokers (IBKR) to manage portfolios, query accounts, and execute trades across multiple account types (Roth IRA, personal brokerage, business). It favors the TWS/TWS-Gateway binary API via the modern ib_async library for low-latency, multi-account programmatic work while offering Client Portal REST alternatives for lighter web use. The skill includes IRA-safe validations, connection patterns, and an MCP server for local tooling and safety caps.
How this skill works
It connects to a locally running IB Gateway or TWS instance (ports 7496/7497) using ib_async to issue requests and place orders. The skill exposes read operations (linked accounts, balances, positions, market and historical data) and write operations (place/cancel orders) with account-specific routing and IRA restriction checks. A local MCP server wraps common helpers (get_portfolio, get_account_summary, place_order, check_shortable_shares) and enforces safety limits for paper and live modes.
When to use it
- Building automated trading or portfolio management that needs low-latency, multi-account access
- Querying linked accounts, per-account positions, balances, or streaming account updates
- Placing orders with IRA-aware validation (no shorts, no margin) across several accounts
- Debugging or developing Python code that connects to IB Gateway/TWS using ib_async or ib_insync
- When you need a local, secure MCP wrapper for safety, logging, and order caps
Best practices
- Prefer ib_async for asyncio-native, actively maintained integration; fallback to ib_insync or ibapi only if necessary
- Run IB Gateway/TWS on localhost and add 127.0.0.1 to trusted IPs; never expose the API directly to the internet
- Store credentials in the OS credential manager and do not hardcode secrets
- Enumerate linked accounts with reqLinkedAccounts() and explicitly specify account_id on all placeOrder calls
- Implement session timeout handling, ping/keepalive, and robust reconnection logic
Example use cases
- Automated signal pipeline: ingest trading signals → size positions per-account → validate IRA rules → execute orders
- Multi-account portfolio view: aggregate positions and P&L across Roth IRA, personal, and business accounts
- Paper-trading development: use MCP server on port 7497 with order caps and confirmation prompts
- Compliance guardrails: pre-flight checks to block short/margin orders for IRA accounts
- Ad-hoc reporting: fetch account summaries, historical candles, and export CSVs for reconciliation
FAQ
Use the TWS/TWS-Gateway binary API with ib_async for low latency, multi-account support and full tick data.
Can I trade IRAs the same way as taxable accounts?
No. IRAs prohibit short selling and margin borrowing; the skill enforces IRA-specific validations before orders are placed.