Fit the hedge ratio of Bank Nifty on Nifty over the previous sixty sessions. On 27 Feb 2026 it reads 0.07. On 31 Jul 2026 it reads 1.67. Same two 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 from its two equations, works one update with a pencil on three dated sessions, tunes its one dial on one stretch of data and tests it on the next, 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. Write the Kalman filter for a hedge ratio as two equations, work one update by hand on dated closes and read its one dial, q.
  2. Choose q on one stretch of data, judge a rule on a later one, and say why a smoothed ratio cannot be used in a test.
  3. Judge a filtered spread by a fixed rule on later days, with lots, statutory charges and the Indian contract rules in the picture.
Two teal and blue strands twisting across the frame, joined by lit rungs

The idea, plainly

The problem a fixed ratio hides

The 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.

Read one more paragraph, 103 words

The word ratio also hides two different numbers. Regress the log of Bank Nifty on the log of Nifty and the slope tells you what counts as the spread: on the whole file of 300 closes it is 0.74. Regress the daily returns instead and the slope tells you how much of one index's daily move the other offsets: on the same file it is 1.13. They answer different questions and they do not agree. The first defines a spread to trade. The second sizes a hedge. I build the filter on the first and then check it on the second.

Two equations: what we see and what we cannot

Everything the filter does follows from two lines. The first says what we observe. The second says how the thing we cannot observe moves.

y(t) = h(t) b(t) + v(t)
b(t) = b(t-1) + w(t)
v ~ N(0, Ve), w ~ N(0, Vw)

Read 2 more paragraphs, 164 words

Here y is the log of the Bank Nifty close. The row h holds the log of Nifty and a one, and the hidden state b holds the slope and the intercept. The noise v is the part of the close the line cannot explain, with variance Ve. The noise w is the step the state may take in one day, with variance Vw. Both are normal and independent of each other. The state follows a random walk because I have no view on which way the ratio will go, only that the next day's is near this day's. That is untrue in detail, since a ratio does not wander forever, and useful as a local description.

What I want each day is a belief about b after the close: a best guess and a variance P. A normal belief stays normal after a normal observation, so those two numbers carry the whole belief. The filter keeps no window of data, only yesterday's belief.

The filter in plain words

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

The Kalman filter as a daily loop: predict the hedge ratio, forecast the spread, observe the close and compute the innovation, update the ratio by the gain times the innovation, then repeat the next dayDiagram with 4 boxes. Predict the ratio to Forecast the close; Forecast the close to Innovation; Innovation to Update by the gain.Predict the ratiodoubt growsForecast the closeratio times NiftyInnovationactual less forecastUpdate by the gainratio moves a share
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.

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 first line adds the doubt the random walk brings in a day. The next two are the forecast error and its variance: doubt about the state carried through h, plus the noise in the close. The gain K is the doubt that belongs to each state element, divided by the total. The last two lines move the state by a share of the surprise and take the information out of the doubt. I set Vw to q times Ve, so one number, q, decides how freely the ratio moves. 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.

The maths: where the gain comes from

Before the close, the belief about b is normal with mean b and variance P. The close is a line in b plus noise, so b and y are jointly normal. For jointly normal numbers the best guess of one given the other is a regression on the surprise:

E[b, y] = b + C (y - h b)
C = Cov(b, y) / Var(y)
Cov(b, y) = P h'
Var(y) = h P h' + Ve

The regression slope C is the gain K, and the variance left over is P minus K h P. Nothing else is in the filter. Set Vw to zero and the recursion is recursive least squares: it reproduces the ordinary regression on everything seen so far, one day at a time, with each new day counting the same as the first. A Vw above zero is the only thing that lets the filter forget.

The simplest case: how fast does it forget?

Strip the regression down to a single number that drifts, so h is one. The gain then settles to a steady value, and that value is set by q alone. In units of Ve, the doubt after an update plus the step q must equal the doubt before it. That gives K squared over one minus K equal to q.

K^2 + q K - q = 0
K = (sqrt(q^2 + 4q) - q) / 2
window = 2 / K - 1

A q of one hundredth remembers about twenty sessions

