Expand description
Live trading node built on a single-threaded tokio event loop.
LiveNode::run() drives the system through a tokio::select! loop that
multiplexes data events, execution events, trading commands, timers, and
periodic maintenance tasks (reconciliation, purge, prune, audit).
§Threading model
The core types (ExecutionManager, ExecutionEngine, Cache) use
Rc<RefCell<..>> and are !Send. All access happens on the same thread.
The select! macro runs one branch to completion (including inner awaits)
before polling the next, so RefCell borrows held across .await points
within a single branch cannot conflict with borrows in other branches.
§Startup sequencing
Startup connects clients in two phases so that instruments are in the cache before execution clients read them:
- Connect data clients (instruments arrive as buffered
DataEvents). - Flush all pending data events and commands into the cache via
flush_pending_data, which loopstry_recvon the channel receivers until no items remain. - Connect execution clients (
load_instruments_from_cachenow finds populated instruments). - Drain remaining events, then run reconciliation.
Both run() (integrated event loop) and start() (manual lifecycle)
follow this sequence.
§Reconciliation
Continuous inflight and open-order checks run on independent intervals. The shared maintenance timer in the select loop dispatches reconciliation at the minimum enabled interval. Each dispatch the handler checks which sub-checks are due based on elapsed nanoseconds and schedules their work. Continuous checks do not await venue HTTP in the select loop: open-order and position checks poll bulk venue report futures from the loop.
§Maintenance dispatcher
Six periodic tasks share a single coarse maintenance_timer:
- reconciliation (inflight, open, position sub-checks)
- purge closed orders
- purge closed positions
- purge account events
- own-books audit
- recent-fills cache prune
The runner wakes one timer per loop iteration regardless of how many
maintenance tasks are configured. Each task tracks its own
next_fire: Instant and the dispatcher fires the bodies whose deadline
has passed, rescheduling next = now + interval (equivalent to
MissedTickBehavior::Delay). Disabled tasks anchor on a far-future
next that never trips.
The 100ms timer cadence is the effective floor for any maintenance
interval. Configured intervals below 100ms (the config types allow
inflight_check_interval_ms and own_books_audit_interval_secs smaller)
get rounded up to the next tick. Real workloads do not run venue or cache
maintenance below 100ms (defaults are seconds to minutes). Cadence drifts
by at most one body duration per fire.
Re-exports§
pub use builder::LiveNodeBuilder;
Modules§
- builder
- Builder for constructing
LiveNodeinstances. - config
- Configuration types for live Nautilus system nodes.
- plugin
- Live-node plug-in support.
Structs§
- Live
Node - High-level abstraction for a live Nautilus system node.
- Live
Node Handle - A thread-safe handle to control a
LiveNodefrom other threads.
Enums§
- Node
State - Lifecycle state of the
LiveNoderunner.