Mattheus Public Preview

Join Waitlist

Mattheus Public Preview

Current Blog

How to Model Futures Contract Rolls in a Backtest

A futures backtest should roll between named contracts with a rule fixed in advance, executable prices on both legs, point-in-time liquidity, and product-specific expiration constraints.

Published Updated
Two glass futures contract lanes pass through a warm cream handoff as the expiring contract fades and the forward contract continues

By alyc

This article was prepared with AI assistance and checked through automated editorial and source review. No named human review is recorded.

A futures backtest should store and trade named contracts, choose its roll rule before the test, and execute the exit and entry at prices that were available at that moment. A continuous series can help calculate signals. It should not supply fills unless its values match an actual listed contract.

For every roll, record the old contract, new contract, decision timestamp, rule version, order timestamps, prices, quantities, multiplier, fees, spread, and data observed at the decision. This makes the change of contract an auditable trade instead of an invisible edit to the price history.

Keep every named contract intact

Store each delivery month as its own instrument. The record should include the root symbol, contract month and year, exchange, multiplier, tick size, currency, trading calendar, last trade date, settlement method, and any first notice or delivery dates that apply.

The Commodity Futures Trading Commission explains that futures contracts are agreements for a future transaction. Some settle in cash, while others contemplate delivery. It also notes that most contracts are liquidated before delivery. A backtest still needs the contract's actual terms because a missed roll can create an exposure the strategy never intended.

Do not infer every product's dates from a generic third-Friday rule. CME Group notes that expiration timing varies by contract. Use the historical exchange calendar for that product and retain it with the research data lineage.

Fix the roll rule before the test

A calendar rule might move from the near contract to the next contract a fixed number of sessions before last trade or first notice. A liquidity rule might roll after the next contract's eligible volume exceeds the near contract's volume. Either approach can work when it is defined in advance and uses information available by the decision timestamp.

Product conventions differ. CME Group states that equity index futures may be rolled at any time, while its customary roll date is the Monday before the third Friday for the listed US index products. That convention is evidence for those products, not a universal rule for energy, rates, metals, or agriculture.

A volume or open-interest crossover needs an availability timestamp. End-of-session totals cannot trigger an earlier intraday decision. If the data vendor later revises the series, keep the value and timestamp that the strategy would have seen then. This is the same point-in-time discipline used to prevent look-ahead bias.

Execute both legs with real contract prices

CME Group describes a roll as simultaneously offsetting the current position and establishing the position in a later month. Model both legs. Use historical quotes, trades, or a documented spread-order book that covers the arrival time. Apply latency, bid and offer selection, depth, partial fills, fees, and impact to each leg.

Consider a synthetic equity-index example. A strategy is long two December contracts with a $50 multiplier. At the modeled roll time it sells December at 5,125.25 and buys March at 5,141.75. The March contract is 16.50 index points above December. Re-establishing two contracts moves the cash basis by 16.50 points times $50 times two, which equals $1,650.

That $1,650 is the spread between contract months. It is not an instantaneous $1,650 trading loss by itself. Record realized profit or loss on the December exit and the March entry basis separately. If the fee is $2.50 per contract per leg, four contract sides cost $10.00. Bid-offer cost and market impact remain separate trading-cost inputs.

The example is illustrative, not an empirical result. It assumes both prices are executable at the same decision time, both legs fill for two contracts, the multiplier is $50 per point, and no leg risk develops between fills.

Use continuous series only for analysis

A continuous futures series joins several named contracts into one history. A back-adjusted series removes or redistributes price jumps at roll boundaries. That can make returns and indicators easier to study, but the adjusted price may never have traded.

Calculate fills and account balances from raw named contracts. If a signal uses an adjusted series, store the active contract mapping and adjustment factor for every timestamp. Produce that factor only from data then available. Recomputing the full history after a later roll can change old signal values and leak future information into the past.

Keep the raw files, transformations, roll schedule, and adjustment factors in the data-lineage record. Researchers should be able to reproduce both the signal series and the executable trade path.

Respect sessions and expiration events

A roll rule measured in sessions needs the correct exchange calendar. Holidays, early closes, overnight sessions, and daylight-saving changes affect when data becomes eligible and when orders can trade. Use the product's actual market calendar and time zone.

Store last trade, settlement, first notice, and delivery events as distinct fields. Do not let a strategy hold a physical-delivery contract beyond its operational cutoff merely because a continuous ticker still has a price. For cash-settled products, model the documented final settlement process if the strategy intentionally holds through expiration.

Test the roll as a state transition

Run explicit invariants against the implementation.

  • The active contract at each timestamp is a listed contract that existed then.

  • The rule uses only calendars, volume, open interest, and prices available by the decision time.

  • The old and new legs have separate orders, fills, fees, and quantities.

  • Contract multipliers and currencies are applied before positions are combined.

  • Back-adjusted prices never become execution prices.

  • First notice, last trade, delivery, and settlement rules come from the correct product history.

  • A partial fill or failed second leg creates recorded leg risk instead of a silent complete roll.

  • The resulting position and cash ledger reconcile before and after the transition.

Also test a holiday-shortened week, a volume crossover published after the close, a thin next contract, a partial spread fill, an exchange-calendar correction, a multiplier change, and a contract whose settlement method differs from another product. A roll is reliable only when the contract choice, input timing, arithmetic, and resulting ledger can be reconstructed.

Explore Markets with Infinite Context.

Explore Markets with Infinite Context.

Browse the public preview. Join the waitlist for gated trading features.

Browse the public preview. Join the waitlist for gated trading features.

Browse the public preview. Join the waitlist for gated trading features.

Dashboard interface preview