[Interactive Brokers] Execution callback can lose submitted client_order_id mapping and materialize duplicate reconciliation order

Author: tariq-dxbCreated Sep 10, 2026Updated Sep 29, 2026
Labelsbugadapter

Bug Report

Confirmation

Before opening a bug report, please confirm:

  • I've re-read the relevant sections of the documentation.
  • I've searched existing issues and discussions to avoid duplicates.
  • I've reviewed or skimmed the source code (or examples) to confirm the behavior is not by design.
  • I've tested this issue using a recent pre-release or development wheel (2.0.0rcN, dev develop, or a nightly) and can still reproduce it.

Possibly related to #4564 at the IBKR order-identity/reconciliation layer, but this reproduction does not involve a modify, connectivity loss, or multiple live broker permId incarnations.

Here, a normal MARKET fill arrives with an execution.order_id that does not resolve to the original submitted order mapping, which causes the fill to be materialized on a reconciliation/external order while the original remains ACCEPTED with filled_qty=0.

So the two issues appear related in subsystem and identity semantics, but not duplicates.

Expected behavior

When a Nautilus order is submitted through the official IBKR adapter, the fill callback should resolve back to the original submitted client_order_id.

For a submitted order with:

  • Nautilus client_order_id = C0
  • IBKR native orderId = O0

the adapter should preserve the identity mapping so that when IBKR later reports the execution/fill, the original Nautilus order transitions from ACCEPTED to FILLED, with the correct filled_qty.

The fill should not cause a second reconciliation/external order representation to be materialized for the same broker order.

Actual behavior

The broker order is accepted and filled, but Nautilus represents the same broker order as two divergent order records.

Observed behavior:

  1. Submission creates client_order_id=C0.
  2. The adapter allocates native IBKR orderId=O0.
  3. order_ref=C0 is sent.
  4. Submission-time tracking context is stored under O0.
  5. The IBKR openOrder callback still uses O0, so the original Nautilus order receives its normal acceptance/update path.
  6. The later execution callback arrives with execution.order_id=Oexec, where Oexec != O0.
  7. handle_execution_data performs its tracked-context lookup using execution.order_id, so the original context is not found.
  8. The adapter does not recover the original order context using execution.client_id or permId.
  9. The fill therefore falls through to reconciliation/external-order handling.
  10. A second Nautilus order representation is materialized and receives OrderFilled.
  11. The original submitted order remains ACCEPTED with filled_qty=0.

This reproduced independently on both:

  • the MARKET entry order, and
  • the subsequent MARKET flatten order.

Final restart reconciliation correctly restored broker/Nautilus flat state, but it did not repair the live order identity/fill attribution.

Steps to reproduce

  1. Start NautilusTrader 2.0.0rc3 using the official Interactive Brokers adapter against IB Gateway PAPER.
  2. Connect data and execution clients and complete reconciliation.
  3. Resolve AUD.USD=CASH.IDEALPRO.
  4. Confirm broker and Nautilus are initially flat with zero working orders.
  5. Submit one MARKET BUY order for 25,000 AUD with a known Nautilus client_order_id.
  6. Observe that the broker acknowledges and fills the order.
  7. Inspect the Nautilus order cache/state after the fill.
  8. Observe that:
    • the original submitted order remains ACCEPTED with filled_qty=0, while
    • a second reconciliation/external order representation receives the fill and produces PositionOpened.
  9. Submit the corresponding MARKET flatten order.
  10. Observe the same accepted-original / filled-reconciliation split again.
  11. Restart/reconcile and confirm final broker and Nautilus state is flat.

The issue reproduced on both entry and flatten using two independently allocated broker orders.

Code snippets or logs

The issue appears to occur in the IBKR execution callback identity lookup.

Submission stores the original mapping using the submission-time native orderId.

Later, execution handling resolves context using:

rust
let tracked_context = Self::get_tracked_order_context(
    exec_data.execution.order_id,
    active_order_contexts,
    terminal_order_contexts,
)?;

let mapped_client_order_id = {
    let map = venue_order_id_map
        .lock()
        .map_err(|_| anyhow::anyhow!("Failed to lock venue order ID map"))?;
    map.get(&exec_data.execution.order_id).copied()
};
In the reproduced runs:
submission orderId = O0
execution.order_id = Oexec
Oexec != O0

The lookup therefore misses the original order context.

The execution then falls back to generic fill/reconciliation handling, which materializes a second order representation.

Observed high-level state: Original order: CREATED -> SUBMITTED -> ACCEPTED -> remains ACCEPTED filled_qty = 0

Reconciliation-generated order: -> ACCEPTED -> FILLED -> PositionOpened

The same behavior occurred on the flattening order, which ultimately produced PositionClosed.

Sensitive native broker identifiers (orderId, permId, execution IDs, account ID) were intentionally not persisted in the test evidence.

Specifications

  • OS platform: macOS-26.6-arm64-arm-64bit-Mach-O
  • Python version: 3.14.7
  • nautilus_trader version: 2.0.0rc3
  • Installed from: PyPI pre-release wheel
  • Adapter/venue: Interactive Brokers / IB Gateway PAPER / IDEALPRO

Source: nautechsystems/nautilus_trader