[Interactive Brokers] Execution callback can lose submitted client_order_id mapping and materialize duplicate reconciliation order
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,devdevelop, oranightly) 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:
- Submission creates
client_order_id=C0. - The adapter allocates native IBKR
orderId=O0. order_ref=C0is sent.- Submission-time tracking context is stored under
O0. - The IBKR
openOrdercallback still usesO0, so the original Nautilus order receives its normal acceptance/update path. - The later execution callback arrives with
execution.order_id=Oexec, whereOexec != O0. handle_execution_dataperforms its tracked-context lookup usingexecution.order_id, so the original context is not found.- The adapter does not recover the original order context using
execution.client_idorpermId. - The fill therefore falls through to reconciliation/external-order handling.
- A second Nautilus order representation is materialized and receives
OrderFilled. - The original submitted order remains
ACCEPTEDwithfilled_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
- Start NautilusTrader
2.0.0rc3using the official Interactive Brokers adapter against IB Gateway PAPER. - Connect data and execution clients and complete reconciliation.
- Resolve
AUD.USD=CASH.IDEALPRO. - Confirm broker and Nautilus are initially flat with zero working orders.
- Submit one MARKET BUY order for
25,000 AUDwith a known Nautilusclient_order_id. - Observe that the broker acknowledges and fills the order.
- Inspect the Nautilus order cache/state after the fill.
- Observe that:
- the original submitted order remains
ACCEPTEDwithfilled_qty=0, while - a second reconciliation/external order representation receives the fill and produces
PositionOpened.
- the original submitted order remains
- Submit the corresponding MARKET flatten order.
- Observe the same accepted-original / filled-reconciliation split again.
- 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:
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 != O0The 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_traderversion: 2.0.0rc3- Installed from: PyPI pre-release wheel
- Adapter/venue: Interactive Brokers / IB Gateway PAPER / IDEALPRO
Source: nautechsystems/nautilus_trader