Skip to content
All library documents

Building a Strategy Class for an Event-Driven Backtester

Article FMZ forum · Author: 善

Summary

This article outlines the strategy layer in an event-driven backtester. A strategy receives market bars from a data handler and emits signal events for a portfolio through an event queue. The design uses an abstract base class with a signal-calculation method, allowing specific strategies to implement their own rules while remaining independent of whether data is historical or live. Indicators and filters are noted as possible extensions but are outside the article’s scope.

As a concrete example, the article describes a buy-and-hold strategy that sends one long signal for each symbol when its first usable bar arrives, then marks that symbol as already bought to prevent duplicate signals. This is presented as a simple implementation and a benchmark for testing the strategy interface. It is not a complete backtester or a performance evaluation; portfolio accounting, profit and loss tracking, and more advanced strategies are left to later development.

Key ideas

  • A strategy consumes market data and produces signal events for a portfolio to process.
  • An abstract strategy interface defines a method that derived strategies implement to generate signals.
  • The buy-and-hold example emits one long signal per symbol and tracks whether it has already done so.
  • The strategy layer can use either historical or live data through the data handler interface.
  • Indicators, portfolio accounting, and performance evaluation are outside this article’s scope.

Tags

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