Skip to content
All library documents

Building an Event-Driven Buy-and-Hold Strategy Class

Article QuantStart

Summary

This article describes the strategy layer in an event-driven backtester. A Strategy interface receives market updates and turns them into signal events for downstream portfolio handling. The design separates signal generation from data access and execution, and is intended to work with either historical or live bars supplied by a data handler.

Its concrete example is a buy-and-hold strategy. For each symbol, it checks whether a recent bar is available and whether the symbol has already been bought; if not, it queues a long signal and records that the signal has been sent. The per-symbol state ensures the strategy emits only one entry signal per security and never exits. This simple rule serves as a framework example and possible benchmark, not as evidence of profitable performance. The article leaves indicators, filters, more complex strategies, portfolio accounting, and profit-and-loss tracking to other components or later work.

Key ideas

  • An abstract strategy interface can standardize how market data produces signal events.
  • The strategy reads recent bars from a data handler and places generated signals on an event queue.
  • A per-symbol state dictionary prevents repeated long signals after the initial entry.
  • The example remains continuously long and does not implement exits, indicators, or performance evaluation.

Tags

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