[Interactive Brokers] No liveness detection for subscriptions that are open but delivering no data
Feature Request
- I've searched existing issues and discussions to avoid duplicates.
Scoped deliberately to the Interactive Brokers adapter rather than proposed as a platform-wide mechanism. If a general data-liveness facility is the preferred shape, I am happy to move this to an RFC.
Problem statement
The Interactive Brokers data client cannot detect a subscription that is open but delivering nothing. Recovery is driven exclusively by IB notices. When IB accepts a subscription or resubscription and then sends no data, the adapter has no mechanism to notice, and a live strategy goes blind indefinitely with no error, no notice, and no stream end.
This is reliably reproducible, because IBKR permits only one active session per username and a paper account's market data is shared from the live username:
- Run a node subscribed to trades for a few liquid US equities and confirm ticks flow.
- Log into IBKR mobile or web with the live username. The paper session loses market data. IB's documented state for this is error 10197, "No market data during competing session".
- Log out again.
Observed on two deliberate runs and once unintentionally mid-session:
- Farm notices fire.
[2103] Market data farm connection is broken: usfarmis followed about a second later by[2104] ... is OK, and the adapter logsIB data farm recovered by notice 2104 ...; resubscribing data feeds. - Those re-requests are issued while the competing session still holds the data. IB accepts them and delivers nothing.
- No further ticks ever arrive, including minutes after the competing session ends. We verified with resubscribe attempts 1.3 and 5.3 minutes after logout, and after a manual refresh in TWS, while TWS's own quotes were live again.
- Nothing is logged. No error, no
SubscriptionItem::Notice, no stream end.
Why the existing recovery does not cover it
In crates/adapters/interactive_brokers/src/data/core_streams.rs, a trade stream resubscribes only on either a data farm recovery generation bump, or an Err carrying SUBSCRIPTION_DISCONNECTED_CODE (10182). A starved but open subscription produces neither.
Per the pinned ibapi = 3.3.0, per-request IB errors surface as a terminal Err, and SubscriptionItem::Notice covers only warning codes 2100 to 2169. So this state is genuinely invisible to the current logic rather than merely unhandled.
Proposed solution
Detection. A per-subscription idle or liveness timeout, surfaced as a log line and as an event a strategy can react to. A flat constant is awkward because print rates vary enormously across instruments and across the session, so ideally the threshold derives from observed inter-arrival behaviour, with a configurable floor and cap.
An explicit signal. Even without adapter-side recovery, a "subscription appears dead" event would let applications escalate on their own terms.
Example usage
InteractiveBrokersDataClientConfig(
...
# None disables; when set, the client emits a liveness event for a
# subscription that has been accepted but has delivered nothing.
subscription_idle_timeout_secs=120,
)Alternatives considered
We implemented a data-based liveness supervisor in application code as a workaround, tracking arrival statistics per instrument and computing an adaptive staleness threshold. It detects the condition reliably. What it cannot do is fix it, which is the important negative result below.
Same-connection resubscribe does not recover. An engine-level unsubscribe followed by subscribe did not restore data in either of our runs. Only a brand new API connection, meaning a fresh process, restored the feed. The IB data client currently exposes connect and disconnect with no reconnect path.
We report that explicitly because it changes what "recovery" can mean here. If client-side reconnection is out of scope for the adapter, then detection plus an explicit event is the valuable part, and the application decides whether to alert or restart.
Additional context
We are happy to contribute the detection logic if the approach is welcome. The adaptive threshold implementation is small and self-contained.
- OS platform: macOS-26.6.2-arm64-arm-64bit-Mach-O
- Python version: 3.13.15
nautilus_traderversion: 2.0.0rc4- Adapter/venue: Interactive Brokers (TWS paper, API v178), data shared from the live username
Source: nautechsystems/nautilus_trader