---
title: "Cointegration toolkit: ADF, half life and z score"
description: "The Engle Granger test step by step on dated Nifty and Bank Nifty closes: hedge ratio, ADF against strict values, half life, z score and a held out check."
source_url: "https://www.rupeecase.com/learn/path-18/module-18-7-cointegration-toolkit"
---

[Path 18 7 of 14](/learn/path-18/)Cointegration toolkit: Engle Granger, ADF, half life and z score[Next 18.8](/learn/path-18/module-18-8-pair-trading-with-stock-futures)

On 15 Sep 2026 the log spread between Bank Nifty and Nifty stood a little above one usual size from its average if I used every session in the file, and close to zero if I used only the last sixty. Same day, same spread, two answers, and neither was wrong. A z score is a distance measured in the spread's usual size, and the usual size depends on the window you choose. That is the first thing the cointegration toolkit teaches: every number in it is an estimate from a window, and each choice of window is a decision the data did not make for you. This lesson builds the Engle Granger test step by step, adds half life and z score, and runs it on 300 dated NSE closes with a part held out. Nothing here is live, and nothing is a view on a trade.

3By the end you can

1. Run the two steps of the Engle Granger test and read the statistic against the strict cutoffs.
2. Work out a half life from the spread's pull back and a z score from a window, and say why both depend on choices.
3. Explain why many pairs, a fitted ratio and one window each make a pass less reliable.

## The idea, plainly

### Two steps

The [pair trading intuition module](/learn/path-18/module-18-3-pair-trading-intuition) explained why correlation does not make a pair. The Engle Granger method is the standard way to ask the better question. Step one regresses the log of one price on the log of the other over a formation window. The slope is the hedge ratio and the leftover is the spread. Step two tests that spread for a unit root. A unit root means the spread wanders and has no home. Rejecting it is evidence that the spread keeps returning to one.

Fit, test, measure, then judge on days not used

The order of the toolkit. Everything before the last box is estimated on the formation window, and the last box uses only what was frozen at its end. Illustration of the method, with no prices. Source: RupeeCase illustration of the method. As of 15 Sep 2026.

### Reading the statistic

The test statistic is the t value of the spread's own lagged level in a Dickey Fuller regression, with one lagged change added. More negative is stronger evidence of a home. The usual Dickey Fuller table is the wrong ruler here. The regression in step one picked the slope that made the spread as calm as possible, so the spread looks tamer than a random one and the plain table rejects too easily. The Engle Granger values are stricter. For two series with a constant, the five percent value is about minus 3.34, and the one percent value is stricter again.

Half life and z score, in formulas
Fit the spread on its own previous value. The coefficient phi sits between zero and one when the spread pulls back.

s(t) = phi x s(t-1) + e
Half life =
minus ln 2 / ln phi
z = (s minus mean) / sd

A phi of 0.98 gives a half life of about 34 sessions: the gap closes half its distance in that time on average. The mean and sd in the z score come from a window, which is why the same day can read differently under different windows. If phi is at or above one the spread has no half life at all.

### Which way round

A regression is not symmetric. Regress Nifty on Bank Nifty and you get one slope and one statistic. Swap them and both change, because ordinary least squares minimises errors in one variable only. In this sample the two directions gave different statistics and very different half lives, though both failed. If a pair passes in one direction and fails in the other, that is itself a warning. Say which leg is y.

### How long a sample, how long a half life

A half life is only useful next to the sample it came from. If the gap takes about as long as the whole file to close half its distance, the file holds almost no completed returns to learn from. A working rule is to want several half lives inside the sample, and ideally many separate stretches that left the mean and came back. Two years of daily closes is a few hundred sessions, so a half life of a month leaves room for only a handful of cycles. Short windows are noisy, long windows hide breaks. A relationship that held in one stretch can change when index weights change, when a regulation moves a sector, or when the two sets of stocks begin to be traded differently.

The term this section turns on: Half life

From the module glossary; every term is in the Learn glossary too. Source: Module 18.7, Cointegration toolkit: Engle Granger, ADF, half life and z score.

### Many pairs, many chances

Statistical arbitrage means running a rule like this across many pairs or baskets, with small positions and a statistical edge in each. The danger is arithmetic. A test at the five percent level passes about one pair in twenty by luck alone. Screen twenty stocks and there are 190 pairs, so about nine or ten will pass with no home at all. A pair picked as the best of many and judged on the same days is the look ahead bias from the intuition module, only larger.

