Skip to content
All library documents

Mean-Reversion Trading of the WTI–Brent Futures Spread

Code Awesome Systematic Trading

Summary

The strategy tracks the daily price difference between continuous WTI and Brent crude futures and compares it with a 20-day simple moving average. When the spread is above its average, it takes positions intended to profit from a decline toward that reference level; when below, it takes the opposite positions, anticipating a rise. The example uses opposing holdings in the two contracts and closes or reverses exposure when the spread crosses the average. It also defines daily historical data handling, leverage, and a custom fee calculation.

The code illustrates implementation mechanics, not evidence of profitability: it supplies no performance statistics, validation, or discussion of parameter sensitivity. Its mean-reversion premise may fail when the relationship shifts or trends persist. Continuous, back-adjusted futures data and the sizing of the two legs also affect results; those details require careful review before interpreting a backtest or applying the approach.

Key ideas

  • The strategy defines the spread as the WTI price minus the Brent price.
  • It uses a 20-day simple moving average as the spread’s reference level.
  • A spread above its average leads to short WTI and long Brent exposure, while a spread below leads to the reverse.
  • The example liquidates when recent data is stale and assigns leverage and a custom fee model.
  • The code provides no performance evidence, and spread behavior may depart from the assumed mean reversion.

Tags

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