# nautechsystems/nautilus_trader architecture

> Architecture diagram of the GitHub repository nautechsystems/nautilus_trader, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nautechsystems/nautilus_trader
- Repository: https://github.com/nautechsystems/nautilus_trader

## Overview

NautilusTrader is a Rust-native, event-driven trading system with Python as a control plane. Its main workflow is to configure and run a strategy in simulation or live mode, consume normalized market data through venue adapters, and manage execution and portfolio state. The README documents these product capabilities and shared strategy semantics; source-index references additionally support the backtest engine’s relationship to its Python interface. Several runtime paths are represented at subsystem level because their implementation was not sampled.

Main entry points: [`crates/backtest/src/engine.rs`](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/backtest/src/engine.rs) (Backtest engine), [`crates/trading/src/controller.rs`](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/trading/src/controller.rs) (Trading API), [`crates/pyo3/src/lib.rs`](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/pyo3/src/lib.rs) (Python control plane), [`crates/adapters/derive/src/http/query.rs`](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/adapters/derive/src/http/query.rs) (Venue adapters)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["Strategy control"]
  node_python["Python control plane<br/>[lib.rs]"]
  node_controller["System controller<br/>[controller.rs]"]
  node_trading["Trading API<br/>[controller.rs]"]
end

subgraph group_market["Market connectivity"]
  node_adapters["Venue adapters<br/>[query.rs]"]
  node_network["Network clients<br/>[client.rs]"]
end

subgraph group_runtime["Trading runtime"]
  node_data["Data engine<br/>[client.rs]"]
  node_execution["Execution engine<br/>[manager.rs]"]
  node_portfolio["Portfolio manager<br/>[manager.rs]"]
  node_risk["Risk engine<br/>[mod.rs]"]
end

subgraph group_simulation["Simulation"]
  node_backtest["Backtest engine<br/>[engine.rs]"]
  node_sim_modules["Simulation modules<br/>[mod.rs]"]
  node_backtest_python["Python backtest API<br/>[engine.rs]"]
end

subgraph group_state["State and persistence"]
  node_event_store["Event replay<br/>[replay.rs]"]
  node_persistence[("Persistence storage<br/>[storage.rs]")]
end

node_user(("Strategy user"))
node_venue(("Trading venue"))

node_user -->|"configures"| node_python
node_python -->|"orchestrates"| node_controller
node_controller -.->|"runs strategies"| node_trading
node_trading -.->|"consumes data"| node_data
node_data -->|"requests feeds"| node_adapters
node_adapters -->|"translates APIs"| node_venue
node_adapters -.->|"uses transport"| node_network
node_trading -.->|"submits orders"| node_execution
node_execution -.->|"routes orders"| node_venue
node_execution -.->|"updates state"| node_portfolio
node_backtest_python -->|"wraps engine"| node_backtest
node_backtest -->|"dispatches modules"| node_sim_modules
node_python -->|"configures simulation"| node_backtest_python
node_backtest -.->|"replays market data"| node_data
node_backtest -.->|"simulates portfolio"| node_portfolio
node_trading -.->|"checks risk"| node_risk
node_backtest -.->|"stores results"| node_persistence
node_event_store -.->|"replays events"| node_backtest

click node_python "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/pyo3/src/lib.rs"
click node_controller "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/system/src/controller.rs"
click node_trading "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/trading/src/controller.rs"
click node_data "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/data/src/client.rs"
click node_adapters "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/adapters/derive/src/http/query.rs"
click node_network "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/network/src/websocket/client.rs"
click node_execution "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/execution/src/order_manager/manager.rs"
click node_portfolio "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/portfolio/src/manager.rs"
click node_risk "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/risk/src/engine/mod.rs"
click node_backtest "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/backtest/src/engine.rs"
click node_sim_modules "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/backtest/src/modules/mod.rs"
click node_backtest_python "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/backtest/src/python/engine.rs"
click node_event_store "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/event_store/src/replay.rs"
click node_persistence "https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/persistence/src/common/storage.rs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_python,node_controller,node_trading,node_user toneBlue
class node_adapters,node_network toneAmber
class node_data,node_execution,node_portfolio,node_risk toneMint
class node_backtest,node_sim_modules,node_backtest_python toneRose
class node_event_store,node_persistence,node_venue toneIndigo
```

## Components

### Strategy control

- [Python control plane](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/pyo3/src/lib.rs): `crates/pyo3/src/lib.rs`
- [System controller](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/system/src/controller.rs): `crates/system/src/controller.rs`
- [Trading API](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/trading/src/controller.rs): `crates/trading/src/controller.rs`

### Market connectivity

- [Venue adapters](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/adapters/derive/src/http/query.rs): `crates/adapters/derive/src/http/query.rs`
- [Network clients](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/network/src/websocket/client.rs): `crates/network/src/websocket/client.rs`

### Trading runtime

- [Data engine](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/data/src/client.rs): `crates/data/src/client.rs`
- [Execution engine](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/execution/src/order_manager/manager.rs): `crates/execution/src/order_manager/manager.rs`
- [Portfolio manager](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/portfolio/src/manager.rs): `crates/portfolio/src/manager.rs`
- [Risk engine](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/risk/src/engine/mod.rs): `crates/risk/src/engine/mod.rs`

### Simulation

- [Backtest engine](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/backtest/src/engine.rs): `crates/backtest/src/engine.rs`
- [Simulation modules](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/backtest/src/modules/mod.rs): `crates/backtest/src/modules/mod.rs`
- [Python backtest API](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/backtest/src/python/engine.rs): `crates/backtest/src/python/engine.rs`

### State and persistence

- [Event replay](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/event_store/src/replay.rs): `crates/event_store/src/replay.rs`
- [Persistence storage](https://github.com/nautechsystems/nautilus_trader/blob/develop/crates/persistence/src/common/storage.rs): `crates/persistence/src/common/storage.rs`

### Other components

- **Strategy user**
- **Trading venue**

## Connections

- Strategy user → Python control plane: configures (evidence: `README.md`)
- Python control plane → System controller: orchestrates (evidence: `README.md`)
- System controller → Trading API: runs strategies
- Trading API → Data engine: consumes data
- Data engine → Venue adapters: requests feeds (evidence: `README.md`)
- Venue adapters → Trading venue: translates APIs (evidence: `README.md`)
- Venue adapters → Network clients: uses transport
- Trading API → Execution engine: submits orders
- Execution engine → Trading venue: routes orders
- Execution engine → Portfolio manager: updates state
- Python backtest API → Backtest engine: wraps engine (evidence: `crates/backtest/src/python/engine.rs`)
- Backtest engine → Simulation modules: dispatches modules (evidence: `crates/backtest/src/engine.rs`)
- Python control plane → Python backtest API: configures simulation (evidence: `README.md`)
- Backtest engine → Data engine: replays market data
- Backtest engine → Portfolio manager: simulates portfolio
- Trading API → Risk engine: checks risk
- Backtest engine → Persistence storage: stores results
- Event replay → Backtest engine: replays events
