Reducing Numba JIT Compilation Delays in HftBacktest
Summary
HftBacktest uses Numba-compiled classes and strategy functions, so importing the library and compiling a strategy can add startup time before a backtest begins. The document describes enabling Numba’s cache option on a strategy function so compiled code can be reused and reduce repeated compilation overhead.
The example places a compiled strategy in a backtest configured with market data, an initial snapshot, order latency, a queue model, tick and lot sizes, and trading fees. It does not report timing measurements or compare cached and uncached runs. Caching addresses compilation delay; it does not change the strategy logic, market simulation, or the time needed to run a backtest. The document notes that startup cost may matter less for longer multi-day backtests, but offers no guidance on cache invalidation or deployment-specific behavior.
Key ideas
- HftBacktest relies on Numba JIT compilation for its classes and strategy functions.
- Compilation can add noticeable startup time before backtests run.
- Enabling Numba’s cache option for the strategy function may reduce repeated compilation overhead.
- The example configures market data, latency, queue behavior, instrument parameters, and fees, but provides no performance measurements.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.