This guide explains what the tester calculates, how to read its results, a worked example, the half-life of mean reversion and the pitfalls of cointegration testing.
What the tester calculates
Using the Engle–Granger method on a formation period, such as the last year of daily closes:
- Hedge ratio (β): the slope from regressing the price of stock A on the price of stock B. It tells you how many units of B to hold against one unit of A.
- Spread: A − β × B for each day.
- ADF statistic and p-value: an Augmented Dickey–Fuller test on the spread. A more negative statistic and a lower p-value suggest the spread is stationary, meaning it tends to revert.
- Half-life: an estimate of how many days the spread takes to close half of a gap from its average.
- Current z-score: how far today's spread is from its average, in standard deviations.
Reading the results
| Result | What it suggests |
|---|---|
| p-value below 0.05 | Evidence of cointegration at the 5% level |
| p-value between 0.05 and 0.10 | Weak evidence |
| p-value above 0.10 | No reliable evidence of cointegration |
| Short half-life, such as under 20 days | The spread reverts quickly enough to trade |
| Very long half-life | Reversion may be too slow to be useful |
A worked example
This is a hypothetical result for two stocks in the same sector over one year of daily data:
- Hedge ratio: 0.82
- ADF statistic: −3.9, p-value: 0.01
- Half-life: 6 trading days
- Current z-score: +2.1
The low p-value suggests the pair is cointegrated over this period, the half-life suggests gaps have closed within about a week on average, and the current z-score shows the spread is stretched. A pairs strategy might sell A and buy 0.82 units of B in value terms, with an exit when the z-score returns to 0. See the pairs trading guide for full rules.
The half-life of mean reversion
The half-life comes from regressing the daily change in the spread on the previous day's spread. If the slope is λ (a negative number for a mean-reverting spread):
Half-life = −ln(2) ÷ λ
A spread with a half-life of 6 days closes half of any gap in about 6 days on average. It also guides a sensible maximum holding period for trades.
Choosing the order of the pair
The Engle–Granger test can give different results depending on which stock is A and which is B. Run it both ways. If one direction passes and the other does not, treat the evidence as weaker. The Johansen test, which handles both directions at once and can test more than two series, is an alternative.
Pitfalls
- Spurious results. With many pairs tested, some will pass by chance. Testing 100 pairs at the 5% level can produce around five false positives. Prefer pairs with a clear economic link.
- Relationships break. Mergers, regulation, management changes or business shifts can end a relationship permanently. Re-test regularly and use stops.
- Formation-period bias. A pair chosen because it looks good on one period should be tested on the next period before trading.
- Corporate actions. Splits, bonuses and dividends must be adjusted for, or they will distort the spread.
- Execution. Trading the pair needs both legs, often through stock futures for overnight shorts in India, with lot sizes that rarely match the hedge ratio exactly.
Correlation vs cointegration
| Correlation | Cointegration | |
|---|---|---|
| Measures | Whether returns move together | Whether price levels share a stable relationship |
| Needed for pairs trading | Helpful as a first filter | Essential |
| Can two stocks have one without the other? | Yes | Yes |
The stock correlation matrix is a useful first screen; this tester is the second step.
Start your free trial
Connect your broker, build a strategy and test it on paper before a single live order goes out.
Frequently asked questions
What is a cointegration test?
A statistical test of whether a combination of two price series, such as A minus a multiple of B, tends to return to a stable average.
What p-value means two stocks are cointegrated?
A p-value below 0.05 is the usual threshold for evidence of cointegration. It is evidence, not proof, and it can change with the period tested.
How long should the test period be?
Commonly one to two years of daily data. Longer periods give more data but may include old relationships that no longer hold.
Can cointegration change over time?
Yes. Relationships can weaken or break, so pairs should be re-tested regularly.
Sources
- Engle, R. F. and Granger, C. W. J. (1987). Co-Integration and Error Correction: Representation, Estimation, and Testing. Econometrica, 55(2), 251–276
- Johansen, S. (1991). Estimation and Hypothesis Testing of Cointegration Vectors in Gaussian Vector Autoregressive Models. Econometrica, 59(6), 1551–1580
- Chan, E. P. (2013). Algorithmic Trading: Winning Strategies and Their Rationale. Wiley
