Analysis
HDFC Bank vs ICICI Bank — Correlation, Lead-Lag & Pairs Trading
hdfc-icici-pairs-trading-analysis
Correlation (Pearson and Spearman) and its stability over time across 5/20/60/120-day rolling windows.
Lead-lag relationship via both a cross-correlation scan and a proper statsmodels Granger causality F-test; cointegration testing via Engle-Granger and an ADF test on the OLS spread.
Hedge ratio and live spread z-score as an illustrative pairs-trading signal, plus co-movement of large (>3%) single-day moves.
Fixed in review
- A SyntaxError from nested same-type quotes in an f-string.
- An overstated "Granger Causality" label on what was actually a plain lag-correlation scan — the scan was kept but clearly labeled a heuristic, and a real Granger F-test was added in both directions.
- A statsmodels cross-version incompatibility around the verbose kwarg.
- A hardcoded end date.
- Simplified fragile lead-lag and rolling-beta computations that had dtype and index-alignment bugs.
CointegrationGranger causalityPairs tradingstatsmodels