Generating futures long-only return series using Quandl

Summary

– Generate futures(equity index and commodity) long-only return series using Quandl
– Each futures are rolled on month-end basis
– Returns using pre-populated near future price by Quandl are technically not tradable ones
– This post is translated/modified version of the previous post

Quandl roll mechanism

According to Quandl description, the near future series is populated as follows:

Continuous Contracts – Data from Quandl
https://www.quandl.com/c/futures/continuous

Quandl’s continuous contracts are created using the simplest possible roll algorithm: “end-to-end concatenation”. That is to say, CL1 is always the crude oil contract with the shortest time to expiry; CL2 is the second shortest contract, and so on. On expiry date, CL1 starts to point to the next future in line, and so on all the way down the strip. There’s no price adjustment, and the roll dates are simply the last trading dates.

So returns calculated only by CL1 series are not tradable because return on expiry date(time t) should refer to near future contract on time t, which is not included CL1 series. In other words, return on expiry date is referring different two contracts if you use only CL1.

Proposed roll mechanism

In this post, I will assume futures are rolled on month-end, i.e. near futures are unwound on month-end and next far futures are purchased on the same day. By doing this, all returns become theoretically tradable.

Python code

Note that you need to plug your Quandl token in self.token when you use this code.

Results

Equity index futures
150329_all_log

Commodity futures
150331_comdty

Next step

Since we could generate some benchmark indices, next step would be to come up with statistical investment strategy. Applying basic machine learning would be the first analysis.

Comments are welcome.