docs/concepts/live.md
NautilusTrader deploys backtested strategies to live markets with no code changes. The same actors, strategies, and execution algorithms run against both the backtest engine and a live trading node.
Live trading involves real financial risk. Before deploying to production, understand system configuration, node operations, execution reconciliation, and the differences between backtesting and live trading.
For how config structs handle defaults, T vs Option<T> semantics, and
builder patterns, see the Configuration concept guide.
For step-by-step setup of TradingNodeConfig, execution engine options, strategy
configuration, and multi-venue wiring, see the
Configure a live trading node how-to guide.
Execution reconciliation aligns the venue's actual order and position state with the
system's internal state built from events. Only the LiveExecutionEngine performs
reconciliation, since backtesting controls both sides.
:::note[Terminology] An in-flight order is one awaiting venue acknowledgement:
SUBMITTED - initial submission, awaiting accept/reject.PENDING_UPDATE - modification requested, awaiting confirmation.PENDING_CANCEL - cancellation requested, awaiting confirmation.These orders are monitored by the continuous reconciliation loop to detect stale or lost messages. :::
Two scenarios:
:::tip Persist all execution events to the cache database. This reduces reliance on venue history and allows full recovery even with short lookback windows. :::
Unless reconciliation is set to false, the execution engine reconciles state for each
venue at startup. The reconciliation_lookback_mins parameter controls how far back the
engine requests history.
:::tip
Leave reconciliation_lookback_mins unset. This lets the engine request the maximum
execution history the venue provides.
:::
:::warning Executions before the lookback window still generate alignment events, but with some information loss that a longer window would avoid. Some venues also filter or drop older execution data. Persisting all events to the cache database prevents both issues. :::
Each strategy can claim external orders for an instrument ID generated during reconciliation
via the external_order_claims config parameter. This lets a strategy resume managing open
orders when no cached state exists.
Orders generated with strategy ID EXTERNAL and tag RECONCILIATION during position
reconciliation are internal to the engine. They cannot be claimed via external_order_claims
and should not be managed by user strategies.
:::tip
To detect external orders in your strategy, check order.strategy_id.value == "EXTERNAL". These orders participate in portfolio calculations and position tracking like any other order.
:::
For all live trading options, see the LiveExecEngineConfig API Reference.
All adapter execution clients follow the same reconciliation procedure, calling three methods to produce an execution mass status:
generate_order_status_reportsgenerate_fill_reportsgenerate_position_status_reportsflowchart TD
Start[Startup Reconciliation] --> Fetch[Fetch venue reports
orders, fills, positions]
Fetch --> Dedup[Deduplicate reports
log warnings for duplicates]
Dedup --> Orders[Order Reconciliation
align order states, generate missing events]
Orders --> Fills[Fill Reconciliation
verify fills, generate missing OrderFilled events]
Fills --> Pos[Position Reconciliation
compare net positions per instrument]
Pos --> Match{Positions
match venue?}
Match -->|Yes| Done[Reconciliation complete
system ready for trading]
Match -->|No| Gen[Generate missing orders
strategy: EXTERNAL, tag: RECONCILIATION]
Gen --> Done
The system reconciles its state against these reports, which represent external reality:
OrderFilled events for missing trade reports.generate_missing_orders is enabled (default: True), generates orders with strategy ID EXTERNAL and tag RECONCILIATION to align discrepancies.reconciliation_lookback_mins is set, the window may miss opening fills.If reconciliation fails, the system logs an error and does not start.
The tables below cover startup reconciliation (mass status) and runtime checks (in-flight order checks, open-order polls, own-books audits).
| Scenario | Description | System behavior |
|---|---|---|
| Order state discrepancy | Local state differs from venue (e.g., local SUBMITTED, venue REJECTED). | Updates local order to match venue state, emits missing events. |
| Missed fills | Venue filled an order but the engine missed the event. | Generates missing OrderFilled events. |
| Multiple fills | Order has partial fills, some missed by the engine. | Reconstructs complete fill history from venue reports. |
| External orders | Orders exist on venue but not in local cache. | Creates orders with strategy ID EXTERNAL and tag VENUE. |
| Partially filled then canceled | Order partially filled then canceled by venue. | Updates state to CANCELED, preserves fill history. |
| Different fill data | Venue reports different fill price/commission than cached. | Preserves cached data, logs discrepancies. |
| Filtered orders | Orders marked for filtering via config. | Skips based on filtered_client_order_ids or instrument filters. |
| Duplicate order reports | Multiple orders share the same identifier. | Deduplicates with warning logged. |
| Position quantity mismatch (long) | Internal long position differs from venue (e.g., 100 vs 150). | Generates BUY LIMIT with calculated price when generate_missing_orders=True. |
| Position quantity mismatch (short) | Internal short position differs from venue (e.g., -100 vs -150). | Generates SELL LIMIT with calculated price when generate_missing_orders=True. |
| Position reduction | Venue position smaller than internal (e.g., internal 150 long, venue 100 long). | Generates opposite‑side LIMIT order with calculated price. |
| Position side flip | Internal position opposite of venue (e.g., internal 100 long, venue 50 short). | Generates LIMIT order to close internal and open external position. |
| Internal reconciliation orders | Orders with strategy ID EXTERNAL and tag RECONCILIATION. | Never filtered, regardless of filter_unclaimed_external_orders. |
| Scenario | Description | System behavior |
|---|---|---|
| In‑flight order timeout | Order remains unconfirmed beyond threshold. | After inflight_check_retries, resolves to REJECTED. |
| Open orders check discrepancy | Periodic poll detects a venue state change. | Confirms status at open_check_interval_secs and applies transitions. |
| Own books audit mismatch | Own order books diverge from venue public books. | Audits at own_books_audit_interval_secs, logs inconsistencies. |
reconciliation_lookback_mins or cache all events locally.:::tip For persistent issues, drop cached state or flatten accounts before restarting. :::
The reconciliation system maintains four invariants:
trade_id and venue_order_id values emitted during reconciliation are deterministic functions of the logical event. The same logical fill or position-adjustment order produces the same ID across restarts, so replayed reconciliation events dedupe against earlier runs instead of being treated as new.These hold even when:
When reconciliation_lookback_mins limits the window, the system analyzes position lifecycles
from fills and adjusts to reconstruct positions accurately.
| Scenario | Description | System behavior |
|---|---|---|
| Complete lifecycle | All fills from opening to current state are captured. | No adjustment. |
| Incomplete single lifecycle | Window misses opening fills, no zero‑crossings. | Adds synthetic opening fill with calculated price. |
| Multiple lifecycles, current matches | Zero‑crossings detected, current lifecycle matches venue. | Filters out old lifecycles, returns current only. |
| Multiple lifecycles, current mismatch | Zero‑crossings detected, current lifecycle differs from venue. | Replaces current lifecycle with a single synthetic fill. |
| Flat position | Venue reports FLAT regardless of fill history. | No adjustment. |
| No fills | Window contains no fill reports. | No adjustment, empty result. |
Key concepts: