Skip to main content
The NanoARB backtesting engine uses an event-driven architecture to simulate realistic trading with configurable latency, fills, and risk management.

Quick Start

Basic Backtest Example

Backtest Engine Architecture

The engine is defined in nano-backtest/src/engine.rs:33-64.

Engine Components

Event-Driven Workflow

The backtest processes events in chronological order (engine.rs:260-276):

Event Processing

Event Types

From events.rs:10-76, the engine processes:

Event Flow Example

Market data event → Strategy decision → Order submission:

Engine API

Creating an Engine

Registering Instruments

From engine.rs:94-99:

Scheduling Events

From engine.rs:113-115:

Running the Backtest

From engine.rs:260-276:

Loading Market Data

From Binary MDP3 Feed

From CSV Data

Strategy Integration

Your strategy must implement the Strategy trait:

Accessing Results

From engine.rs:319-348:

Engine State Management

From engine.rs:18-30:

Resetting the Engine

From engine.rs:368-385:

Performance Optimization

Event Capacity Pre-allocation

Batch Event Processing

Disable Expensive Recording

Complete Example