Backtesting with NautilusTrader: Engines, APIs, and Simulation Components
Summary
This overview explains how NautilusTrader simulates strategies against historical data. A backtest engine processes a historical data stream through components that are also used in live trading, including portfolios, strategies, execution algorithms, and user-defined modules, then produces performance metrics when processing ends.
It distinguishes a high-level workflow, built around a configurable node, data catalogs, and batch runs, from a low-level workflow that gives direct control over the engine and manual component setup. The reading guide points to detailed topics including data granularity and venues, event sequencing, matching and fill prices, bar and trade execution, fill models, accounts, margin, and simulation modules. This is a software guide rather than evidence about any trading strategy: it describes available modeling areas but does not evaluate their realism or report strategy results. Backtest conclusions depend on the selected data and simulation settings, so the linked execution and fill documentation is relevant when interpreting metrics.
Key ideas
- NautilusTrader backtests replay historical data through strategy and execution components.
- The engine produces results and performance metrics after the data stream ends.
- A high-level API supports configuration, catalogs, and batch runs.
- A low-level API provides direct engine control and manual component setup.
- Data granularity, venue settings, execution sequencing, fills, and margin are key areas to configure.
Tags
Full text
# Backtesting # Backtesting Backtesting simulates trading against historical data using the same core system components used in live trading: built-in engines, the `Cache`, the [MessageBus](../message_bus.md), `Portfolio`, [Actors](../actors.md), [Strategies](../strategies.md), [Execution Algorithms](../execution/algorithms.md), and user-defined modules. A `BacktestEngine` processes a stream of historical data. When the stream is exhausted, the engine produces results and performance metrics for analysis. NautilusTrader offers two API levels for backtesting: | API level | Use when | | ---------- | ----------------------------------------------------------------------- | | High-level | You want `BacktestNode`, config objects, data catalogs, and batch runs. | | Low-level | You want direct `BacktestEngine` control and manual component setup. | The pages in this section describe the current Rust backtest engine and its Python package-root API. ## Reading guide The generated sidebar may sort these pages alphabetically. Use this order when reading the section end to end: | Step | Page | Use it for | | ---- | ------------------------------------------------------- | ----------------------------------------------- | | 1 | [APIs and repeated runs](apis-and-runs.md) | Choose API level, load data, and run batches. | | 2 | [Data and venues](data-and-venues.md) | Match data granularity with venue `book_type`. | | 3 | [Execution flow](execution-flow.md) | Understand sequencing, timers, and trade IDs. | | 4 | [Fill prices and matching](fill-prices-and-matching.md) | Understand deterministic matching behavior. | | 5 | [Trade execution](trade-execution.md) | Use trade ticks, aggressor sides, and queues. | | 6 | [Bar execution](bar-execution.md) | Use bars, OHLC sequencing, and bar timing. | | 7 | [Fill models](fill-models.md) | Configure slippage and probabilistic fills. | | 8 | [Accounts and margin](accounts-and-margin.md) | Configure funding, balances, and margin models. | ## Simulation modules [Simulation modules](simulation-modules.md) describes module configuration, lifecycle, failure handling, and built-in FX rollover and CFD swap behavior. ## Related guides - [Strategies](../strategies.md): Develop strategies to backtest. - [Visualization](../visualization.md): Generate tearsheets from backtest results. - [Reports](../reports.md): Analyze backtest performance data.
Shown in full with attribution under the source's licence. Licence: LGPL-3.0
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.