## Worked example: the pair lab on its default settings

The pair lab regresses Bank Nifty on Nifty over every session from 1 Jul 2025 to 15 Sep 2026, fits the ratio on the first sixty percent, and holds it fixed on the rest. Here is the picture first, then the numbers.

Two indices that share stocks, and a gap that did not stay put

Nifty 50 and Bank Nifty closes from 1 Jul 2025 to 15 Sep 2026, rebased to a common start, with the z score of the log spread over a rolling window of 60 sessions. The rolling window forgets a slow drift, so it understates how far the gap strayed. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Every span of the spread stayed short of the Engle Granger cutoffs

Statistic for the full sample, the fitted span to 19 Mar 2026 and the held out span after it, against the three Engle Granger values. A bar must reach the grey ones to count as a rejection. Source: NSE end of day index closes, computed by RupeeCase. As of 15 Sep 2026.
Read 2 more paragraphs, 120 words
Step one on the formation window, the first sixty percent of sessions to 19 Mar 2026, gave a hedge ratio near 1.07. Step two gave a statistic well short of any cutoff. Held fixed over the remaining sessions, the spread did no better. Refitting the ratio on those sessions alone moved it by more than a quarter, a sign of how loosely the pair is tied.

The half life told the same story from another side. On the fitted span it ran past a hundred sessions, about two thirds of the span it was fitted on. On the held out span it fell to about twenty three, which looks tempting until you notice the spread itself had not returned.

### What the held out spread did

The more useful picture is the z score of the frozen spread, month by month. For the first two months it sat close to zero. From June it spent most sessions beyond two usual sizes, and at the last close it was still there.

After the split the spread drifted away from its fitted mean and stayed away

Z score at each month end of the held out span, measured with the mean and spread of the formation window only. A z beyond two is the usual trigger, and here it arrived and did not leave. Source: NSE end of day index closes, computed by RupeeCase. As of 15 Sep 2026.
Read one more paragraph, 93 words
A trader who entered at a z of two on 9 Jun 2026, the first session beyond it, would have seen a wider gap at three of the four later month ends. The held out test counted one stretch beyond two and no return through zero. Rolling windows of 60 sessions, stepped five sessions at a time, passed the five percent cutoff in two of 49 cases, about what chance alone gives. None of that is a verdict on every pair. It shows what the toolkit says when a pair has no rope.

### One day, four readings

Back to the opening. The same last close, measured four ways:

One close, four z scores: the window is a choice

The spread is the same on 15 Sep 2026. Only the window used for its mean and usual size changes, and with it the reading. Source: NSE end of day index closes, computed by RupeeCase. As of 15 Sep 2026.
None of the four is beyond two. The lesson is the spread between the readings, not any of them. A rule that fires at a z of two needs its window written down before the data is seen, and tested on days it did not shape.

### Where this meets India

The closes used here are index closes, which no one can trade directly. A real pair would use two futures, each rolling every month, each with a lot that cannot be split, and each with its own costs. The ratio the regression asks for is a continuous number, and the exchange sells lots. The next module, [pair trading with Indian stock futures](/learn/path-18/module-18-8-pair-trading-with-stock-futures), works through lots, roll, physical settlement and costs. More than two series need a different test, and a hedge ratio that moves through time needs a different estimator. Both belong to later, more advanced lessons.

### Read the chart yourself

Open the pair lab linked below and change the split from sixty to eighty percent. Note the fitted statistic, the held out statistic and the hedge ratio each time. Ask whether any setting passes on both spans. Then swap which index is y and repeat. If you find a setting that passes, ask how many settings you tried. Every extra try is another chance for luck, and the fair answer to a pass found by searching is to test it on a later period that the search never touched.

## The common mistake

The claim: This pair passed the cointegration test, so the spread has to come back. A pass means that on one sample the spread looked more like a rope than a wandering path, at an error rate of one in twenty at the five percent level. Across many pairs some pass by luck. Relationships also change, and a ratio fitted on one window moved by over a quarter on the next. Ask for four things before taking a result seriously: Engle Granger values and not the plain table, a half life short against the sample, a ratio frozen on one window and judged on a later one, and the number of pairs that were screened to find this one. Even then a pair can break.

Watch in the terminal: how does a dynamic allocation share out its money? A short tutorial on sample data.