Model, not market data. The equivalent window in sessions for six settings of q in the scalar filter: about 632 at q of 0.00001, 200 at 0.0001, 63 at 0.001, 20 at 0.01, 6 at 0.1 and 2 at 1q 0.00001 632; q 0.0001 200; q 0.001 63; q 0.01 20; q 0.1 6; q 1 2.Sessions of memory that match each qq 0.00001632q 0.0001200q 0.00163q 0.0120q 0.16q 12
Model, not market data. Inputs: the scalar filter where the state is a single drifting number, steady state gain from K squared plus q K minus q equal to zero, window equal to two over K minus one. In a regression the gain on the slope is also scaled by the regressor, covered below. Source: RupeeCase calculation, steady state of the scalar filter. As of 31 Oct 2026.
Read 2 more paragraphs, 119 words

A steady gain K means each day's close gets a weight K and older days fade by one minus K each day. That is an exponentially weighted average, and it matches a plain average over about two over K minus one sessions. So q has a plain reading. A small q is a long memory and a large q a short one.

A q of 0.01 gives a gain of 0.095 and a window of 20 sessions, close to a rolling month. A q of 0.001 gives about 63, close to the sixty session fit people reach for by habit. The filter has no window length, and in its steady state it behaves as though it had one.

Choosing the two noise variances

Two numbers decide the filter, and the data supply neither. Ve is the noise in the close. I take it from an ordinary fit on the formation window, the first 60 sessions, whose residual standard deviation is 0.0145 in log terms. Vw is the freedom of the ratio. I write it as q times Ve and tune q, in one of three honest ways.

  • Likelihood. Every day the filter forecasts the close and states how wrong it expects to be, with variance Q. It can therefore score itself on a stretch of data, and I pick the q that scores highest.
  • EM. Alternate between a smoother that looks back over the stretch and a re-estimate of both variances from it, until they stop moving. It is the same likelihood, searched more cleverly, and it can learn Ve and Vw together.
  • Diagnostics. Look at the standardised innovations. If the model were right they would have unit variance and no autocorrelation. Neither is a score to maximise. Both are ways to see that the model is wrong.

log L = -1/2 sum over days
of [ ln(2 pi Q) + e^2/Q ]

Read one more paragraph, 56 words

The rule I keep is three stretches that never touch. The first 60 sessions initialise the filter. The next 90 are where q is tuned. The last 150 judge the rule, and nothing learned from them is allowed back into the first two. A dial fitted to the days that judge it has seen the answer.

Scale decides what q means

One thing about q is easy to miss: it is not a pure number. It compares the step of the state with the noise of the data, and the state here is the slope. A step in the slope changes the forecast by x times the step. If the log of Nifty moves only a few hundredths over the stretch, the data barely notice the step, and the surprise is handed to the intercept, the only thing that can soak it up.

The term this section turns on: q

The term this section turns on: qThe term this section turns on: q. q: The 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.qThe ratio of the noise allowed in the hedgeratio's step to the noise in the data. It isthe filter's one dial and is not...
From the module glossary; every term is in the Learn glossary too. Source: Module 18.14, Kalman filter hedge ratios.
Read one more paragraph, 99 words

So two scalings give two different filters. I subtract the mean of the log of Nifty over the first sixty sessions and divide by its standard deviation, 0.0125. The slope inside the filter is then the ratio times that number, and I divide it back to read the ratio. With the log of Nifty only centred, a q of 0.01 kept the ratio between 1.007 and 1.039 for a year. Standardised, the same q gave a ratio from 0.55 to 1.85. Nothing else changed. Any quoted q is meaningless without the scale of the regressor behind it.

Three 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.

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.

Read 3 more paragraphs, 187 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 good 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.

A rolling regression forgets everything older than its window all at once. The filter forgets gradually, so q does the job of the window length with smoother edges. It needs the same discipline: pick it on one stretch of data and test on another, never on the days that will judge the rule.

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

Which number is the hedge ratio

The file holds 300 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

