---
title: "Kalman Filter Hedge Ratios: Bank Nifty on Nifty"
description: "A Kalman filter hedge ratio built step by step on a year of Nifty and Bank Nifty closes, with the dial, a trading test of every setting and the lots it implies."
source_url: "https://www.rupeecase.com/learn/path-18/module-18-14-kalman-filter-hedge-ratios"
---

[Path 18 14 of 14](/learn/path-18/)Kalman filter hedge ratios[Path 18](/learn/path-18/)

Fit the hedge ratio of Bank Nifty on Nifty over the previous sixty sessions and read it on the last day of February 2026. It is close to zero. Read the same fit on 31 Jul 2026 and it is above one and a half. Same indices, same method: from almost no hedge to more than one and a half for one. A fixed ratio is too stiff for that, and a rolling one is too jumpy. The Kalman filter is the third answer: let the ratio drift, and let each day's surprise decide how far. This lesson builds the filter in plain steps, shows what it does to the Nifty and Bank Nifty ratio on a year of dated closes, and asks whether a moving ratio finds a spread worth trading or only makes an old spread look calm. Dated NSE data, nothing live, nothing a view.

3By the end you can

1. Build the predict, forecast, compare and update loop of a Kalman hedge ratio and read its one dial, q.
2. Explain why a more mobile ratio makes the leftover spread look more mean reverting without proving it is.
3. Judge a filtered spread by a fixed rule on later days, with lots and costs in the picture.

Watch in the terminal: how fast did the model grow? A short tutorial on sample data.

## The idea, plainly

### The problem a fixed ratio hides

The [cointegration toolkit](/learn/path-18/module-18-7-cointegration-toolkit) fitted one ratio on a formation window and froze it. If the relationship between the two prices moves, the frozen ratio goes stale and the spread drifts for a reason that is not mean reversion. The usual patch is to refit on a rolling window. That swaps one choice for two: the window length, and the fact that every day's refit is a fresh draw from a short sample. The ratio then jumps about, and a pair that needs a stable hedge gets an unstable one.

### The filter in plain words

The Kalman filter treats the ratio as a hidden number that follows a random walk: the next day's ratio is the last one plus a small unknown step. Each day it does the same four things.

* **Predict.** The ratio is what it was, and the doubt about it grows a little.

* **Forecast.** Use the predicted ratio to say where the Bank Nifty should close given the Nifty.

* **Compare.** The gap between the forecast and the actual close is the innovation, the day's surprise.

* **Update.** Move the ratio by a share of the surprise. That share is the gain: large when the doubt about the ratio is large next to the noise in the data, small otherwise.

Predict, forecast, compare, update: the ratio moves by a share of each surprise

One day of the filter. The gain is set by two noise levels: how much the ratio is allowed to wander, and how noisy the closes are. Their ratio, called q here, is the only dial. An illustration of the method, with no prices. Source: RupeeCase illustration of the method. As of 17 Oct 2026.
The maths: the recursion
Let y be the log of Bank Nifty and x the log of Nifty. The state b holds the slope and the intercept, h is the row of x and one.

b(t) = b(t-1) + w
y(t) = h(t) b(t) + v
P = P + Vw
e(t) = y(t)-h b
Q = h P h' + Ve
K = P h' / Q
b = b + K e(t)
P = P-K h P

The noise in w is Vw and in v is Ve. I set Vw to q times Ve, so one number, q, decides how freely the ratio moves. A very small q gives a filter that behaves like a regression over everything seen so far. A large q gives one that chases yesterday's close. The standardised innovation is e divided by the square root of Q, and if the model were right it would have unit variance and no pattern.

### Two things the filter does not do

It does not create mean reversion. The innovation is the part of today's close that the ratio did not predict, and the filter updates the ratio from it. Raise q and the ratio absorbs more of every deviation, so the leftover looks calmer and less persistent. That looks like reversion and is partly a property of the method.

Read 2 more paragraphs, 134 words
It does not choose q either. The dial sets how stiff the ratio is, and no part of the data says what the right stiffness is. If I pick q to make the spread look best on the same days I will trade, I have fitted the dial to the answer.

And it does not know a break from noise. If the link between the two indices changes for good, because index weights moved or a rule changed, the filter adapts a few days later and the old spread vanishes without a mark. A frozen ratio would have shown the break as a spread that never returns. That makes the filter a smoother, not a detector, and a trader who wants to know that a relationship has gone has to look at something else.

### q is a window length in disguise

A rolling regression forgets everything older than its window all at once. The filter forgets gradually: each new day counts a little more than the one before it. A larger q means a shorter memory, a smaller q a longer one. So the dial does the job that the window length does in a rolling fit, with smoother edges. That is useful, and it is also why q needs the same discipline: pick it on one stretch of data and test on another, and never on the days that will judge the rule.