## Key takeaways

* Engle Granger regresses first, then tests the spread for a unit root.
* Use the strict Engle Granger values, not the plain table.
* Half life and z score both depend on the window you choose.
* Swapping which price is y changes the ratio and the statistic.
* Test many pairs and some pass by luck.

Two terms to hold on to from 18.7

From the module glossary. Source: Module 18.7, Cointegration toolkit: Engle Granger, ADF, half life and z score.
**Before you trade.** Derivatives trading carries a high risk of loss. SEBI's study "Profitability of Individual Traders in the Equity Derivatives Segment (FY25 to FY26)" (August 2026) found that 87.7% of individual traders in equity F&O made net losses in FY26, with aggregate net losses of Rs 91,685 crore. [Read the SEBI study](https://www.sebi.gov.in/reports-and-statistics/research/aug-2026/study-profitability-of-individual-traders-in-the-equity-derivatives-segment-fy25-fy26-_103835.html)

What does Cointegration toolkit: Engle Granger, ADF, half life and z score cover?Regress, test the spread, time its return, measure its stretch, then judge it on days it never saw. It works through The idea, plainly, Worked example: the pair lab on its default settings, The common mistake, Key takeaways. It is module 18.7 of Path 18, Arbitrage and Relative Value, about 10 minutes of reading, free.

TTry it

## Pair z score lab, on the same example.
Hedge ratio, ADF test, half life and z score bands on two dated series. Dated NSE end of day data, nothing live, no orders.

**Pair z score lab**.

[Open the pair z score lab](/learn/tools/pair-lab)

  AF&O on RupeeCase

