Markets: A Rigorous Course

15.10 Playbook 10: a pairs trade the tests reject (HDFC Bank and ICICI Bank, July 2026)

Core about 40 min

15.10.1Prerequisites and what this playbook teaches#

Read first (essential, enough to follow the lesson) M13A · 13A.1 (the ladder of ties), 13A.3 (spurious regression), 13A.7 (the Ornstein–Uhlenbeck spread and its half-life), 13A.11 (Indian frictions), 13A.12.1 and 13A.13.2 (this pair, and the merger that broke it), M03 · 3.1.1 (how many trades detect an edge) and 3.9 (position size), M01 · 1.7–1.8 (costs and tax).

For depth (needed to run the tests yourself): M13A · 13A.2, 13A.4–13A.6 and 13A.8–13A.10 (unit roots, Engle–Granger and Johansen, optimal bands, the Kalman hedge ratio, break tests) and M14 · 14.17 (short selling and stock lending). The practitioner track reads this playbook for its lesson, that a pair which fails its pre-stated tests is not traded however wide the spread looks; the full and core tracks read it after all of M13A.

What it teaches A pairs trade bets that the gap between two weighted prices returns to its average; it is only as good as the evidence that such an average exists. The playbook runs that evidence first, on a candidate list declared in advance, and finds no tradeable pair. It then follows day by day the trade a trader who skipped the tests would have taken in HDFC Bank and ICICI Bank on 1 Jul 2026, with real prices and lot sizes from the NSE bhavcopy. That trade loses 1.58R after costs, and the plan would have refused it even at the sizing step.

This is an educational reconstruction from public data. It is not a recommendation to buy or sell any security, and the trade it follows is one the stated plan forbids.

15.10.2The setup as testable rules#

Universe, declared before the scan Thirteen stocks with NSE stock futures, in three sectors: five private banks (HDFC Bank, ICICI Bank, Kotak Mahindra Bank, Axis Bank, IndusInd Bank), five IT services firms (TCS, Infosys, HCLTech, Wipro, Tech Mahindra) and three oil marketing companies (BPCL, HPCL, IOC). Pairs are formed only within a sector: 10+10+3=2310 + 10 + 3 = 23 pairs.

Formation At each quarter end, take the last 504 trading days (about two years) of log closes adjusted for dividends, splits and bonuses. For a pair (y,x)(y, x) fit ln⁡Pty=a+bln⁡Ptx+ut\ln P^y_t = a + b\ln P^x_t + u_t by OLS. The spread is st=ln⁡Pty−a−bln⁡Ptxs_t = \ln P^y_t - a - b\ln P^x_t and its standardised value is zt=(st−μ)/σz_t = (s_t - \mu)/\sigma, with μ,σ\mu, \sigma the formation-window mean and standard deviation of the residual.

