AgentStack
SKILL verified MIT Self-run

Ibkr Trading

skill-acaprino-claude-code-daodan-ibkr-trading · by acaprino

>

No reviews yet
0 installs
16 views
0.0% view→install

Install

$ agentstack add skill-acaprino-claude-code-daodan-ibkr-trading

✓ scanned · ✓ verified — works with Claude Code, Cursor, and more.

Security review

✓ Passed

No issues found. Passed automated security review. · v0.1.0 How review works →

  • Prompt-injection patterns
  • Secret / credential exfiltration
  • Dangerous shell & filesystem operations
  • Untrusted network calls
  • Known-malicious package signatures

What it can access

  • Network access No
  • Filesystem access No
  • Shell / process execution No
  • Environment & secrets No
  • Dynamic code execution No

From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.

Are you the author of Ibkr Trading? Claim this listing to set pricing, connect Stripe payouts, and keep 70% of every sale.
Sign up to claim

About

Interactive Brokers Algotrading

Knowledge base for building production-grade algorithmic trading systems with Interactive Brokers TWS API and ib_async in Python.

When to Use

  • Connecting to TWS or IB Gateway with ib_async
  • Implementing real-time market data subscriptions
  • Designing order execution logic (bracket orders, order lifecycle)
  • Handling pacing violations for historical data requests
  • Building reconnection resilience for 24/7 production bots
  • Deploying IB trading systems on Windows with IBC + Task Scheduler
  • Debugging TWS API error codes (110, 135, 162, 200, 201, 354, 366, 1100-1102)
  • Translating FX/metals symbols into the right contract type (spot vs CFD) for the account's entity
  • Sizing orders from prices without the NaN/0.0/unit/tick traps that silently mis-size or reject

Quick Start

For 80% of use cases, start with:

  1. Connection: IB Gateway (headless, lower resources) + IBC (automated lifecycle)
  2. Library: pip install ib_async (asyncio-native successor to ib_insync)
  3. Data: reqRealTimeBars for live 5-sec bars with local aggregation
  4. Orders: Bracket orders with transmit=False pattern
  5. Resilience: disconnectedEvent + exponential backoff reconnection
  6. Deployment: IBC + Windows Task Scheduler for auto-restart

Then harden incrementally:

  • Missing fills on reconnect -- add reqExecutions() reconciliation
  • Pacing violations -- add asyncio.Semaphore throttled request queue
  • Overnight crashes -- add IBC auto-restart + heartbeat monitoring
  • State drift -- add periodic position/order reconciliation via reqPositions()
  • Orders FIRED but never live, mis-sized, or rejected with no error -- read venue-boundary-failure-modes.md (async rejection ingress, tick conformance, FX-as-CFD routing, NaN-safe sizing)

Reference Materials

  • tws-api-architecture.md -- TWS API 10.45, Gateway vs TWS, Client Portal, ib_async setup, clientId strategy, official docs
  • event-driven-data.md -- reqMktData, reqRealTimeBars, reqTickByTickData, keepUpToDate, OHLCV construction, pacing violations, historical data
  • order-execution.md -- order types, bracket orders, lifecycle states, execDetails monitoring, race conditions, error codes
  • reconnection-resilience.md -- daily reset, IBC automation, reconnect patterns, heartbeat, Windows deployment, community resources
  • venue-boundary-failure-modes.md -- the silent-failure layer: async rejection ingress (errorEvent -> lifecycle), price/tick conformance (110/135, minTick from ContractDetails), FX-as-CFD routing for retail EU entities (201/200/2127/366), data-contract vs order-contract split, and NaN-safe sizing with canonical lot units and conversion-rate fallback

Key Decision Points

| Decision | Default | Upgrade When | |----------|---------|-------------| | Connection target | IB Gateway | Need visual debugging -- TWS | | Python library | ibasync | Need same-day new features -- ibapi | | Live data | reqRealTimeBars (5s bars) | Need tick precision -- reqTickByTickData (max 3) | | Chart data | keepUpToDate | Network-sensitive env -- reqRealTimeBars + aggregation | | Historical data | reqHistoricalData + throttle | Bulk backfill -- chunked requests with Semaphore | | Order type | Bracket (parent+TP+SL) | Need trailing: TRAIL. Need algo: Adaptive | | Lifecycle mgmt | IBC + Task Scheduler | Docker available -- gnzsnz/ib-gateway-docker | | whatToShow | TRADES | Forex: MIDPOINT. Backtesting: ADJUSTEDLAST |

Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

Install and usage instructions live in the source repository linked above.

Reviews

No reviews yet — be the first.

Versions

  • v0.1.0 Imported from the upstream source.