Building a Python Strategy Tester with Historical Tick Replay
Summary
This installment develops a Python tester modeled on MetaTrader 5. It outlines tester configuration, validates required settings and values, and loads historical data for specified symbols and dates. The central replay loop processes ticks across those symbols and calls the strategy’s tick handler; the article also discusses alternative modeling modes, account and trade simulation, and generating reports. The project aims to add sequential processing and performance measures such as profit, drawdown, win rate, and trade statistics to an earlier simulator.
The design makes users list every instrument explicitly and select a supported modeling mode through configuration. Input validation checks keys, timeframes, date order, deposit, leverage, and other settings before testing. The article presents an evolving implementation rather than a finished, fully validated platform: it acknowledges that the custom tester remains buggy and lacks some metrics. It does not provide evidence that its outputs match MetaTrader’s tester across cases, so results should be treated as development-stage simulations rather than verified equivalence.
Key ideas
- A Python tester can replay historical ticks across multiple explicitly configured symbols.
- Configuration validation can catch missing, extra, or incorrectly formatted tester settings.
- The main event loop updates symbol data and invokes the strategy handler as ticks are processed.
- Tester modeling choices determine whether data is processed as ticks or bars.
- The project is still incomplete, with acknowledged bugs and missing performance measures.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.