Skip to content
All library documents

Event-Driven Forex Backtesting with Historical Tick Data

Article QuantStart

Summary

This development diary describes changes to a forex trading system: correcting how positions use bid and ask prices, adding historical tick data from CSV files, and building an initial event-driven backtester. The position update distinguishes trade direction from order side, so long and short positions use the appropriate prices when opened and valued. Historical prices are sent to the rest of the system as tick events through a shared price-handler interface, allowing live and backtest data sources to fit the same event flow.

The author favors an event-driven, multithreaded simulation because it can represent execution and transaction-cost behavior more closely than a vectorized research backtest. A limitation is that thread scheduling can make repeated runs on identical data produce different trades and returns. The diary suggests measuring that variation as an indication of sensitivity to data latency, while noting that a single-threaded simulator would be more deterministic but less like the live system. The described setup is still limited to one currency pair and a GBP base currency.

Key ideas

  • Long positions open at ask and are valued for closing at bid, while short positions use the opposite sides.
  • A common price-handler interface can feed historical and live ticks into the same event-driven system.
  • CSV tick data supports a more execution-aware backtest than a simple vectorized calculation.
  • Multithreaded scheduling can make repeated simulations nondeterministic.
  • Variation in repeated-run returns can indicate sensitivity to data arrival timing.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.