Hedge ratio estimates of Bank Nifty on Nifty from 25 Sep 2025 to 15 Sep 2026: 0.74 on the whole file, 1.01 on the first 60 sessions, a rolling 60 session fit between 0.07 and 1.67, and a Kalman filter between 0.55 and 1.85Whole file regression 0.74; First 60 sessions 1.01; Rolling 60, lowest 0.07; Rolling 60, highest 1.67; Kalman, lowest 0.55; Kalman, highest 1.85.Hedge ratio of log Bank Nifty on log NiftyWhole fileregression0.74First 60 sessions1.01Rolling 60,lowest0.07Rolling 60,highest1.67Kalman, lowest0.55Kalman, highest1.85
The rolling fit is refitted every session on the last sixty. The Kalman filter uses q of one hundredth with the log of Nifty standardised, as set out above. The ratio is in log terms, which is close to a ratio of values. Same closes, same dates, 25 Sep 2025 to 15 Sep 2026. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read one more paragraph, 114 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 did not stay in a narrow band. Its ratio went as low as 0.55 on 1 Jul 2026 and as high as 1.85 on 8 May 2026, and in one stretch of twenty one sessions it moved by 1.04. I expected a smoother line than that. The reason is the regression itself. The two indices share most of their weight, so their logs rise and fall together, and the slope is decided by small differences between two large moves. A filter that follows the slope follows those differences.

One update by hand, on three dated sessions

For the hand work I use the returns version, which is the one that sizes a hedge. The observation y is the Bank Nifty's percentage move in a session, x is the Nifty's, and the single hidden state is the ratio. The inputs are model inputs, set near the values of a fit on the first sixty sessions: a ratio of 0.95, a doubt about it of 0.005, noise in a session's Bank Nifty move of 0.08 in squared percent, and a step variance of 0.003 a day. The moves are from the dated closes of 28 Aug to 2 Sep 2026.

SessionNifty move, %Bank Nifty move, %Forecast, %Innovation, %GainRatio after
31 Aug 2026−0.3940.919−0.3741.294−0.0390.900
1 Sep 2026−0.102−1.060−0.092−0.969−0.0140.913
2 Sep 2026−0.588−0.414−0.5370.123−0.0960.901
Read 2 more paragraphs, 210 words

Walk the first row. The doubt grows from 0.005 to 0.008 with the day's step. The forecast for Bank Nifty is the ratio times the Nifty move, −0.374. Bank Nifty actually rose 0.919 while Nifty fell, so the innovation is 1.294. Its variance Q is the Nifty move squared times the doubt, plus the noise, which is 0.0812. The gain is the doubt times the Nifty move over Q, −0.039, and the ratio moves by the gain times the innovation to 0.900.

Look at the size of that move. The innovation is about 4.6 noise standard deviations, a day I would circle on a chart, and the ratio shifts by only 0.05. The reason is the gain. The Nifty barely moved, so the day says almost nothing about the slope, and the filter correctly refuses to read much into it. The second session is a small correction, and on the third, with a larger Nifty move, the gain is larger and the innovation is small, so the ratio hardly changes. Three sessions took the ratio from 0.95 to 0.901. The doubt about it rose from 0.005 to 0.0131, because each day adds a step and the updates took back less than that.

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

Lag one autocorrelation of the Kalman innovations of Bank Nifty on Nifty for six settings of q from 25 Sep 2025 to 15 Sep 2026: 0.95, 0.94, 0.88, 0.69, 0.30, -0.01, falling as the ratio is allowed to move moreq 0.00001 0.95; q 0.0001 0.94; q 0.001 0.88; q 0.01 0.69; q 0.1 0.30; q 1 −0.01.Lag one autocorrelation: near 1 wanders, near0 is noiseq 0.000010.95q 0.00010.94q 0.0010.88q 0.010.69q 0.10.30q 1-0.01
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. 25 Sep 2025 to 15 Sep 2026. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read 2 more paragraphs, 166 words

This is the trap in one picture. Across the six settings the leftover goes from a spread that barely forgets to one with no memory at all. Nothing about the Nifty and Bank Nifty changed. Only the dial did. A lower bar is not a better spread.

The standardised innovations say more. If the filter described the data, they would have a standard deviation of one. At q of 0.0001 they come close, at 1.00, and they are almost as persistent as the raw leftover, with an autocorrelation of 0.94. At q of 0.01 their standard deviation is 0.43, and at q of one it is 0.10: the filter claims an error bar ten times wider than the one it actually makes, because the free ratio has already swallowed the surprise. Whiteness and unit variance never arrive together, and a model that fits would deliver both. I read that as the random walk ratio being a convenient description and not the truth.

Tuning q on one stretch

So how do I pick a q without peeking? Score each setting by the likelihood of its forecasts on the tuning stretch, 25 Sep 2025 to 4 Feb 2026, ninety sessions.

On the tuning sessions, a q of one hundredth scores highest