Tests. A pair is tradeable only if it passes all six

  1. Engle–Granger (M13A · 13A.5): augmented Dickey–Fuller regression on the residual, lags by AIC, MacKinnon pp-values from the Engle–Granger (not Dickey–Fuller) distribution, run in both orderings. Pass if the larger pp is below 0.05/23=0.002170.05/23 = 0.00217. The Bonferroni division by 23 is the multiple-testing correction of M04 and M03 · 3.1.1: testing 23 pairs and keeping the best is a selection procedure.
  2. Johansen trace for rank 0 (M13A · 13A.6) above its 5% critical value, 15.49.
  3. Positive hedge ratio, b>0b > 0. A negative bb means "long both", which is not a hedge.
  4. Breaks (M13A · 13A.10): sup-F over break dates in the middle 70% of the window below 11.79 (Andrews' 5% value for two parameters, 15% trimming), and the OLS-residual CUSUM test with p>0.05p > 0.05.
  5. Kalman check (M13A · 13A.9): a random-walk Kalman filter for (at,bt)(a_t, b_t), signal-to-noise ratio chosen by likelihood on the formation window. Pass if the filtered slope at the formation end lies within three of its own standard deviations of the OLS bb.
  6. Half-life (M13A · 13A.7): AR(1) coefficient ϕ^\hat\phi of the residual, half-life ln⁡2/(−ln⁡ϕ^)\ln 2/(-\ln\hat\phi) no longer than 60 trading days.

Trade rules (next quarter, out of sample)

  • Entry on a close with ∣z∣≥2|z| \ge 2. If z≤−2z \le -2, yy is cheap: buy yy for delivery and sell xx futures ("long the spread"). If z≥2z \ge 2, the reverse. The long leg is always cash and the short leg is always the near-month stock future, because an individual cannot carry a cash short overnight except through stock lending (M14 · 14.17).
  • Weights. Because the spread is in logs, a small move gives Δs≈ry−b rx\Delta s \approx r^y - b\,r^x, so the position holds ₹bb of xx per ₹1 of yy.
  • Target: zz crosses 0. Stop: ∣z∣≥∣zentry∣+1|z| \ge |z_{\text{entry}}| + 1 on a close, so the planned loss is one formation σ\sigma. Time stop: three half-lives. Forced exit at the next quarter end, when the pair is re-formed.
  • Size: 1R is one σ\sigma of spread on the yy notional, 1R=Nyσ1R = N^y\sigma. Apply (3.23) with f=1%f = 1\% of ₹10,00,000, rounding the futures leg down to whole lots. Zero lots means no trade.
  • Reconstruction convention: fills at closing prices (spot close for the cash leg, futures close for the short leg). A real trader acts in the closing session or at the next open.

15.10.3The scan and the episode#

Data Daily adjusted closes from Yahoo Finance (fetched 6 Nov 2026) for the 13 stocks; NSE F&O UDiFF bhavcopies for every trading day from 30 Jun to 21 Jul 2026 and for 5 Nov 2026 (futures closes, underlying closes and lot sizes). ICICI Bank's adjusted and raw series differ by a constant factor through the trade window and HDFC Bank's not at all, so no corporate action falls inside it.

The named pair first HDFC Bank on ICICI Bank, formation 18 Jun 2024 to 30 Jun 2026 (504 days):

Statistic Value Test
OLS bb (s.e.) 1.1143 (0.0368) b>0b>0: pass
R2R^2 / Durbin–Watson 0.647 / 0.052 R2≫R^2 \gg DW: spurious-regression warning (M13A · 13A.3)
EG, HDFC on ICICI −2.19-2.19, p=0.432p = 0.432 fail
EG, ICICI on HDFC −3.12-3.12, p=0.084p = 0.084 fail
Johansen trace r=0r = 0 13.30 (cv 15.49) fail
sup-F 413.8, at 4 Mar 2026 (cv 11.79) fail
CUSUM pp below 0.001 fail
Kalman slope at 30 Jun (s.d.) 0.628 (0.048), against OLS 1.114 fail
AR(1) ϕ^\hat\phi (s.e.), half-life 0.9778 (0.0102), 30.9 days, 95% interval 16 to 309 days pass on the point estimate only

The split windows show the trap. In the first half of the window (Jun 2024 to Jun 2025) the EG test rejects strongly (p=0.0008p = 0.0008, b=0.886b = 0.886); in the second half it does not (p=0.48p = 0.48, b=1.840b = 1.840). A trader who looked at the pair in mid-2025 saw a textbook pair; the relationship then moved, with the largest break in March 2026. This is the pattern of M13A · 13A.12.1 (no convincing cointegration in any long sample) and 13A.13.2 (a level relationship that drifted after the HDFC merger).

The full scan at 30 Jun 2026 No pair passes test 1. The five lowest larger-ordering pp-values were TCS/Infosys 0.068, ICICI/Kotak 0.082, ICICI/IndusInd 0.087 (with b<0b < 0), HCLTech/Wipro 0.103 and Infosys/Wipro 0.128. HDFC/ICICI ranked twelfth at 0.432. Five pairs reject at 5% in at least one ordering. That is not much more than chance: 46 tests at 5% give 2.3 false rejections on average if they are independent, and these tests share stocks and sector factors, so their count scatters more widely. The scans at the four previous quarter ends (30 Jun 2025 to 31 Mar 2026) and at the next one (30 Sep 2026) also produced zero passes.

The top-ranked pair fails the other tests too: TCS on Infosys has sup-F 417.6 (break dated 11 Jun 2025), CUSUM p<0.001p < 0.001, and a Kalman slope of 0.706 against an OLS slope of 1.218. Even under a relaxed rule its zz never reached ±2\pm 2 in the third quarter (largest 1.79, on 24 Jul).

Decision under the plan: no trade The book stays flat for the quarter. The rest of this playbook follows the trade a trader without the tests would have taken, because that trade is the common one and it shows what the tests protect against.

15.10.4The plan before entry#

On the close of 1 Jul 2026 the HDFC/ICICI spread stood at z=−2.655z = -2.655: HDFC Bank cheap relative to ICICI Bank by 2.65 formation standard deviations. The plan such a trader writes:

  • Thesis. The spread mean-reverts with a half-life of about 31 trading days; HDFC Bank will outperform ICICI Bank by about 2.65σ=14.2%2.65\sigma = 14.2\% in log terms.
  • Trigger. Close of 1 Jul, z=−2.655z = -2.655.
  • Legs. Buy HDFC Bank for delivery at ₹796.15. Sell 1 lot of ICICI Bank July futures (expiry 28 Jul 2026; lot 700 in the 1 Jul bhavcopy) at ₹1,386.90. One lot is ₹9,70,830 of ICICI Bank, so the HDFC leg is 9,70,830/1.11439{,}70{,}830/1.1143, which is ₹8,71,239, or 1,094 shares (₹8,70,988).
  • Stop z≤−3.655z \le -3.655. Target z≥0z \ge 0. Time stop ⌈3×30.9⌉=93\lceil 3 \times 30.9\rceil = 93 trading days, which runs past the July expiry, so the short leg would be rolled into August futures before 28 Jul at the cost of a second futures round trip.
  • Invalidation. Either bank's quarterly results, a corporate action, or the Kalman ratio moving further from the OLS ratio.
  • Size. 1R=Nyσ=8,70,988×0.05356=₹46,6501R = N^y\sigma = 8{,}70{,}988 \times 0.05356 = \text{₹}46{,}650, which is 4.67% of the account. Rule (3.23) at 1% gives ⌊10,000/46,650⌋=0\lfloor 10{,}000/46{,}650 \rfloor = 0 lots. A 1% position would be ₹1,86,707 of HDFC Bank (234 shares) against ₹2,08,047 of ICICI Bank, 0.214 of a lot. Trading one lot at 1% risk needs an account of ₹46.65 lakh.
  • Capital. The cash leg takes ₹8.71 lakh. The futures margin is not in the bhavcopy; at an assumed 20% of notional it is about ₹1.94 lakh, for a total of ₹10.65 lakh, more than the account. Funding it means pledging the HDFC Bank shares as collateral (M14 · 14.16).
  • The hedge ratio itself. The Kalman slope on 30 Jun was 0.628, not 1.114. On that ratio the HDFC leg against one ICICI lot would be ₹15.47 lakh. Two estimators of the same quantity disagree by a factor of 1.8.
  • Costs (M01 · 1.7: statutory and exchange charges as of 6 Nov 2026, STT as amended from 1 Apr 2026; brokerage as an illustrative parameter of ₹0 for delivery and ₹20 per futures order). At unchanged prices the delivery round trip costs ₹1,953 (₹1,742 of it STT at 0.1% each side) and the futures round trip ₹596 (₹485 of it STT at 0.05% on the sell leg, which is the opening leg of a short). That is ₹2,549 in all, 0.055R.
  • Expected R and break-even. If the target is reached the gross gain is +2.655R+2.655R; the stop costs −1R-1R. The break-even win rate, ignoring costs, is 1/(1+2.655)=27.4%1/(1 + 2.655) = 27.4\%. That looks generous until 15.10.7 shows how rarely the target is reached.

A plan-following trader stops at the size line, with four separate reasons to stand aside: the tests, size, capital and the hedge ratio. The log follows the trade at one lot, with R measured against the one-lot risk of ₹46,650.

15.10.5Day-by-day management#

Closing prices; HDFC Bank from the bhavcopy's underlying close, ICICI Bank from the July futures close. Open P&L is long 1,094 HDFC Bank and short 700 ICICI Bank futures, before costs.

Date (2026) zz HDFC Bank (₹) ICICI Bank Jul fut (₹) Open P&L (₹) Open R Action / note
1 Jul −2.655 796.15 1,386.90 0 0.00 Enter both legs at the close. Stop z=−3.655z = -3.655.
2 Jul −2.963 795.95 1,404.30 −12,399 −0.27 Hold.
3 Jul −3.011 801.05 1,415.20 −14,449 −0.31 Hold. Spread wider than at entry.
6 Jul −2.579 829.85 1,430.00 +6,698 +0.14 HDFC Bank +3.6% on the day.
7 Jul −2.413 829.30 1,417.30 +14,986 +0.32 Hold.
8 Jul −2.338 810.30 1,386.40 +15,830 +0.34 Both legs fall together; spread steady.
9 Jul −2.173 817.60 1,386.70 +23,606 +0.51 Best point of the trade; zz still far from 0.
10 Jul −2.312 824.95 1,404.30 +19,327 +0.41 Hold.
13 Jul −2.594 817.95 1,412.40 +5,999 +0.13 Hold.
14 Jul −2.763 809.40 1,408.60 −695 −0.01 Hold.
15 Jul −2.749 815.45 1,417.10 −26 0.00 Hold.
16 Jul −2.943 808.30 1,423.00 −11,978 −0.26 Hold.
17 Jul −3.063 819.60 1,449.10 −17,886 −0.38 ICICI Bank futures +1.8%; spread 0.59σ from the stop.
20 Jul −4.273 777.60 1,459.80 −71,324 −1.53 HDFC Bank −5.1%, ICICI Bank +1.1%. Stop breached on the close: exit both legs.

On 20 Jul the spread moved 1.21σ in one session, from inside the stop to well beyond it, so the loss was 1.53R rather than 1R; a close-based stop cannot prevent a move between two closes. We have not verified what caused HDFC Bank's fall that Monday. Whatever it was, a pair does not diversify single-stock events: it is long one bank's idiosyncratic risk and short the other's. Waiting for the 21 Jul close would have cost more: z=−4.71z = -4.71, open P&L −₹91,722 (−1.97R).

15.10.6Exit and result#

Exit, 20 Jul 2026 at the close: sell 1,094 HDFC Bank at ₹777.60; buy back 700 ICICI Bank July futures at ₹1,459.80.

Item ₹
HDFC Bank leg, 1,094×(777.60−796.15)1{,}094 \times (777.60 - 796.15) −20,293.70
ICICI Bank futures leg, −700×(1,459.80−1,386.90)-700 \times (1{,}459.80 - 1{,}386.90) −51,030.00
Gross −71,323.70
Delivery charges (STT 1,721.68; exchange 52.86; SEBI 1.72; stamp 130.65; GST 9.82; DP 15.34) −1,932.07
Futures charges (brokerage 40; STT 485.42; exchange 36.47; SEBI 1.99; stamp 20.44; GST 14.12) −598.43
Net, before tax −73,854.21

That is −1.583R against the one-lot risk, and 7.4% of the ₹10 lakh account. At the plan's 1% risk the same trade would have cost about 1.6% of the account; the oversizing multiplied a 1.58R loss into a 7.4% drawdown.

Tax (M01 · 1.8 and M00 · 0.7, rules for tax year 2026-27; assumes a 30% slab and that the losses can be used in the year). The two legs fall under different heads, and that is a real cost of the cash-plus-futures structure.

  • The futures leg is non-speculative business income. Its loss including its charges, ₹51,628.43, can be set off against other income except salary; at 30% it is worth ₹15,488.53 of tax.
  • The delivery leg is a short-term capital loss of ₹20,293.70 (STT is not deductible against capital gains). It can be set off only against capital gains. Against short-term gains taxed at 20% it is worth ₹4,058.74.
  • After tax, if both losses are fully used: −₹54,306.94, or −1.16R.

The mismatch cuts harder in the other direction. If a pair trade makes ₹50,000 on the futures leg and loses ₹50,000 on the cash leg, the economic result is zero, but the futures gain is taxed at the slab rate, while the capital loss waits for a capital gain to offset it. Before trading pairs this way, ask a chartered accountant how your own income would treat the two heads.

The counterfactual without the stop Held to 6 Nov 2026 at spot prices (ignoring the cost of rolling the futures), the trade would have been down ₹1,42,623, −3.06R, with z=−5.72z = -5.72; the low was z=−6.08z = -6.08 on 31 Aug. The spread never returned within 2σ of the formation mean after 1 Jul. The stop was the one part of the plan that worked.

15.10.7Post-mortem#

Process Four decisions, each visible before entry, produced the loss: trading a pair that failed four of six tests, risking 4.67% instead of 1%, using more capital than the account had, and ignoring a Kalman ratio that said the hedge had changed. The jump through the stop was bad luck in timing, not in kind (M03 · 3.9 on gap risk).

Base rates To judge the rule rather than the trade, the same rules were run at every quarter end from 30 Jun 2012 to 30 Jun 2026 on all 23 pairs (57 formations; quarter-end forced exit; R net of a cost of 0.24% of the cash-leg notional and 0.06% of the futures-leg notional, converted to R through each formation's σ\sigma):

Trades taken from NN Win rate Mean R (net) s.d. R tt
All pairs with b>0b > 0, no tests 782 51.3% +0.101 1.173 2.41
EG at 5%, better ordering, unadjusted 200 51.5% +0.142 1.300 1.55
Bonferroni pass, both orderings 19 31.6% −0.283 1.110 −1.11
HDFC/ICICI only, no tests 31 48.4% 0.000 1.371 0.00

Of the 782 trades, 71 reached the target, 225 the stop, 71 the time stop, and 415 were closed at the quarter end. The worst was −3.23R; 3.3% were worse than −1.5R. Only 13 of the 721 formations that produced a trade passed the Bonferroni test.

Three readings, in order of importance.

  1. The target at z=0z = 0 is reached in 9% of trades. The +2.65R payoff in the plan is the tail, not the typical outcome, and the 27.4% break-even win rate compared the wrong quantities.
  2. The all-pairs tt-statistic of 2.41 overstates the evidence. The trades overlap in time and share stocks and sector factors, so the effective number of independent observations is much smaller than 782. The filter that is meant to select real relationships selected 19 trades that lost on average. With t=−1.11t = -1.11 that is not significant either, but it gives no support to the idea that the tests find tradeable pairs in this universe.
  3. Taking the all-pairs numbers at face value, M03 (3.2a) gives N=(2×1.173/0.101)2=539N = (2 \times 1.173/0.101)^2 = 539 trades for t=2t = 2 in expectation, and (3.2b) gives 1,089 trades for 80% power. At the backtest's rate of about 55 trades a year that is ten and twenty years. A trader cannot learn from experience whether this rule has an edge; the evidence has to come from the history, and the history is weak.

What would change the answer Relationships tied by contract or construction (M13A · 13A.1, levels 1–2): a merger with a fixed swap ratio before completion, an index against its futures or ETF, Nifty Bank against its own constituents. Same-sector Indian stocks have so far been level-4 relationships: correlated returns, untied levels.

15.10.8Do it in the simulator#

The simulator (Simulator → New order) fills end-of-day against daily bars, offers no stock futures, and does not allow an overnight short in cash equities. A two-stock pair cannot be placed in full, so the exercise is built around that limit.

  1. Scan. Re-run the six tests with formation ending 30 Sep 2026 on the same 23 pairs (the M13A pairs lab computes the EG statistic, half-life and Kalman path for any two symbols). Record the table of pass/fail results in your journal before looking at any zz-score after 30 Sep.
  2. If nothing passes, log a no-trade decision with the table attached. That is a valid outcome of the playbook.
  3. If a pair passes and signals, size it by (3.23) with the short leg in whole lots (bhavcopy lot size, dated). If the size is zero lots, log that too. Otherwise place the cash long leg in the simulator: buy, market at close, quantity from the sizing. Enter no price stop; the stop is on zz. Record the short leg's hypothetical fills from the bhavcopy futures close in the paper-trade journal, and compute pair P&L and zz by hand each day.
  4. Index-hedged variant. Instead of the second stock, hedge the long leg with BANKNIFTY or NIFTY futures, which the simulator does offer. One BANKNIFTY lot (30) on 1 Jul 2026 was 30×58,309.8=₹17.4930 \times 58{,}309.8 = \text{₹}17.49 lakh, about nine times the 1%-risk HDFC Bank leg of ₹1.87 lakh. Work out the beta-weighted hedge, what lot rounding does to it, and the residual risk: an index hedge removes the market factor but leaves the stock's own risk, the very risk that hit this trade on 20 Jul.
  5. Review. Compare the result in R with the base-rate table above. One trade cannot confirm or refute the rule; check only whether it lies inside the backtest's distribution (M14 · 14.10.3).

See it live: both legs' prices and futures OI by expiry at https://oicharts.com/stocks/HDFCBANK and https://oicharts.com/stocks/ICICIBANK .

Data lab

Replay: long HDFC Bank against short ICICI Bank futures, 1–20 Jul 2026

The chart shows only the cash leg, HDFC Bank. The trade was a pair: the short leg was one lot of ICICI Bank July futures, sold at ₹1,386.90 on 1 Jul 2026 and bought back at ₹1,459.80 on 20 Jul. The stop and target lines are the HDFC Bank prices at which the spread zz would reach the stop or the target if ICICI Bank had not moved; the real stop is on zz, so the trade can be stopped out with HDFC Bank well above the drawn stop, as it was on 17–20 Jul when ICICI Bank rose. Load ICICI Bank for the same dates alongside to see both legs.

What to look at The two legs' moves on 6 Jul, 8 Jul and 20 Jul; how often the legs moved together (a quiet spread) and how often apart; the single session that carried the spread from inside the stop to 1.21σ beyond it.

Questions

  1. On which days did the two legs move in opposite directions, and what did each such day do to the open P&L?
  2. Compute the ratio of ICICI Bank's 20-day return to HDFC Bank's at 30 Jun and at 20 Jul. Is a hedge ratio of 1.11 consistent with what you see, or the Kalman estimate of 0.63?
  3. If the stop had been checked at the next open instead of the close, would the 20 Jul exit have been better or worse? Use the 21 Jul open of each leg.

Create a free account

Reading is open to everyone. An account keeps your progress, answers, notes and code drafts, and gives you the study plan, the journals and the simulator. Running code needs an account approved for it.