## Hedging only, in development
F&O at RupeeCase will do one job: protect a portfolio you already own, by a rule published before it runs. No speculation, no naked option selling, no leveraged bets. It is not available yet.

  [How hedging will work](/hedging)[Sign up for RupeeCase](https://invest.rupeecase.com/signup)

  [No hedgeFalls with the marketWith a putA floor, for a premiumIllustration with made up numbers, not a product and not a recommendation.](/hedging)

QQuick check

## 10 questions, 7 to pass.
Each attempt draws 10 of the 15 questions in this module's bank, and a retake draws a fresh set. A pass gives this module's Certificate of Completion. Your result stays on this device and counts towards the Path 18 certificate.

7 of 10 correct passes module 18.7

Every answer is explained when you check; a retake is always free. Source: RupeeCase Learn quiz rules (70% to pass).

  Passed

###

  Certificate ID

Download PNGPrint or save as PDF[Check the ID](/learn/certificates/verify)
Self paced and unproctored. A record of completing free education by RupeeCase; not a NISM certificate and not endorsed by NISM, NSE, BSE or SEBI. It qualifies no one to deal, advise or publish research.

CCheck yourself

## Path 18 so far.
Your quick check results on this device, stop by stop.

Stop 7 of 14 on Path 18

Arbitrage and Relative Value: every live stop, this module ringed. Source: RupeeCase Learn, Path 18.

1. [18.1Cash futures arbitrage and the Nifty 50 Arbitrage indexNot yet](/learn/path-18/module-18-1-cash-futures-arbitrage)
2. [18.2Conversions and reversalsNot yet](/learn/path-18/module-18-2-conversions-and-reversals)
3. [18.3Pair trading intuition: correlation is not cointegrationNot yet](/learn/path-18/module-18-3-pair-trading-intuition)
4. [18.4Futures calendar arbitrage and roll dynamicsNot yet](/learn/path-18/module-18-4-futures-calendar-arbitrage)
5. [18.5Box spreads with European index optionsNot yet](/learn/path-18/module-18-5-box-spreads)
6. [18.6Parity deviations in practice: what the frictions costNot yet](/learn/path-18/module-18-6-parity-deviations)
7. [18.7Cointegration toolkit: Engle Granger, ADF, half life and z scoreNot yet](/learn/path-18/module-18-7-cointegration-toolkit#quiz)
8. [18.8Pair trading with Indian stock futuresNot yet](/learn/path-18/module-18-8-pair-trading-with-stock-futures)
9. [18.9Mean reversion against momentumNot yet](/learn/path-18/module-18-9-mean-reversion-vs-momentum)
10. [18.10Implied correlationNot yet](/learn/path-18/module-18-10-implied-correlation)
11. [18.11Dispersion trades: construction and risksNot yet](/learn/path-18/module-18-11-dispersion-trades)
12. [18.12The correlation risk premiumNot yet](/learn/path-18/module-18-12-correlation-risk-premium)
13. [18.13Baskets, PCA stat arb and Johansen testsNot yet](/learn/path-18/module-18-13-pca-stat-arb)
14. [18.14Kalman filter hedge ratiosNot yet](/learn/path-18/module-18-14-kalman-filter-hedge-ratios)
15. [TPath test, 30 questionsNot yet](/learn/path-18/module-18-14-kalman-filter-hedge-ratios#pathTestSection)

Path 18 in reading time: 143 minutes over 14 modules

Minutes of reading per module, this one in amber. Source: RupeeCase Learn, Path 18.

    Explore next

## Put the module to work.

* [Free module 19.7Walk forward and out of sample testing10 min read](/learn/path-19/module-19-7-walk-forward-testing)
* [Free module 19.1What a backtest is, and five biases that ruin it9 min read](/learn/path-19/module-19-1-backtest-biases)
* [ToolOption payoff builderLegs on a dated Nifty chain, breakevens and charges](/learn/tools/payoff-builder)

      Community

## Join my WhatsApp group.

      Scan the code, fillFill one short form, and join my WhatsApp group. Slides, sources, factsheets and the rebalance logs live there, and members join a daily Google Meet with me.

      New to RupeeCase? [Getting started](/getting-started) [See the terminal](/terminal)

        [Sign up for RupeeCase](https://invest.rupeecase.com/signup)
        [Join the WhatsApp group](https://forms.gle/C6HMtM1Z2GfeocQV7)

      [One form, one group](https://forms.gle/C6HMtM1Z2GfeocQV7)Scan with your phone camera

SSources

## Go to the source.
6 sources, NSE the most cited

The publisher of each source listed below. Source: Module 18.7 source list.
1. [NSE, equity derivatives contract specifications, including Nifty and Bank Nifty lot sizes](https://www.nseindia.com/static/products-services/equity-derivatives-contract-specifications) NSE
2. [NSE Indices, Nifty 50](https://www.niftyindices.com/indices/equity/broad-based-indices/nifty-50) NSE
3. [NSE Indices, Bank Nifty](https://www.niftyindices.com/indices/equity/sectoral-indices/nifty-bank) NSE
4. [SEBI Investor, Understanding derivatives](https://investor.sebi.gov.in/understanding_derivatives.html) SEBI
5. [NISM, Series VIII Equity Derivatives certification examination](https://www.nism.ac.in/revamp-nism/equity-derivatives/) NISM
6. [Engle, R. and Granger, C. (1987), Co-integration and error correction, Econometrica](https://doi.org/10.2307/1913236) Paper

GTerms

## 5 terms from this module.
Engle Granger testA two step test: regress one log price on another, then test the leftover spread for a unit root against strict values.
Unit rootA spread that wanders with no home level. Rejecting it is evidence that the spread keeps returning.
ADF statisticThe Dickey Fuller t value of the spread. More negative is stronger evidence of a home.
Half lifeMinus the log of 2 over the log of phi, the spread's pull back coefficient. It counts the sessions to close half a gap.
Statistical arbitrageRunning a statistical rule across many pairs or baskets, with small positions in each.
[All 230 terms in the glossary](/learn/glossary)

[Question people askCointegration or correlation: what is the difference?A short answer with a dated chart](/learn/questions/cointegration-vs-correlation)[Question people askHow do I compute the half life and z score of a pair?A short answer with a dated chart](/learn/questions/pair-half-life-and-z-score)[Related module18.3 Pair trading intuition: correlation is not cointegration8 min, Intermediate](/learn/path-18/module-18-3-pair-trading-intuition)[Related module18.8 Pair trading with Indian stock futures10 min, Advanced](/learn/path-18/module-18-8-pair-trading-with-stock-futures)[Pillar guideDerivatives and Quant115 modules across paths 12 to 19](/learn/derivatives)

Education only, not investment advice, a research report or a recommendation to buy, sell or hold any security. RupeeCase (QC Alpha Technologies Pvt Ltd) is not registered with SEBI as an investment adviser or research analyst. Contracts and prices shown are for illustration only, come from NSE end of day files at least 30 days old, and are not recommendatory. Derivatives trading carries a high risk of loss.
