Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Simple Pairs Trading Strategy: BP & Shell

Regression dates: 2014 - 2018

4 responses

Thanks for posting this. A good example of cointegration at work.

Having previously worked in Oil & Gas Exploration & Production (O&G E&P) myself for many years, while modeling financial markets was also my hobby outside of my "day job" before i "retired", i was quite interested to look at a few others including not only the publicly listed Major operating companies (OpCos) such as BP, XOM, CVX, some of the smaller companies such as APA, DVN, etc, as well as the oilfield service companies SLB, HAL, etc, and various oil-related ETFs, and of course the prices of the underlying commodities Oil, Gas, and refined products.

By looking at financial entities of similar size and operational profiles where many of the same factors are at work in both, these should be some very nice low-risk market-neutral trades, as you have identified. The problem that i found was that the cointegration relationships that hold so well for periods of limited duration (e.g. the last 3 years in your example certainly look great) but can also break down suddenly with little or no warning. Sometimes the unpredictable reasons are readily apparent (e.g. a platform fire or tanker oil spill for example), at other times the reason is less clear (e.g. Haliburton's involvement in various non-oilfield operations), and sometimes the reason for the breakdown in the relationship is not clear at all, perhaps related to "investor sentiment" as much as anything else. Whatever the reasons, the caveat is that the nice relationships that are so carefully found can also suddenly disappear without much warning. But nevertheless, still potentially good opportunities. Nice example. Cheers, best regards.

Nice work! For reasons Tony mentioned, most people add a good news feed as a filter to improve performance. Stocks are more likely to mean revert if there is no news.

I’m also very impressed. Thanks for sharing!

Thanks for sharing. However, I found that by softmax_order function. It will not short any equity, so it is possible that the profit will be gone when the market is going downward, which is not a proper pair trading from my opinion.