Skip to content
All library documents

Bollinger Band Mean Reversion for Two-Contract Spreads

Code Quant course library

Summary

The document describes a two-leg spread strategy built around Bollinger Bands. It calculates a weighted price difference between two contracts, samples the spread on a five-minute schedule, and compares it with a rolling mean and standard deviation. A move above the upper band opens a short-spread position; a move below the lower band opens a long-spread position. Positions are closed when the spread returns to the middle band.

The example also covers target-position sizing, limit-order placement, cancellation of stale orders, and a bar-based backtest that fills orders against the next bar’s range and open. Its evidence is implementation detail rather than reported performance. The document cautions that multi-contract backtests cannot establish the order of fills within a bar; the described module supports limit orders and does not provide stop orders. The example does not establish profitability or address spread stability, transaction costs, or legging risk.

Key ideas

  • The strategy uses a weighted price difference between two contracts as its spread measure.
  • It opens positions when the spread crosses a rolling Bollinger Band and exits near the mean.
  • Target positions are translated into leg-level orders based on current holdings.
  • The backtest fills limit orders using the next bar’s prices.
  • Multi-contract bar backtests cannot determine the within-bar order of fills.

Tags

From a private course collection; the original is not published.