Skip to content

Instantly share code, notes, and snippets.

@stefansimik
stefansimik / run_backtest.py
Last active February 3, 2025 13:49
MRE - Minimalistic reproducible example for Nautilus Trader
from datetime import datetime, timezone
import pandas as pd
from nautilus_trader.backtest.engine import BacktestEngine
from nautilus_trader.backtest.models import MakerTakerFeeModel
from nautilus_trader.config import BacktestEngineConfig, LoggingConfig, StrategyConfig
from nautilus_trader.core.datetime import dt_to_unix_nanos
from nautilus_trader.model.currencies import USD
from nautilus_trader.model.data import Bar, BarSpecification, BarType
from nautilus_trader.model.enums import (
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

🔄 Current System Analysis & Limitations

The current backtesting system handles many order-fill scenarios effectively, particularly with L2 data. While the existing probabilistic FillModel serves its purpose for basic scenarios, there are several significant limitations that prevent realistic simulation of market dynamics:

Key Limitations

  1. Can't Simulate Competition for Liquidity
  • The system cannot model how market participants compete for available liquidity, treating all visible volume as fully accessible.