[Interactive Brokers] Make the tick-by-tick trade type selectable (Last vs AllLast)

Author: Artur-SulejCreated Sep 9, 2026Updated Sep 29, 2026

Feature Request

  • I've searched existing issues and discussions to avoid duplicates.

Problem statement

The IB data client always subscribes to tick-by-tick trades as AllLast, with no way to request Last. In crates/adapters/interactive_brokers/src/data/core_streams.rs:

rust
let mut subscription = client
    .tick_by_tick(&contract, 0)
    .all_last()
    .await
    .context("Failed to create tick-by-tick trade subscription")?;

AllLast includes trade types beyond regular trades, such as combos, derivatively-priced and average-price prints, which are not part of the price-forming tape. Last excludes them. ibapi 3.3.0 exposes both on the same builder (last() at market_data/realtime/builder/tick_by_tick.rs:190, all_last() at :221), so only the choice is missing.

Why this matters: recorded data cannot reproduce a live session

Replaying a recorded IB session through the same strategy code reproduced every data-derived decision exactly: opening range 229.82/232.58, entry trigger 232.70, size 17, entry fill 17 @ 232.70, protective stop at 229.82, exit reason protective_stop_hit.

One thing diverged, the stop's fill price:

live   NVDA stop filled @ 229.69     realised -51.17
replay NVDA stop filled @ 224.93     realised -132.09

A 13-cent slip became a 4.9-point slip and the loss more than doubled. The recorded tape contains prints far below the stop trigger which were not executable market prices, and the simulator fills a triggered market stop at the next tick it sees.

The direction is what makes it hard to work with: backtests are pessimistic on stop-outs by a margin which varies with the instrument and the day, and which cannot be recovered from the recorded data. For any strategy exiting on stops, backtest P&L is not comparable to live P&L.

Filtering downstream by value, for example discarding prints far from their neighbours, is not a sound substitute: a filter cannot distinguish a non-market print from a genuine violent move, which is precisely the event a protective stop exists for. Being able to subscribe to Last moves the decision to the venue, which knows which trades are regular.

Possible secondary benefit

Odd-lot and irregular prints arrive through AllLast. Subscribing to Last would likely reduce the volume of unrepresentable sizes reported in #4948 at the source, rather than only lowering how loudly they are logged.

Proposed solution

A configuration field on InteractiveBrokersDataClientConfig selecting the trade tick type, defaulting to the current behaviour so nothing changes for existing users.

This follows the existing convention in the same config, which already lets the caller choose which IB mechanism supplies quotes:

rust
/// Whether to use batch quotes (reqMktData) by default instead of tick-by-tick.
#[builder(default = true)]
pub batch_quotes: bool,

Example usage

python
InteractiveBrokersDataClientConfig(
    host="127.0.0.1",
    port=7497,
    client_id=1,
    market_data_type=MarketDataType.REALTIME,
    # Regular trades only, so recorded tapes contain price-forming prints.
    all_last_trades=False,
)

A bool matches batch_quotes for consistency; a small enum (Last / AllLast) would read better at the call site. Either is fine by us.

Alternatives considered

Preserve the trade conditions on TradeTick instead. The labels already arrive: ibapi's Trade carries trade_attribute.unreported and special_conditions, and parse_trade_tick drops both. Carrying them through, as OrderBookDelta, OrderBookDepth10 and OrderBookDeltas already do with flags: u8, would be the more general fix, would let consumers filter by label rather than by feed choice, and would help other adapters too (Databento's record flags are dropped for the same reason).

That is a core data type change touching Arrow schemas, persistence and bindings, so we are raising this narrower option first. Happy to open the broader one as an RFC if you would prefer that direction instead, or in addition.

Value-based filtering downstream. Covered above; unsound for stop-driven strategies.

Recording through a separate IB client which keeps the conditions. Means maintaining a second data path purely for recording, and gives up the guarantee that live and backtest consume the same code path.

Additional context

Happy to open a PR for this if the approach is acceptable, including whichever of bool or enum you prefer.

Related to #2194 (fill simulation), though the cause here is upstream of the fill model: the information needed to model the fill is discarded before the matching engine sees it.

  • OS platform: macOS-26.6.2-arm64-arm-64bit-Mach-O
  • Python version: 3.13.15
  • nautilus_trader version: 2.0.0rc4
  • Adapter/venue: Interactive Brokers (TWS paper, API v178), US equities

Source: nautechsystems/nautilus_trader