Skip to content
All library documents

Backtesting Continuous Futures Through Contract Rollover Stitching

Article vn.py community

Summary

The post outlines a way to backtest a continuous sequence of dominant futures contracts in a VeighNa-based system. It argues that an exchange-style continuous index can differ from trading actual contracts because it blends contract prices and may produce prices that do not conform to the instrument’s tick size. The suggested workflow obtains each dominant contract’s date range, then runs the backtest across those contracts in sequence.

The implementation notes cover overlapping history for strategy initialization, switching into trading on the next contract, and simulating a close and reopen when a position remains open at rollover. Results from each contract segment are then combined for analysis. The post includes code sketches and says the changes were made for an older VeighNa version, so they may not suit current releases. It does not provide validation results or address all practical rollover details, such as transaction costs, liquidity, or the choice of roll dates.

Key ideas

  • A dominant-contract series can be represented as date ranges linked to specific futures contracts.
  • Separate contract segments can be backtested and their trade and daily result records combined.
  • A position carried across a contract change can be modeled as a close in the old contract and an open in the new one.
  • The next contract’s history needs to begin early enough to initialize the strategy before trading starts.
  • The code sketches target an older VeighNa version and are not accompanied by validation results.

Tags

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