Two prices that stay together, and the trap of searching
Log prices aₜ and bₜ are each non-stationary, yet they are cointegrated if some combination sₜ=aₜ-βbₜ-α is stationary: the two drift together and the spread sₜ keeps returning to zero. The hedge ratio comes from an ordinary regression of a on b with a constant, sm.OLS(a, sm.add_constant(b)).fit(); its slope is β and its intercept α. How fast the spread reverts is measured by an AR(1): sₜ=c+φsₜ₋₁+uₜ. With 0<φ<1 the half-life is -ln 2/lnφ periods, the time to close half of a gap; φ near 1 means a random walk and no trade. The Engle-Granger test, coint(a, b), tests the null that the spread has a unit root, so a small p-value is evidence of cointegration. It uses special critical values, because the spread comes from a regression and is not an ordinary series.
Now search. Test 66 pairs at the 5% level and about 3 will pass by pure chance; with persistent prices the test is even more generous. A Bonferroni correction divides the level by the number of tests, 0.05/66, and keeps only the very small p-values. Here, on the first 669 weekly observations of 12 stocks, 13 of the 66 pairs have p<0.05 and 2 survive Bonferroni, and the best are not economically natural: a bank (WFC) with a beverage maker (PEP), p=0.0005. The honest check is out of sample. Fix the hedge ratio on the first half, form the spread on the second half, and test again. None of the five best pairs is still cointegrated (p-values 0.54 to 0.86), and the AR(1) coefficient of the later spread is 0.99: it no longer reverts. A strategy built on a search needs a correction for the search, and a test on data the search never saw.
- Cointegration means a stationary spread a-βb-α; the Engle-Granger null is a unit root, so small p means cointegrated.
- Half-life -ln 2/lnφ from the AR(1) coefficient tells how long a gap takes to close; φ≥1 means never.
- Search, correct, then test out of sample: 66 pairs find noise; Bonferroni helps; only later data tells.
Lab · what's graded
- The hedge ratio10 pts
- The spread5 pts
- The AR(1) coefficient10 pts
- The half-life10 pts
- The Engle-Granger test5 pts
- Scanning all pairs15 pts
- Counting discoveries10 pts
- Out of sample15 pts
- The pairs study20 pts