The world’s leading publication for data science, AI, and ML professionals.

Rolling on the Futures curve – continuous Futures prices

Using Python to create custom continuous futures price timeseries for backtesting and trading.

Photo by M. B. M. on Unsplash
Photo by M. B. M. on Unsplash

Disclaimer

This article does not offer investment advice and nothing in it should be construed as investment advice. It provides information and education for individuals who can make their investment decisions without advice.

The information contained in this article is not, and should not be read as, an offer or recommendation to buy or sell or a solicitation of an offer or recommendation to buy or sell any securities. It is not, and should not be seen as, a recommendation to use any particular investment strategy.


In today’s capital markets, futures provide one of the most capital efficient ways to trade a wide variety of asset classes. Their use ranges from everything including hedging future currency exposure to taking outright positions in commodities to shorting equity index volatility.

Historically, even though futures are very capital efficient and require relatively low margin compared to their notional, the absolute size of these notionals meant that they were not appropriate instruments for retail investors with smaller account sizes.

The development and listing of multiple smaller futures contracts (minis and micros) in recent years has changed this dramatically. There are smaller futures contracts offered for equity indices, volatility, oil, corn and other commodities and even bitcoin. This makes the asset class interesting now for retail traders, especially from a systematic investment point of view.

Futures

The challenge

Systematically backtesting and trading futures strategies comes with its own challenges though, with the main difficulty being to create a continuous time series from the underlying futures. Contracts with different expiries rarely trade with the same price, causing jumps in the timeseries if their prices were just stitched together.

As an example, let’s look at the VIX Futures contracts with expiries in June and July 2021. The June contract expired on the 16th of June.

If we would just switch from one Futures to the next on the roll date and stitch the price time series together, the jump in the chart below on the 16th of June (marked in red) is entirely a product of the two contracts trading at different levels and does not represent the actual behaviour in the market.

The stitched timeseries shows a jump from 17.1 on June 15th to 19.625 on June 16th, an increase of 14.8%, whereas the change in the July futures contract would have actually been just 0.3%!

Stitched timeseries for June & July 21 VIX Futures (Image by Author)
Stitched timeseries for June & July 21 VIX Futures (Image by Author)
VIX Futures Prices Snapshot (Image by Author)
VIX Futures Prices Snapshot (Image by Author)

It is clear that introducing artificial jumps like these can completely alter any form of data analysis or backtest performed on this time series.

The solution

There are various methods that can be used to tackle this issue in order to obtain a timeseries suitable for backtesting and analysis. The most common ones are the Panama Adjustment, Proportional Adjustment and using Perpetual Rollovers. Each of these methods come with their own pros and cons. Let’s look at each of them and their implementation using python.

Panama Adjustment

This method removes the gap between the different futures contracts by shifting each previous contract by the difference in price of the futures at the roll date. In our example above where the price of the July Futures on the roll date was 19.625 and the price of the June Futures was 16.38, it would mean shifting all prices before the roll upwards by 3.245.

A simple python function that performs the Panama Adjustment looks as follows:

Applying the Panama Adjustment results in this price time series.

Futures timeseries after using the Panama Adjustment (Image by Author)
Futures timeseries after using the Panama Adjustment (Image by Author)

Quite different to the stitched timeseries!

This is a very simple method that comes with a few cons. The main issue is that it introduces a trend bias, which can cause a large drift to the prices. In some cases this can lead to negative prices for older contracts. There is also a loss of the relative price information in the timeseries as the shift is in absolute terms.

Nevertheless, this is one of the most common methods that is used.

Proportional Adjustment

In contrast to the absolute shift used by the Panama method, the proportional adjustment method uses a relative adjustment of the old prices. This provides a continuous timeseries without introducing any bias.

However, the issue with this approach is that any strategy relying on the absolute price level would need to be adjusted in a similar manner to the timeseries which requires an immense amount of care as it is extremely easy to introduce errors using this approach.

Futures timeseries after using the Proportional Adjustment (Image by Author)
Futures timeseries after using the Proportional Adjustment (Image by Author)

Perpetual Rollover

This method uses a linear combination of the two futures involved in the roll over x number of days. E.g. if you would roll over 5 days, on day 1 you would roll 20% from the old to the new contract to have 80% exposure to the old contract and 20% to the new one. On day two you would have 60% in the old one and 40% in the new one and so on. By day 5, you would have completed your roll.

While this method provides a very smooth transition, its main drawback is that in actual trading, one would need to trade on all these days and potentially incur higher transaction costs.

Futures timeseries after using Perpetual Rollover (Image by Author)
Futures timeseries after using Perpetual Rollover (Image by Author)

Conclusion

In this article I have presented three different methods to create a continuous futures timeseries for backtesting and analysis. All of these methods have their own advantages and disadvantages and it ultimately depends on your specific application which method would work the best. However, this should give you a good starting point.

If you want to learn more about the intricacies of futures backtesting and trading, check out out Quantra’s 12hr comprehensive course on Automating Futures Trading with python.

Futures Trading: Concepts & Strategies | Quantra by QuantInsti


Note from Towards Data Science’s editors: While we allow independent authors to publish articles in accordance with our rules and guidelines, we do not endorse each author’s contribution. You should not rely on an author’s works without seeking professional advice. See our Reader Terms for details.


Related Articles