Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Oil Calendar spreads - a story of slippage

Hello everyone, having spent this holiday season trying to figure, out how to trade calendar spreads in CL contracts I thought i should share the results with you. As you will see there is nothing earth-shatteringly complex about this algo, its just a standard linear mean-reversion trading strategy on CL contracts.

My initial thought was to trade the 1year spread (so 1 and 11 or 12 contracts) however, which showed some promise in the research environment. However, upon researching the topic further, i realized that there is virtually 0 liquidity in the 11 / 12 contract so I was forced to implement it using different spreads.

As you can see i have tried to impose volume restrictions on the algo, i.e. not trade if the average volume the last 4 days is below a certain threshold value. It would be nice to see if any of you have another idea how to model liquidity (model it as a time series ?) to make sure we are actually trading the spread and not just taking positions in the front month.

Other feedback is also greatly appreciated however since the algo is very straightforward i doubt there is much to speak about in terms of in terms of implementation.

Best

Magnus

2 responses

Hi,

What is your m_hurst function calculating and why is that useful? I've never heard of that before. How and why are you using that?

I ran your algorithm over a longer time period. There are bouts of time where there this approach is useful and other sections of time where this method does not work as well. I wonder if you could detect the correct market mode (maybe a simple to two state distribution estimated with a HMM) and then turn on and off this mean reversion strategy.

Hi, the hurst parameter is relating the half time of the mean reversion process, I think other threads discuss this approach in detail.

Yea it seems like the approach is only working sometimes, but how much of that is due to low liquidity in the 3rd contract?

To illustrate what i mean consider the 1-12 spread without any volume filter below (we are essentially just trading the 1st future since the latter are not getting the fills).