Market data, bars, depth, options, scanners, and news
Top-of-book streaming
ticker = ib.reqMktData(
contract,
genericTickList="233,236",
snapshot=False,
regulatorySnapshot=False,
mktDataOptions=[],
)
await ib.sleep(1)
print(ticker.bid, ticker.ask, ticker.last, ticker.marketPrice())
ib.cancelMktData(contract)
reqMktData returns a Ticker immediately; fields begin empty/NaN and update asynchronously. genericTickList is a comma-separated set of numeric generic tick IDs, not field names. Snapshot requests end automatically and cannot be combined with generic ticks. Regulatory snapshots can incur fees and require eligibility.
Ticker.marketPrice() uses last price when it is inside a valid bid/ask, otherwise midpoint, otherwise last. That is a convenience estimate—not an executable quote. hasBidAsk() excludes unset/negative prices and non-positive sizes.
Market data types
reqMarketDataType selects live, frozen, delayed, or delayed-frozen behavior when the account/server permits it. Delayed data uses different tick IDs and is not a substitute for subscriptions in every endpoint. Historical API data generally requires the corresponding live Level 1 entitlement.
Tick by tick
ticker = ib.reqTickByTickData(contract, "AllLast", numberOfTicks=0, ignoreSize=False)
ib.cancelTickByTickData(contract, "AllLast")
Tick types are Last, AllLast, BidAsk, and MidPoint. numberOfTicks=0 requests streaming only; a positive value asks for historical ticks followed by streaming subject to server rules. IBKR limits concurrent tick-by-tick subscriptions based on market-data lines. A zero price/size tick with pastLimit can indicate a halt.
Real-time bars
reqRealTimeBars returns fixed five-second bars; the requested barSize parameter is retained for protocol compatibility but only 5 seconds is supported. Subscriptions count against market-data limits and are also subject to historical pacing. Volume conventions vary by instrument and feed.
Market depth
reqMktDepth(contract, numRows=5, isSmartDepth=False) maintains domBids, domAsks, and DOM ticks. Direct depth and SMART aggregate depth differ. Market-maker identifiers and available rows are venue-dependent. Depth is lossy during disconnects; discard and rebuild the book after a gap rather than replaying deltas onto stale state.
Option calculations
calculateImpliedVolatilityAsync(contract, optionPrice, underPrice) and calculateOptionPriceAsync(contract, volatility, underPrice) are requests to IBKR's model, not local deterministic functions. Cancel counterparts exist on Client. Missing market data, invalid inputs, or subscription limits can produce no model value or errors. Ticker option-computation fields distinguish bid, ask, last, and model Greeks.
Scanners
Obtain the current scanner schema with reqScannerParametersAsync(), construct a ScannerSubscription, and use reqScannerDataAsync for a one-shot result or reqScannerSubscription for updates. Valid instrument/location/scan combinations are server-defined. Cancel streaming scanners and respect pacing.
News and WSH
News requires provider entitlements. Discover providers, then request articles or headlines using provider codes and article IDs. Historical-news times and result limits are explicit parameters. WSH metadata/event endpoints return JSON strings for corporate-event data and have one active metadata/event subscription semantics in IB.
Subscription hygiene
Every streaming request needs a deterministic owner and cancellation path. Track subscriptions by qualified contract and request kind, make resubscription idempotent, cancel before replacement, and rebuild all subscriptions after connectivity code 1101 (data lost). Do not assume code 1102 requires replay.