Log likelihood of the forecasts on the 90 tuning sessions for six settings of q, relative to the highest: -36, -30, -13, 0, -18, -76, with the peak at q of 0.01q 0.00001 −36; q 0.0001 −30; q 0.001 −14; q 0.01 (highest) 0; q 0.1 −18; q 1 −77.Log likelihood less the best setting; 0 is thebestq 0.00001-36q 0.0001-30q 0.001-13q 0.01 (highest)0q 0.1-18q 1-76
Sum of the log density of each day's forecast, minus the best setting, over the ninety sessions from 25 Sep 2025 to 4 Feb 2026. The filter had seen only the earlier closes at each step. A difference of ten or more is large. Source: NSE end of day data, computed by RupeeCase. As of 4 Feb 2026.
Read one more paragraph, 89 words

The score peaks at q of 0.01. It falls by 13 one step below and by 18 one step above. That is a sharp preference, and it is the setting I carry to the judging stretch without looking at it. Two cautions. The peak is the best of six on a short stretch, and I have not tested it on any other. And a high likelihood tells me which q forecasts the next close best, which is not the same as which q finds a spread that pays.

The test that decides

So I ran the trade as a test on the later 150 sessions, from 5 Feb to 15 Sep 2026, with nothing from them used before. The rule is fixed and simple. At each close the leftover is the day's innovation. I divide it by its standard deviation over the last twenty sessions. The position is minus that number over two, held between minus one and plus one, so a large positive leftover means short the Bank Nifty against the Nifty, a large negative one means long. The hedge is that day's ratio. The profit is the next day's change in the spread, the Bank Nifty's log move less the ratio times the Nifty's. The same rule ran for each setting, and for the frozen first sixty session ratio and the rolling sixty session ratio for comparison. Charges are the statutory ones on the futures legs, set out below.

After statutory charges no setting of the dial left a result apart from zero

Mean daily return in basis points of a spread reversion rule on Bank Nifty and Nifty after statutory charges, 149 days from 5 Feb 2026: q 0.00001 1.34, q 0.0001 0.21, q 0.001 -0.51, q 0.01 (tuned) -0.06, q 0.1 0.01, q 1 0.28, Frozen first 60 -1.36, Rolling 60 -0.40q 0.00001 1.34; q 0.0001 0.21; q 0.001 −0.51; q 0.01 (tuned) −0.06; q 0.1 0.01; q 1 0.28; Frozen first 60 −1.36; Rolling 60 −0.40.Mean daily return, basis points, afterstatutory chargesq 0.000011.34q 0.00010.21q 0.001-0.51q 0.01 (tuned)-0.06q 0.10.01q 10.28Frozen first 60-1.36Rolling 60-0.40
Index closes standing in for the futures, a position limit of one unit, the hedge ratio of the day, and the next day's change in the spread, for 149 trading days from 5 Feb 2026. Charges are STT, the exchange transaction charge, the SEBI fee, GST on those two and stamp duty on the buy leg, by date. Brokerage is left out. Not a recommendation. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read 2 more paragraphs, 178 words

Before charges the means run from about 0.78 to 3.06 basis points a day, the largest at q of one. The t statistic of that largest mean is 1.41, short of two. After charges every setting is within 1.4 basis points of zero. At q of 0.01, the setting the likelihood chose, the mean is 1.82 basis points before charges, a t of 0.76, and −0.07 after. The frozen ratio and the rolling one do about as well. The filter did not find a trade in this pair. It found a way to describe the pair more smoothly, and I would not tune q until a bar turned positive.

In rupees: one Bank Nifty lot was worth Rs 16,56,012 at the future of 10 Jun 2026, so 1.82 basis points before charges is Rs 301 a day on one lot, and the statutory charges at q of 0.01 took 1.89 basis points, Rs 313 a day. A freer ratio trades more, so the charges grow with q while the gross result does not keep pace.

The same rule with a smoothed ratio

There is a way to make this rule look wonderful, and it is worth seeing once. The filter has a second form, the smoother, which re-estimates yesterday's ratio using the closes that came after it. The Rauch, Tung and Striebel smoother does it with one backward pass. The smoothed ratio describes what the relationship was. A trader could not have held it, because at each date it uses closes that had not happened. Run the same rule with the smoothed leftover and the result changes:

