Brief background: I recently started writing a Python code to find stocks which might be cointegrated. I iterated over a really long list of stocks trying to find a pair which might be cointegrated. To my surprise, I found many unrelated companies whose stocks were cointegrated.

I used daily data from yahoo finance, and I used just the first 90 days to find the OLS coefficients (OLS from statsmodels). The spread was found for years starting from 2015 till present. One of the strange pairs I found was that of Facebook and Sherwin Williams. The spread obtained is given below.

Spread between Facebook and Sherwin Williams stocks

Now as you can see, this looks nothing like a stationary process. It shows very clear signs of trends during different periods. However, this passes ADF test with a very good confidence level.

A simple Bollinger Band strategy optimized for the best returns gives the following result.

Pairs trading returns between 'FB' and 'SHW' stocks

Of course, just adding transaction cost of 5bps changes everything. After all, if it was this easy to make money, everyone one earth would have been rich!

I immediately had a few questions and also made a few observations.

  1. How can I minimize the effect of transaction costs?
  2. How can I use data that can potentially help with pairs trading? For instance, can I modulate the spread using data from VIX, and may be from bond ETF prices like HYG, to improve returns?
  3. Two seemingly unrelated stocks are cointegrated. What possible economic reason could result in such unrelated stocks to be cointegrated? Perhaps some big investment firm like Blackrock keeps rebalancing constantly, letting small traders pick up the "leaks"?
  4. There were certain pairs whose spread was not cointegrated. Nevertheless, the gain from pairs trading was significant. So just because a pair is not cointegrated does not mean they are not a profitable pair.
  5. Conversely, there were many cointegrated pairs which were not profitable no matter how I traded the spread. So just because I found a cointegrated pair does not mean the pair that they are profitable as a pair used in pairs trading.
  6. The so called Sharpe ratio was medicore (1 to 1.5 depending on certain factors).
  7. Most importantly, the spread looks nothing like a stationary process. Why then is it passing ADF test?

What I am looking for: There are books written on Statistics for finance. Tsay's book is highly recommended and I am yet to actually look at it.

However, I thought of asking the members of this forum if there is a good source to get answers to my questions above, and for learning about

  1. Statistics of cointegration and how it can be best used in trading
  2. Ways to include influencing factors, mostly interest rates, bond yields etc, in the process of pairs trading.
  3. How to minimize transaction costs?

It would be great to have some kind of undergraduate level reference which talks about the above points and perhaps more. Please let me know if there are such references available.

Edit 1 (Nov 2nd 2021, IST):

As I mentioned above, what we are actually doing is to trade the spread by buying one and shorting scaled version of the other stock, based on the relative position of the spread to its 15-day moving average. Hence the spread itself is not what we need to look at. It got me thinking that I should look at how the difference between the spread and the 15-day moving average, used by my Bollinger Band code, looks like. I have included that graph below.

Difference of Spread and its 15-day moving average

Now this is beautiful. It is still not really stationary because it's variance seems to change quite a bit (and hence, the Bollinger band strategy actually adaptively keeps changing the "Band-Width"). But the mean is for sure constant. Also, the ADF test showed a really good number for the confidence that the unit-root null to be rejected. So all of this makes sense.

However, I would still like to know of resources (preferably undergrad level statistics book on cointegration for pairs trading, or maybe papers) which perhaps also includes some ideas on ways to reduce transaction costs.

  • $\begingroup$ I found the OLS parameters using just first 90 days of data, which is my in-sample time series. It's just a Bollinger band strategy run on the spread thus obtained. I don't think there is any data snooping bias in what I have done. If you think otherwise, please do point me specifically to where data snooping is happening in my approach. $\endgroup$ Nov 5, 2021 at 3:30
  • $\begingroup$ Very good. It seems you have data snooping under control. $\endgroup$
    – nbbo2
    Nov 5, 2021 at 17:59
  • $\begingroup$ Thanks. BTW can you recommend good sources of research papers on quant stuff? $\endgroup$ Nov 5, 2021 at 19:33
  • $\begingroup$ I think the observation "spread - 15 day ma stays constant" doesn't mean much, as you can get this result on practically every series. It's predictive power that matters. $\endgroup$
    – Splinter
    Nov 6, 2021 at 10:35
  • $\begingroup$ The most interesting stuff for me is on SSRN ssrn.com/index.cfm/en/fen But it takes some effort to find the interesting ones. Often I get recommendations from friends, from web sites, etc. If I Google 'pairs trading SSRN' I get some hits, that I haven't evaluated closely. $\endgroup$
    – nbbo2
    Nov 6, 2021 at 11:35


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.