QuantLab now includes a small local profiling surface for the current Python backtest engine.
This is not a benchmark suite for the whole repository.
It exists to answer a narrower question:
- is the backtest inner loop actually the first hotspot worth accelerating?
From the repository root:
python scripts/profile_backtest.pyExample with custom sizes and JSON output:
python scripts/profile_backtest.py --sizes 1000,10000,50000 --repeats 5 --warmup 1 --json-out outputs/profiling/backtest_profile.jsonExample targeting the optional Numba pilot:
python scripts/profile_backtest.py --backend numba --sizes 1000,10000,50000 --repeats 5 --warmup 1The script:
- generates synthetic OHLC and signal inputs
- runs the current Python backtest engine repeatedly
- can target either the default
pythonbackend or the optionalnumbabackend - reports timing for small, medium, and large workloads
- summarizes throughput in rows per second
The goal is not to simulate real strategy quality.
The goal is to compare backtest kernel cost across representative sizes before introducing Numba, C++, or Rust.
The most important fields are:
mean_secondsmin_secondsrows_per_second_avgrows_per_second_maxbackend
Use the results to answer:
- does the current engine become meaningfully expensive at larger sizes?
- is the performance shape stable enough to justify extracting an inner numeric kernel?
- does the optional
Numbapilot materially outperform the Python path on the same workload? - is a compiled extension still justified after trying
Numba?
Interpretation note:
- for small workloads,
Numbacan still lose because warmup and dispatch overhead are not free - for larger workloads, the extracted inner loop is the place where
Numbais most likely to show useful gains
This profiling surface supports the current native-acceleration strategy:
- keep QuantLab Python-first
- target the backtest engine first if profiling confirms it as the main hotspot
- try
Numbabefore introducing a compiled extension
To enable the optional Numba backend:
pip install -e .[perf]