Smoothing with future closes turns a null result into a t of six

t statistic of the mean daily return of the same rule using the filtered or the smoothed leftover: Filter, q 0.001 0.26, Smoothed, q 0.001 3.82, Filter, q 0.01 0.76, Smoothed, q 0.01 6.28, Filter, q 0.1 1.07, Smoothed, q 0.1 7.33, Filter, q 1 1.41, Smoothed, q 1 7.55Filter, q 0.001 0.26; Smoothed, q 0.001 3.82; Filter, q 0.01 0.76; Smoothed, q 0.01 6.28; Filter, q 0.1 1.07; Smoothed, q 0.1 7.33; Filter, q 1 1.41; Smoothed, q 1 7.55.t statistic of the mean daily return, beforechargesFilter, q 0.0010.26Smoothed, q 0.0013.82Filter, q 0.010.76Smoothed, q 0.016.28Filter, q 0.11.07Smoothed, q 0.17.33Filter, q 11.41Smoothed, q 17.55
The same rule, the same 149 days from 5 Feb 2026, for q of one hundredth. The only difference is that the leftover at each date comes from the smoothed state, which has seen the closes up to 15 Sep 2026, and not from the filter, which had seen only the closes to that date. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read one more paragraph, 93 words

At q of 0.01 the filtered rule has a t of 0.76. The smoothed rule has a t of 6.28 and a mean of 13.43 basis points a day, which would be Rs 2,224 a day on one Bank Nifty lot. Same data, same rule. Nothing in the pair changed. The ratio at each date simply knew the future. Any filtered spread in a backtest has to be the filter, not the smoother, and a published chart of a hedge ratio with no word on which one it is deserves a question.

What the hedger gets

The test above asks whether the spread pays. A hedger asks something smaller: how much does a Bank Nifty position still move after the Nifty future is sold against it? That needs the returns ratio. For each approach I took the ratio known the evening before, applied it to the next day's Nifty move and measured what was left, over the same judging stretch.

A good filter and a good rolling fit hedge about equally well

Daily standard deviation in basis points of a Bank Nifty position hedged with Nifty, by method, over 149 sessions from 5 Feb 2026: Unhedged 126.7, Frozen first 60 56.3, Rolling 60 52.6, Filter q 0.001 51.2, Filter q 0.01 51.6, Filter q 0.1 54.1, Filter q 1 66.7, Hindsight ratio 50.8Unhedged 126.7; Frozen first 60 56.3; Rolling 60 52.6; Filter q 0.001 51.2; Filter q 0.01 51.6; Filter q 0.1 54.1; Filter q 1 66.7; Hindsight ratio 50.8.Daily standard deviation of the unhedgedremainder, basis pointsUnhedged126.7Frozen first 6056.3Rolling 6052.6Filter q 0.00151.2Filter q 0.0151.6Filter q 0.154.1Filter q 166.7Hindsight ratio50.8
Daily Bank Nifty return less the ratio known the evening before times the Nifty return, 149 sessions from 5 Feb 2026. The filter here is the returns version with its q scaled by the variance of the Nifty return. The last bar uses the one ratio that was best over these very sessions, which no one could have known. Source: NSE end of day data, computed by RupeeCase. As of 15 Sep 2026.
Read one more paragraph, 148 words

An unhedged Bank Nifty position moved 126.7 basis points a day. A frozen first sixty session ratio left 56.3. A sixty session rolling fit left 52.6. The filter left 51.2 at its best setting, which is within a hair of the 50.8 that the hindsight ratio would have left. At the largest q it left 66.7, worse than not adapting at all, because the ratio chases noise. On a Bank Nifty book of Rs 8.28 crore, the gap between the frozen ratio and the best filter is Rs 41,885 in one standard deviation of the daily remainder. That is real money for a large book, and small beside what a hedge removes: the filter's remainder is 16% of the variance of the unhedged position. Most of the value is in hedging at all. The choice among sensible ratios moves the remainder by about a tenth.

A break the filter would absorb

Model, not market data. Suppose the true ratio jumps by 0.4 one day and stays there, as it might after an index reconstitution, with no other noise. The filter closes the gap by a fixed share each day, so after n sessions the gap left is the jump times one minus K to the power n. A rolling window closes it in a straight line over its length.

A q of one hundredth takes about a month to notice a new ratio