Appendix: one update by hand
Take a ratio of one, a doubt about it of one hundredth, noise in the close of four hundredths, and a regressor of one. The doubt over the doubt plus the noise gives a gain of one fifth. If the close comes in a quarter above the forecast, the innovation is a quarter, the ratio moves up by a twentieth to one and five hundredths, and the doubt falls from one hundredth to eight thousandths. The next morning the filter adds a little doubt back, since the ratio is allowed to wander, and the cycle repeats. The quiz works the same numbers.

## Worked example: Bank Nifty on Nifty, a year of closes

Watch in the terminal: what does "Same money in NIFTY 50" mean? A short tutorial on sample data.

### Which number is the hedge ratio

The file holds three hundred daily closes of both indices from 1 Jul 2025 to 15 Sep 2026. The chart lines up the estimates a trader could have held. The filter starts from a fit to the first sixty sessions, and I judge everything from 25 Sep 2025 on.

Four ways to fit the ratio, four different answers

The rolling fit is refitted every session on the last sixty. The Kalman filter uses a middle setting of its dial, q equal to a hundredth. The ratio is in log terms, which is close to a ratio of values. Same closes, same dates. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read one more paragraph, 79 words
The whole file gives about three quarters, the first sixty sessions about one, and a rolling fit anything from nothing to almost two. The filter stayed in a narrow band around one, and moved slowly inside it. Its ratio was above one from 12 Mar 2026 and drifted down after late Jul. That is the case for the filter: it shows the relationship moving without the jumps. It is not yet a case that the movement is worth following.

### One dial, two readings

Now turn the dial. At the smallest settings the filter behaves like a regression over everything it has seen, and its innovations are strongly persistent: the spread wanders. At the largest the ratio chases every close, and the leftover forgets most of yesterday.

The more the ratio moves, the less the leftover remembers

The lower the bar, the faster the leftover from the filter forgets yesterday. A tall bar is a spread that wanders. A low bar can mean a spread that reverts, or a ratio that has simply absorbed it. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read one more paragraph, 47 words
This is the trap in one picture. Across the six settings the leftover goes from a spread that barely forgets to one that forgets most of yesterday. Nothing about the Nifty and Bank Nifty changed. Only the dial did. A lower bar is not a better spread.

### The test that decides

So I ran the trade as a test on past data. Each day the rule was long the leftover when it stood low against its recent size and short when it stood high, up to a fixed limit, hedged with that day's ratio, and it collected the next day's change in the spread. The same rule ran for each setting, and for the frozen and rolling fits for comparison.

No setting of the dial made money, and the fixed ratios did no better

Index closes, a limit on the position, the hedge ratio of the day, and the next day's change in the spread. About two hundred and forty sessions. Every t statistic is between about minus one and a half and zero, so none of the means can be told from noise. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read one more paragraph, 97 words
Every bar is below zero before costs, and none is far enough from zero to mean anything: the t statistics run from about minus one and a half to zero, for a daily noise of about fifty to seventy basis points on the filtered rules. The frozen and rolling ratios did about as well. The filter did not find a trade in this pair. It found a way to describe the pair more smoothly. I would take that as the honest output of the method here, and I would not tune q until a bar turned positive.

### What a changing ratio means in lots

The filter's ratio moved by less than a fifth in any month, and a trader can only hold whole lots. On 10 Jun 2026 one lot of the near Nifty future was worth Rs 15,10,607 and one lot of Bank Nifty Rs 16,56,012, so the lots are close in value. SEBI's circular of 1 Oct 2024 asks for lot sizes that keep the value on the day of review between 15 and 20 lakh rupees, and both lots sit inside that band. A move in the ratio from the lowest to the highest value of the filter's band changes the Bank Nifty needed against a hundred Nifty lots by about twenty lots. Against one lot the same move is a fifth of a lot, which cannot be traded. At small size the ratio is a number on a chart, not a position. Each rebalance also pays the statutory charges, with STT of 0.05% on the sale of a future.

Appendix: why I centre the Nifty series
The log of Nifty sits near ten and barely moves, so the slope and the intercept of the regression are almost interchangeable. The filter then gives a wrong share of each surprise to each of them, and the ratio swings for no reason. Subtracting the average of the first sixty sessions from the log of Nifty makes the intercept the level of Bank Nifty at the average Nifty, and the slope the ratio alone. The forecasts do not change, but the ratio becomes readable.

### Where this meets India

The legs are index futures, which expire monthly, settle in cash and need a roll by the last day. Each lot is a fixed number of units, set by NSE and revised from time to time, and an index future moves in ticks that depend on the level of the index. A filter that wants a ratio change of a few hundredths to a sixth in a month has to be sized so that the change is a whole lot, and at that size the costs of changing it count. The same filter on two stock futures adds delivery on the last day, the ban list and the lot mismatch of the [stock futures pair lesson](/learn/path-18/module-18-8-pair-trading-with-stock-futures). A smooth hedge ratio does not remove any of that.

Two terms to hold on to from 18.14

From the module glossary. Source: Module 18.14, Kalman filter hedge ratios.

## The common mistake

