How ib-api-reloaded/ib_async works
ib_async is a Python sync/async client library for Interactive Brokers TWS and IB Gateway. A user calls the high-level IB interface to connect, request market/account/research data, or submit orders; the client encodes requests over a socket, then decodes replies into synchronized state and events. Contracts and orders model request inputs, while ticker and object types represent results. Additional capabilities include Flex Web Service reports and optional TWS/Gateway lifecycle monitoring. The README documents the broader feature set; some subsystem wiring is represented only at the documented capability level because its source was not sampled.
Main entry points: ib.py IB interface · wrapper.py State and events · client.py Socket client · connection.py Socket transport
Components 19
User API
- IB interface
ib_async/ib.py - Async utilities
ib_async/util.py
IB Protocol
- Socket client
ib_async/client.py - Socket transport
ib_async/connection.py - Message decoder
ib_async/decoder.py - State and events
ib_async/wrapper.py
Trading Data
- Contracts
ib_async/contract.py - Orders and trades
ib_async/order.py - Live ticker data
ib_async/ticker.py - Result objects
ib_async/objects.py - Research requests
ib_async/ib.py - Account and portfolio
ib_async/ib.py - Market data requests
ib_async/ib.py - Order submission
ib_async/ib.py
Integrations
- Lifecycle watchdog
ib_async/ibcontroller.py - Flex reports
ib_async/flexreport.py
Other components
- Application
- TWS / IB Gateway
- Flex Web Service
Connections 31
- Application → IB interface: calls
- IB interface → Socket client: sends requests
- IB interface → State and events: tracks state
- IB interface → Async utilities: runs async
- Socket client → Socket transport: sends bytes
- Socket transport → TWS / IB Gateway: exchanges messages
- Socket transport → Socket client: delivers bytes
- Socket client → Message decoder: decodes replies
- Message decoder → State and events: dispatches events
- State and events → Live ticker data: updates quotes
- State and events → Result objects: builds results
- State and events → Orders and trades: updates trades
- Market data requests → IB interface: uses interface
- IB interface → Market data requests: returns data
- Market data requests → Contracts: accepts instruments
- Market data requests → Live ticker data: returns live data
- Market data requests → Result objects: returns bars
- Research requests → IB interface: uses interface
- IB interface → Research requests: returns details
- Research requests → Contracts: accepts instruments
- Account and portfolio → IB interface: uses interface
- IB interface → Account and portfolio: returns account state
- Account and portfolio → Result objects: returns positions
- Order submission → IB interface: uses interface
- IB interface → Order submission: places orders
- Order submission → Contracts: specifies instrument
- Order submission → Orders and trades: specifies order
- Lifecycle watchdog → IB interface: monitors connection
- Lifecycle watchdog → TWS / IB Gateway: starts or stops
- Flex reports → Flex Web Service: downloads reports
- Application → Flex reports: requests report