NautilusTrader Documentation
website·Indexed 33 days ago
https://nautilustrader.io/docsAn open-source, production-grade, Rust-native trading engine infrastructure for multi-asset, multi-venue trading. It provides a high-performance core with a Python control surface via PyO3, featuring components for event sourcing, deterministic simulation testing (DST), risk management, and a pluggable architecture for custom strategies and adapters.
What's inside NautilusTrader
- Deterministic Simulation Testing (DST) allows NautilusTrader to run under a seed-controlled runtime to ensure reproducible execution. By replacing ambient process state (task wake order, timer resolution, OS thread scheduling, and randomized hash seeds) with a seeded pseudorandom sequence, two runs with the same seed, binary, configuration, and platform will produce identical observable behavior. This is primarily used to detect and replay concurrency defects such as channel wakeup ordering, drain races during shutdown, and recovery-path correctness.
Overview of Databento Integration in NautilusTrader
NautilusTrader provides an adapter for the Databento API and Databento Binary Encoding (DBN). This adapter is designed for market data retrieval and does not include an execution client. It supports loading historical DBN files, requesting historical data via HTTP API, and subscribing to real-time data feeds via TCP API. The adapter is built using the officialdatabento-rsRust crate, which is linked automatically during build; no separate installation of thedatabentolibrary is required.Overview of Continuous Futures in Nautilus Trader
A continuous future is a derived series that splices consecutive futures contracts into a single adjusted price stream. Because futures contracts expire, the series 'rolls' to the next contract at specific transition points. To prevent artificial price jumps caused by contract changes, each segment is adjusted into a common price frame. In Nautilus, a continuous future is defined by a targetBarType(the continuous root) and a list of roll transitions provided in the request or subscription parameters.Overview of NautilusTrader Value Types
NautilusTrader provides three specialized value types for core trading concepts. These types use internal fixed-point arithmetic to ensure performant and deterministic calculations across platforms.
Type Purpose Signed Currency QuantityTrade sizes, order amounts, positions No - PriceMarket prices, quotes, price levels Yes - MoneyMonetary amounts, P&L, account balances Yes Yes Overview of Hyperliquid Adapter Components
The Hyperliquid adapter is implemented in Rust with Python bindings and integrates directly with Hyperliquid's REST and WebSocket APIs. It consists of several low-level components, though most users typically interact with them via a live trading node configuration.Overview of OKX Integration Components
The OKX adapter is implemented in Rust with PyO3 bindings for Python and does not require external OKX client libraries. It consists of several components that can be used independently or together:
OKXHttpClient: Low-level HTTP API connectivity.OKXWebSocketClient: Low-level WebSocket API connectivity for Rust callers.OKXDataClient: Market data feed manager.OKXExecutionClient: Account management and trade execution gateway.OKXDataClientFactory: Factory for creating OKX data clients.OKXExecutionClientFactory: Factory for creating OKX execution clients.
Overview of built-in market data types
NautilusTrader provides several built-in data types categorized by their role in the market data lifecycle. These types are used across backtesting, sandbox, and live environments. Data flowing over the message bus is organized under thedataroot, with live streams usingdata.<kind>...and pipeline paths usingdata.pipeline.<kind>....Overview of Custom Data in NautilusTrader
NautilusTrader allows users to define custom data types authored in either Python or Rust. Both authoring modes utilize the same runtime routing, persistence (via ParquetDataCatalog), and query pipelines as built-in data. Custom data is wrapped in a common PyO3CustomDatacontainer to cross the Python/Rust boundary and is identified by aDataTypeobject for routing and storage.Overview of nautilus-network transport clients
NautilusTrader adapters utilize thenautilus-networklibrary for network communication. The library provides three primary clients that wrap underlying Rust transports with trading-specific policies such as rate limits, liveness checks, and reconnect control.Overview of NautilusTrader Behavioral Models
Behavioral models are pluggable components in NautilusTrader that define the rules for specific calculations or decisions within the system. They allow users to modify system behavior (such as how fills are simulated or how fees are calculated) without changing the core engine or strategy code. Models are configured as objects during setup or via runtime APIs.Overview of NautilusTrader data flow
Data follows a consistent pathway regardless of the environment (Live, Sandbox, or Backtest):
- Ingestion: In live/sandbox, a venue adapter creates a normalized object. In backtests, the engine feeds data directly.
- Processing: The
DataEnginereceives the data. - Storage & Distribution: The
DataEnginestores cached types in theCacheand publishes all data on theMessageBusfor subscribed handlers.
Overview of Coinbase Advanced Trade Integration
The Coinbase adapter for Nautilus Trader supports live market data ingestion and order execution for spot (Cash) and CFM derivatives (Margin) accounts via the Advanced Trade API. It is implemented in Rust and exposed to Python. Key components include theCoinbaseRawHttpClientfor low-level REST/JWT handling,CoinbaseWebSocketClientfor connectivity, andCoinbaseExecutionClientfor managing orders and streams.