The claim: A Kalman filter adapts the hedge ratio, so the pair never breaks down. The filter follows a ratio that moves. It does not make a spread revert, and it can absorb a break so quietly that nothing looks wrong. In this file the setting of the dial changed how calm the leftover looked, from persistent to short lived, while the result of trading it stayed below zero in every case. Before trusting a filtered spread, ask how q was chosen, on which days, what the same rule earns with a fixed ratio, and whether the hedge moves by whole lots.

## Key takeaways

* The filter lets the hedge ratio drift and updates it from each surprise.
* One dial, q, sets how freely the ratio moves.
* A freer ratio makes the leftover look more mean reverting, partly by construction.
* No setting of the dial made the Bank Nifty and Nifty rule positive here.
* A ratio that moves by fractions of a lot cannot be followed at small size.

The term this section turns on: q

From the module glossary; every term is in the Learn glossary too. Source: Module 18.14, Kalman filter hedge ratios.
**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 Kalman filter hedge ratios cover?A ratio that drifts looks calmer than one that is fixed. Whether it is better is a different question. It works through The idea, plainly, Worked example: Bank Nifty on Nifty, a year of closes, The common mistake, Key takeaways. It is module 18.14 of Path 18, Arbitrage and Relative Value, about 11 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.14

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.

18Path test

## 30 questions. 21 correct earns the certificate.

30 questions drawn from the 210 in the banks of the 14 live modules of Path 18, 18.1 to 18.14, a fresh set each attempt, with no timer. Your score stays on this device.

* **30**questions
* **21**to pass (70%)
* **14**modules covered

Start the testOnly the path test decides the path certificate. The module quizzes are optional: pass them too for each module's own certificate and a tick on every stop.

  Passed

###

  Certificate ID

Download PNGPrint or save as PDF[Check the ID](/learn/certificates/verify)Retake the test
[All your certificates, and the master certificate](/learn/certificates)

CCheck yourself

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

Stop 14 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)
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#quiz)
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.13Backtest overfitting: deflated Sharpe, PBO and multiple testing11 min read](/learn/path-19/module-19-13-backtest-overfitting)
* [ToolOption payoff builderLegs on a dated Nifty chain, breakevens and charges](/learn/tools/payoff-builder)
* [Free module 18.7Cointegration toolkit: Engle Granger, ADF, half life and z score10 min read](/learn/path-18/module-18-7-cointegration-toolkit)
* [Free module 18.8Pair trading with Indian stock futures10 min read](/learn/path-18/module-18-8-pair-trading-with-stock-futures)
* [Free module 18.9Mean reversion against momentum10 min read](/learn/path-18/module-18-9-mean-reversion-vs-momentum)
* [Free module 18.13Baskets, PCA stat arb and Johansen tests11 min read](/learn/path-18/module-18-13-pca-stat-arb)

      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.
7 sources, NSE the most cited

The publisher of each source listed below. Source: Module 18.14 source list.
1. [NSE, equity derivatives contract specifications (index futures, lots, tick sizes, monthly expiry)](https://www.nseindia.com/static/products-services/equity-derivatives-contract-specifications) NSE
2. [NSE, lot sizes of equity derivatives (fo_mktlots)](https://nsearchives.nseindia.com/content/fo/fo_mktlots.csv) NSE
3. [NSE circular NSE/FATAX/73524, STT on equity derivatives from 1 Apr 2026](https://nsearchives.nseindia.com/content/circulars/FATAX73524.pdf) NSE
4. [NSE circular NSE/FA/73061, transaction charges from 1 Mar 2026](https://nsearchives.nseindia.com/content/circulars/FA73061.pdf) NSE
5. [SEBI circular of 1 Oct 2024, measures to strengthen the equity index derivatives framework (contract size and margins)](https://www.sebi.gov.in/legal/circulars/oct-2024/measures-to-strengthen-equity-index-derivatives-framework-for-increased-investor-protection-and-market-stability_87208.html) SEBI
6. Chan, E. P., Algorithmic Trading, Wiley, 2013 (the chapter on mean reversion, with the Kalman filter hedge ratio) Book
7. [Kalman, R. E. (1960), A new approach to linear filtering and prediction problems, Journal of Basic Engineering](https://doi.org/10.1115/1.3662552) Paper

GTerms

## 5 terms from this module.
Kalman filterA recursion that tracks a hidden quantity, here the hedge ratio, by predicting it and then correcting it with each new observation.
InnovationThe actual value less the value forecast from the prediction: the day's surprise. The filter updates the state from it.
GainThe share of the innovation used to update the state. It is large when the doubt about the state is large next to the noise in the data.
qThe ratio of the noise allowed in the hedge ratio's step to the noise in the data. It is the filter's one dial and is not estimated by the filter.
Rolling regressionA hedge ratio refitted every day on the latest window of closes. It depends on the window length and jumps between refits.
[All 230 terms in the glossary](/learn/glossary)

[Question people askWhat is a Kalman filter pairs strategy?A short answer with a dated chart](/learn/questions/kalman-filter-pairs)[Related module18.7 Cointegration toolkit: Engle Granger, ADF, half life and z score10 min, Advanced](/learn/path-18/module-18-7-cointegration-toolkit)[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.
