Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Low Vol, Uncorrelated Alpha in Pair Trading Oil Spreads

This strategy was developed to take advantage of short-term swings in the price spread between Brent and WTI (represented in the trading pair BNO and USO). The idea was that the spread would deviate from the mean over the short-run due to various macroeconomic, international policy, transportation/logistics, military conflicts, national crises, and a myriad of other far-reaching issues, but that in the long-run the spread would return to the mean.

We choose an entry point of positive or negative 1.8 standard deviation where we would go long one of the assets and short the other to gain positive alpha return while the spread returns to zero. Since the spread is calculated BNO minus USO (since BNO generally holds a premium to USO), whenever the spread reached the positive 1.8 standard deviation we should short BNO and go long USO as the spread would likely make its way back to zero (which is the mean). If the spread reached the negative 1.8 standard deviation then we would do the opposite - short USO and long BNO. The reason we chose the 1.8 standard deviation instead of a smaller or larger value is because we wanted to catch the spread on the way back to the mean (meaning we wanted a value larger than the first standard deviation), but we also wanted the algorithm to trade semi-actively so we wanted a value less than the second standard deviation. We settled on the value of 1.8 since it was closer to the second standard deviation, allowing us to catch the spread on the way back to the mean in a more active fashion without succumbing to a lot of the noise which would happen if the standard deviation value for the entry point were somewhere in the 1-1.5 mark.

In realizing that our algorithm would not be able to catch the spread right at the point where it reverted back to the mean since we only scheduled the trading function to happen once an hour in to the train day, we decided to make our exit point at the point where the absolute value of the deviation of the spread was less than 1. This way we would catch a nice profit from the spread moving back towards the mean (the journey from positive or negative 1.8 to less than positive or negative 1) while still having a nice back stop to make sure we didn't exit the positions too late after the point where the spread crossed over the mean again but in the opposite direction. This also helped manage slippage (due to the illiquidity of BNO) where we would have a nice cushion from 1 (or negative 1) back to zero while we exited BNO - which usually took most of the trading day.

You can look at the research notebook here --> https://www.quantopian.com/research/notebooks/BNO-USO%20Pairs%20Trading%20Research%20Notebook.ipynb

3 responses

Very cool! Curious if you've looked at strategies trading Futures pairs (or triplets, quadruplets, etc) instead of ETFs? I would think that there should be some measurable correlation within Energy, Precious Metals, Index Futures, etc, that one could build a strategy around, though I could be wrong. Tight risk management would be key I reckon.

That's a gem, Michael Harris for a simple algorithm!

Good illustration using ETF (also XOP Index as benchmark) and nice set of metrics too!
Noted also preference to hold cash (flat segments in returns graph) rather than risking/hedging in XOP.

Wonder how it performs if using order_optimal_portfolio with a simple risk constraint:

order_optimal_portfolio(  
        opt.TargetWeights(adjusted_weights),  
        constraints=[opt.MaxGrossExposure(1.0)])  

Thanks Joakim, and no I haven't looked into futures yet but that could definitely help avoid some slippage issues with BNO since avg. daily volume is less than a million. I could also see about some sort of strategy that looks at oil producers or other highly correlated equities and use the correlations to pair trade triplets, quadruplets, etc.

Thanks Karl as well. I'll need to try order_optimal_portfolio and play around with some simple risk constraints. I'm also of course cautious to see if I overfit the algo and need to find an unrelated pair with similar correlation (above 95%) and see if it will still work.