Backtesting an ICT strategy at 184 speed: timezone-cache + bisect lookup
The author's ICT-based reversal strategy backtest harness initially took 27 minutes for a 30-day simulation on US500 data (210k minute bars). Profiling revealed the bottleneck was not strategy logic but repeated timezone conversions for each bar. By caching timezone offsets and using bisect lookup to find the correct offset for each timestamp, the same simulation now runs in 8.9 seconds—a 184× speedup. The fix required only two evenings of profiling and one targeted code change. The strategy itself remains unchanged; the optimization solely targeted the backtest infrastructure. The author notes that many custom backtesting scripts in Python likely suffer from similar inefficiencies.
Demonstrates that profiling and caching can yield massive speedups in backtesting, enabling faster iteration.