Model, not market data. Sessions needed to absorb 90 percent of a one off jump in the true hedge ratio: 73 at q of 0.001, 23 at 0.01 and 7 at 0.1 for the filter, and 54 for a sixty session rolling fitFilter q 0.001 73; Filter q 0.01 23; Filter q 0.1 7; Rolling 60 54.Sessions to absorb nine tenths of a jump inthe true ratioFilter q 0.00173Filter q 0.0123Filter q 0.17Rolling 6054
Model, not market data. Inputs: a single drifting ratio, no other noise, steady state gain from q, a rolling window of sixty sessions that fills in a straight line. The frozen ratio never absorbs it. Source: RupeeCase calculation, scalar filter and rolling window. As of 31 Oct 2026.
Read one more paragraph, 92 words

While it is absorbing, the spread looks normal, and the hedge is wrong by the gap that remains. Take a one lot Nifty hedge and a Nifty move of one percent. With a gap of 0.4 in the ratio, the hedge is off by 6,042 rupees on that day, and it stays off by a shrinking share for the weeks the filter takes. A frozen ratio would have been wrong by the full amount from day one, and would at least have shown the break as a spread that never came back.

What a changing ratio means in lots

The ratio moves by fractions, 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. SEBI's circular of 1 Oct 2024 asks for an index derivative contract value of Rs 15 lakh to Rs 20 lakh on the day of review, for new contracts after 20 Nov 2024, and both lots sit in that band. The returns ratio of the filter at its better setting ranged from 0.86 to 1.40, and in its sharpest month it moved by 0.50. For a book of 50 Bank Nifty lots that is about 27 Nifty lots to trade, worth Rs 4.14 crore. If they are sales, STT at 0.05% is Rs 20,700 for the month's rebalance, before exchange charges and the spread. On a one lot book the same move is half a lot, which cannot be traded, and a book of five lots can change its hedge only in steps of 0.18. At small size the ratio is a number on a chart, not a position.

Where this meets India

The legs are index futures. NSE's contract specifications page, updated on 11 Aug 2026, lists three consecutive monthly expiries for the Nifty 50 and Nifty Bank futures. Monthly expiry is the last Tuesday of the month: NSE's circular NSE/FAOP/68747 of 25 Jun 2025 applied it to contracts expiring on or after 1 Sep 2025, following SEBI's circular SEBI/HO/MRD/MRD-TPD-1/P/CIR/2025/76 of 26 May 2025, which limits expiry to Tuesday or Thursday and puts monthly futures in the last week of the month (clause 3.1 and clause 3.3). Both legs of this pair roll on the same day. The tick differs: NSE's circular NSE/FAOP/67135 of 13 Mar 2025 ties the tick of an index future to the index level, reviewed monthly, at Rs 0.10 for an index above 15,000 and up to 30,000 and Rs 0.20 above that. Nifty sat in the first band and Bank Nifty in the second.

Glowing teal and blue bars rising left to right over a glass floor, like a year of monthly returns
Read one more paragraph, 157 words

From 7 Dec 2026, SEBI's circular HO/47/11/11(3)2025-MRD-POD2/I/23843/2026 of 15 Oct 2026 ends trading in expiring index contracts at 3:30 pm and settles them at the volume weighted prices of the last thirty minutes of the cash session (paragraph 4.2.4 and paragraph 4.9.1). A filter that updates on closes has to be told which close: the index close, the last traded price of the future and the settlement price can all differ on an expiry day, and a ratio fitted on one and applied to another leaks. Rebalancing costs are in the cost of an F&O trade: from 1 Apr 2026 STT on the sale of a future is 0.05% (NSE/FATAX/73524 of 31 Mar 2026), and the exchange transaction charge was revised from 1 Mar 2026 (NSE/FA/73061 of 27 Feb 2026). On two stock futures the filter adds delivery on the last day, the ban list and the lot mismatch of the stock futures pair lesson.

What the research says

Kalman published the recursion in 1960 for filtering and predicting a signal seen through noise. In finance the first question was whether a stock's market beta is constant. Bos and Newbold (1984) asked whether the slope of the market model follows a random process, which is the choice made here. Faff, Hillier and Hillier (2000) compared three ways of modelling a time varying beta on daily UK industry returns and found that a Kalman filter with a random walk beta had the lowest mean square error of the three. For India, Das and Barai (2015) estimated industry betas with a regression, the Kalman filter and other approaches, found a dynamic beta, and reported the lower forecasting error for the filter in almost all industries.

