Expand description
Ibkr market data stream (behind ibkr feature).
Interactive Brokers market data connector.
Provides streaming market data from IB TWS/Gateway via the ibapi crate.
§Testing Status
NOT TESTED in CI. IBKR has not confirmed permission to use credentials for CI, and requires IB Gateway/TWS running locally.
Tested locally (free subscriptions via IBKR Pro):
- Tier 0: Connection, contract resolution
- Tier 1: Historical bars/ticks, L1 quotes, Greeks calculator, option chains
NOT tested locally (paid subscriptions):
- Tier 2: L2 Market Depth — exchange-specific fees
- Tier 3: OPRA US Options — paid subscription
Tests are organized by subscription tier (see ibkr_integration.rs).
§Connection
Requires TWS or IB Gateway running locally with API enabled:
| Application | Live Port | Paper Port |
|---|---|---|
| TWS | 7496 | 7497 |
| IB Gateway | 4001 | 4002 |
Enable API in TWS/Gateway: Configure → API → Settings → Enable ActiveX and Socket Clients.
§Architecture
Unlike WebSocket-based exchanges, IB uses TCP sockets with a blocking API.
This module implements Stream directly rather than using the Connector
trait designed for WebSocket exchanges.
§Supported Data Types
- Quotes (
OrderBookL1): Best bid/ask viamarket_data()subscription - Depth (
OrderBookEvent): L2 order book viamarket_depth()subscription - Trades (
PublicTrade): Tick-by-tick trades viatick_by_tick_all_last()subscription - Historical (
Candle): OHLCV bars viahistorical::IbkrHistoricalData
§Limitations
- Market depth limit: IB allows max 3 concurrent depth subscriptions (error 309)
- Trade side: IB doesn’t provide trade side; defaults to
Side::Buy - Blocking API: Uses
std::thread::spawnfor long-lived subscriptions - No auto-reconnect: Caller responsibility per library philosophy
§See Also
- IB API Documentation
rustrade_execution::client::ibkrfor order execution
Modules§
- depth
- Depth aggregation for IB market depth updates.
- greeks
- Greeks aggregation for IB option tick data.
- historical
- Historical data fetcher for Interactive Brokers.
- options
- Option Greeks and chain data types for Interactive Brokers.
- quotes
- Quote aggregation for IB market data ticks.
- subscription
- IBKR subscription types.
- trades
- Trade tick transformation for IB tick-by-tick data.
Structs§
- Flex
Poll Policy - Poll timing for the GetStatement stage of
IbkrFlexClient::fetch_statement_xml. - Ibkr
Flex Client - Client for fetching corporate-action records from the IBKR Flex Web Service.
- Ibkr
Flex Config - Credentials for the IBKR Flex Web Service: an Activity-statement Flex
tokenand the id of a saved Flex query that includes the Corporate Actions section. - Ibkr
Flex Corporate Action - A single corporate-action row from an IBKR Flex statement, surfaced verbatim.
- Ibkr
Market Stream - Market data stream from Interactive Brokers.
- Ibkr
Stream Config - Configuration for the IBKR market data stream.
Enums§
- Ibkr
Flex Error - Errors from IBKR Flex Web Service operations.
- Ibkr
Reorg Type - IBKR Flex reorganisation type (the
<CorporateAction>typeattribute).
Functions§
- parse_
corporate_ actions - Parse the
<CorporateAction>rows out of an IBKR Flex statement XML document.