Back to Community
Pair trading notebook

I experimented with pair trading as follows:

  • Filtered stock by sector (energy sector only)
  • Picked pairs that have a correlation of more than .95
  • Checked co-integration
  • Filtered by error correction model

I found 1 pair that could be traded out of 150 stocks. I check the out of sample performance and found that the relationship exists for maximum 20 days only. (In sample 90 days, out of sample, 35 days).

Anyone here used other techniques to find pairs? How was your out of sample spread? Does it hold?

Loading notebook preview...
Notebook previews are currently unavailable.
3 responses

Okay, I reduced the correlation threshold from 0.95 to 0.8 and found 54 pairs that can be traded and the out of sample performance of the first one is impressive.

Loading notebook preview...
Notebook previews are currently unavailable.

I have been unable to find consistent OOS results using cointegration. Those pairs that did hold up wound up being super lightly traded, and when backtesting with realistic quote/spread data, the mean-reversion disappeared.

That said, when I was still looking into this stuff (and I might one day go back to it), I found the correlation test totally useless, since some of the most promising pairs were those that had lagged correlations or none at all. Aaron Brown's advice on this topic was excellent: https://www.quantopian.com/posts/how-to-build-a-pairs-trading-strategy-on-quantopian

To quote:

Look at the pairs, concentrating on the ones that seem somewhat related but not completely obvious. Don't just ask why they appear cointegrated, also ask why they deviate in the short term. Ultimately you need both forces to be strong for a robust pairs trade. Also, don't just look at times the relation worked (deviation/correction) but at times when it didn't. Most of the time you'll conclude that either the apparent cointegration or apparent deviations were random noise, discrete events not likely to be repeated or unexplainable.

Thanks for this pravin. So informative.
So is this also backtested in the code?
Best
Andrew