Read one more paragraph, 147 words

For pairs, Elliott, Van der Hoek and Malcolm (2005) put the spread itself into state space form, with a mean reverting hidden state seen through noise, which is a different use of the filter from the hidden hedge ratio here. Krauss (2017) surveys the pairs literature in five groups and reviews profitability in light of market frictions. On method, Shumway and Stoffer (1982) set out the EM route to the variances, Mehra (1970) the older problem of identifying them, Rauch, Tung and Striebel (1965) the smoother, and Ljung and Box (1978) the test of whether innovations are white. None of these shows that a filtered hedge ratio makes money in index futures. They show that betas move and that a random walk state tracks them; the choices around it are where the results come from.

Stretch: what to build next

Three extensions follow. Give the state a pull back to a mean, as in the pairs paper above, so the spread is the hidden thing. Estimate Ve and Vw by EM and compare with the likelihood grid. Add a second regressor, such as a sector index. Whatever you build, walk forward testing and backtest overfitting apply to it, and PCA statistical arbitrage carries the idea to a basket. The noise in a daily close is the subject of microstructure models, and the cost of trading the lots is in optimal execution.

The RupeeCase terminal on sample data: Net return and charges: what do estimated costs take?
Watch in the terminal: what do estimated costs take? A short tutorial on sample data.

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 white noise, while the result of trading it stayed within noise before charges and at zero after them. Before trusting a filtered spread, ask how q was chosen, on which days, what the same rule earns with a fixed ratio, which form of the filter was used, and whether the hedge moves by whole lots.

  • Picking q after the results. Of seven settings the highest mean before charges was q of one: 3.06 basis points a day, Rs 506 on one Bank Nifty lot, with a t of 1.41. Chosen after looking, it is a selection and not a finding. After charges it is 0.28 basis points, Rs 46.
  • Backtesting with the smoothed ratio. At q of 0.01 that gave Rs 2,224 a day on one lot and a t of 6.28. The honest filter gave Rs 301 and a t of 0.76. The whole difference is information from the future.
  • Reading a calm leftover as a reverting spread. The lag one autocorrelation fell from 0.95 to −0.01 as q rose, with the same indices on the same days. A calmer series is the filter absorbing more.
  • Hedging in fractions. A monthly ratio move of 0.50 on 50 Bank Nifty lots is 27 Nifty lots and Rs 20,700 of STT on the sales. On one lot it is half a lot, which cannot be traded.
  • Trusting it to flag a break. At q of 0.01 the filter takes about 23 sessions to absorb nine tenths of a jump in the true ratio, and the spread looks normal on the way. On a one lot Nifty hedge, a one percent day with the ratio off by 0.4 costs Rs 6,042.

Two terms to hold on to from 18.14

Two terms to hold on to from 18.14Two terms to hold on to from 18.14. Kalman filter: A recursion that tracks a hidden quantity, here the hedge ratio, by predicting it and then correcting it with each new observation. Innovation: The actual value less the value forecast from the prediction: the day's surprise. The filter updates the state from it.Kalman filterA recursion that tracks a hidden quantity,here the hedge ratio, by predicting it andthen correcting it with each new observation.InnovationThe actual value less the value forecast fromthe prediction: the day's surprise. The filterupdates the state from it.
From the module glossary. Source: Module 18.14, Kalman filter hedge ratios.

What I'd keep from this

  • The filter lets the hedge ratio drift and updates it from each surprise.
  • One dial, q, sets how freely the ratio moves, given the regressor scale.
  • A freer ratio makes the leftover look more mean reverting, partly by construction.
  • Tune q on one stretch and judge on the next; never use the smoothed ratio.
  • After statutory charges no setting of q earned more than noise on this pair.
  • A ratio that moves by fractions of a lot cannot be followed at small size.

Where this section sits in module 18.14

Where this section sits in module 18.14Where this section sits in module 18.14. 1. The idea, plainly 2. Worked example: Bank Nifty on Nifty, a year of closes 3. The common mistake 4. What I'd keep from this01The idea, plainly02Worked example: Bank Nifty onNifty, a year of closes03The common mistake04What I'd keep from this
Sections 1 to 4 of 4; the highlighted one is next. 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