NAUTILUS / RUST source 3eb18933
Pages

Rust edition: this page follows the live DeepWiki structure but treats the current Rust crates as implementation authority. Non-Rust surfaces are identified at their boundary and are not presented as Rust APIs.

Key Features and Components

Relevant Rust source files

  • crates/core/src/lib.rs
  • crates/model/src/lib.rs
  • crates/system/src/kernel.rs
  • crates/backtest/src/node.rs
  • crates/live/src/node/mod.rs

This page summarizes the native Rust engine, model, data, execution, persistence, backtest, live, and selected adapter capabilities at the pinned revision.

Rust trading-system graph showing Databento and Interactive Brokers feeding the Nautilus data, execution, risk, message-bus, portfolio, cache, and database components.

The diagram is source-qualified to the pinned Rust checkout. Interactive Brokers is marked as evolving develop source because the adapter is native Rust but not published at this revision.

Multi-Account Execution

NautilusTrader supports multi-account execution, enabling a single trading node to manage multiple accounts simultaneously across different venues. This capability is essential for institutional deployments, fund management, and strategies requiring account segregation.

Multi-Account Architecture

Boundary Owned value Routing responsibility
Strategy AccountId on each order command Selects the intended trading account explicitly
RiskEngine Account balances, margin, and limits Validates the command against account-scoped state before execution
ExecutionEngine Client and account routing state Routes approved commands to the venue client associated with the account
Execution client Venue-native account reference Translates the Nautilus account identity into the broker protocol
Portfolio Account-scoped positions and PnL Applies execution reports without merging unrelated account state

Key Features:

  • Account-Level Routing: Orders specify target AccountId for precise execution control.
  • Independent Risk Management: Per-account balance checks, margin calculations, and risk limits are enforced by the RiskEngine
  • Separate Position Tracking: Each account maintains isolated position state within the Portfolio
  • Specialized Account Types: Supports CashAccount, MarginAccount, and BettingAccount

Implementation: Strategies submit orders with an explicit account_id. The Portfolio component handles account-scoped net exposure and balance updates, supporting PortfolioSnapshot events

Selected adapter integration

The adapter layer translates provider and broker protocols into standard Rust DataClient and ExecutionClient contracts. This edition selects only Databento and Interactive Brokers.

Supported Venues

Databento historical and live DBN records converging through the Nautilus Databento adapter, model, data engine, and shared consumers.

Interactive Brokers order commands passing through risk and execution engines to the broker, with execution and account reports returning to shared state.

Databento supplies historical and live market data plus DBN decode and symbology. Interactive Brokers supplies live market data, execution, account reports, and reconciliation.

Databento is distributed as a published crate. The Interactive Brokers crate is native Rust but declares publish = false at the pinned revision, so it must be consumed from a compatible source checkout.

Advanced Order Management

The system supports a wide range of order types and execution instructions, operating with nanosecond precision

Execution Instructions:

  • post-only, reduce-only, and icebergs
  • Contingency Orders: OCO (One-Cancels-Other), OTO (One-Triggers-Other), and OUO (One-Updates-Other)
  • Time In Force: Supports IOC, FOK, GTC, GTD, DAY, AT_THE_OPEN, and AT_THE_CLOSE

Market Data System

NautilusTrader provides high-granularity data types, including support for granular order book updates and derivatives-specific data

Data Type Taxonomy

The canonical data taxonomy includes system events (InstrumentStatus, InstrumentClose), aggregated values (Bar, QuoteTick, TradeTick), derivatives updates (MarkPriceUpdate, IndexPriceUpdate, FundingRateUpdate, OptionGreeks), and order-book values (OrderBookDelta, OrderBookDeltas, OrderBookDepth10).

Key Data Features:

  • Order Book Types: Supports L3_MBO (Market-by-Order), L2_MBP (Market-by-Price), and L1_MBP (Best Bid/Offer)
  • Delta Flags: Uses F_LAST and F_SNAPSHOT bitmasks from RecordFlag to signal event boundaries for the DataEngine
  • Option Greeks: Added SBE and Cap'n Proto support for OptionGreeks

Bar Aggregation Methods

The platform implements various aggregation methods to transform ticks into structured bars

Method Trigger Category
TICK Number of ticks Threshold
VOLUME Traded volume Threshold
VALUE Notional value Threshold
RENKO Fixed price movements Threshold
MINUTE/HOUR/DAY Time intervals Time
TICK_IMBALANCE Buy/sell tick imbalance Information

Core System Components

The architecture is built around the NautilusKernel, which orchestrates engines via a high-performance MessageBus

  • ExecutionEngine: Manages order lifecycles and routes to venue-specific clients
  • RiskEngine: Performs pre-trade validation including notional limits and balance checks
  • DataEngine: Handles fan-in/fan-out of market data and bar aggregation
  • Portfolio: Tracks balances and positions, supporting netting and hedging OMS types
  • Cache: Stores instruments, orders, and positions with Redis/PostgreSQL backing

Rust crate architecture

NautilusTrader utilizes a Rust-native crate architecture for maximum performance and flexibility

Layered Rust crate dependency map showing the Nautilus foundation crates, engine layer, system kernel, backtest and live runtimes, and the selected Databento and Interactive Brokers adapters.

The arrows summarize compile-time composition rather than runtime message direction. nautilus-system assembles the shared engines into NautilusKernel; nautilus-backtest and nautilus-live provide different environments over that shared semantic core. The selected adapters join at live client-factory boundaries rather than redefining the model or engines.

Key Technical Details:

  • Native crate composition: Engine, model, persistence, and adapter crates compose through typed Rust contracts.
  • Plugin System: The nautilus-plugin crate allows loading separately compiled Rust cdylibs at live-node startup
  • Precision Modes: Supports both 64-bit and 128-bit fixed-point precision for financial calculations

Backtesting and Live Trading

The system ensures research-to-live parity, allowing strategies to move from backtests to production with zero code changes

  • Deterministic Time: A nanosecond resolution time model ensures identical execution semantics in simulation and live
  • BacktestEngine: Optimized Rust-native backtesting engine
  • LiveNode: Orchestrates live trading components, now featuring Unix SIGTERM handling in the Rust shutdown path
  • Analysis: Rust analysis and portfolio components expose performance results for downstream presentation.

Testing and Quality Assurance

The codebase is protected by a rigorous CI/CD pipeline and extensive standards.

  • Provenance: Release artifacts carry SLSA cryptographic attestations and Docker images are signed via cosign
  • Code Quality: Enforced through rustfmt, Clippy, Cargo tests, security checks, and repository pre-commit hooks.
  • MSRV: The pinned source revision requires Rust 1.97.0.