Loading...
Loading...
Interactive Brokers (IBKR) API integration for portfolio management, account queries, and trade execution across multiple account types (Roth IRA, personal brokerage, business). Use when the user mentions IBKR, Interactive Brokers, IB Gateway, TWS API, Client Portal API, brokerage API, portfolio positions, account balances, placing trades via API, multi-account trading, IRA trading restrictions, or wants to build/debug code that connects to Interactive Brokers. Also triggers on "ib_async", "ib_insync", "ibapi", or any IBKR endpoint reference.
npx skill4agent add scientiacapital/skills ibkr-api-skillpip install ib_asyncib = IB(); await ib.connectAsync('127.0.0.1', 7497, clientId=1)positions = ib.positions()summary = await ib.accountSummaryAsync()| Criterion | TWS API (Recommended) | Client Portal REST API |
|---|---|---|
| Best for | Automated trading, portfolio mgmt | Web dashboards, light usage |
| Auth | Local login via TWS/IB Gateway | OAuth 2.0 JWT |
| Performance | Async, low latency, high throughput | REST, slower |
| Data quality | Tick-by-tick available | Level 1 only |
| Multi-account | All accounts simultaneously | Per-request |
| Infrastructure | Local Java app (port 7496/7497) | HTTPS REST calls |
| Python library | ib_async (recommended) | requests + OAuth |
| Cost | Free | Free |
reqLinkedAccounts()| Restriction | Impact |
|---|---|
| No short selling | |
| No margin borrowing | Cash-only (no debit balances) |
| No foreign currency borrowing | Must execute FX trade first |
| Futures margin 2x higher | Position sizing affected |
| MLPs/UBTI prohibited | Filter these from IRA order flow |
| Withdrawals USD only | Informational |
# Key TWS API functions for portfolio queries
reqLinkedAccounts() # List all account IDs
reqAccountSummary() # Balances, buying power, equity (all accounts)
reqPositions() # Current positions (up to 50 sub-accounts)
reqPositionsMulti() # Per-account positions (>50 sub-accounts)
reqAccountUpdates() # Stream account + position data (single account)
reqMktData() # Real-time Level 1 market data
reqHistoricalData() # Historical price dataplaceOrder(account_id, contract, order) # Place order on specific account
cancelOrder(order_id) # Cancel pending order
reqGlobalCancel() # Cancel all open ordersGET /iserver/accounts # List accounts
GET /iserver/account/{id}/positions # Positions
GET /iserver/account/{id}/summary # Balances
POST /iserver/account/{id}/orders # Place order
GET /market/candle # Historical candlespip install ib_asyncib_insyncibapireference/connection-patterns.mdreference/trading-patterns.md| Item | Cost |
|---|---|
| API access | Free |
| Market data | $5-50/month per exchange subscription |
| Trading commissions | Standard IBKR rates (varies by asset) |
| Account minimums | $500 per account |
| Estimated total | ~$1,500 aggregate minimum; $15-50/month data |
trading-signals-skill~/Desktop/tk_projects/ibkr-mcp-server/~/.claude.jsonclaude_desktop_config.json| Tool | Purpose | Account Types |
|---|---|---|
| Positions + P&L | All accounts |
| Balances, margin, buying power | All accounts |
| Toggle Roth IRA / Personal / THK | Multi-account |
| Real-time quotes | N/A |
| Historical OHLCV | N/A |
| Orders with safety checks | All (IRA restrictions enforced) |
| Short availability | Personal/Business only |
| Margin needs per security | Personal/Business only |
| Borrow costs for shorts | Personal/Business only |
| Full short analysis package | Personal/Business only |
| IB Gateway health check | N/A |
code-rabi/interactive-brokers-mcpxiao81/IBKR-MCP-ServerHellek1/ib-mcpdangelov/mcp-snaptradereference/multi-broker-strategy.md