Concerning the writer
Undertaking Summary
This mission builds and evaluates a market-neutral pairs buying and selling technique specializing in 25 NSE large-cap shares spanning the Banking, IT, Pharma, Cement, and Auto sectors. The pairs are chosen utilizing a residual stationarity check, particularly the ADF(0) with MacKinnon p-value, on a coaching pattern. To make sure statistical robustness and management for false discoveries, the Benjamini–Hochberg False Discovery Charge (FDR) at 5% is utilized.
The technique trades mean-reversion through z-scores of the unfold utilizing a walk-forward prepare/check break up. It represents a clear, defendable educational implementation with no look-ahead bias, specific transaction prices (5 bps per leg per facet), equal capital per lively pair (₹5,00,000), and complete portfolio-level danger metrics.
Introduction & Undertaking Motivation
Pairs buying and selling is a basic statistical arbitrage technique that seeks to take advantage of non permanent worth divergences between two associated property whereas sustaining a market-neutral stance. This mission applies this idea to the Indian fairness market between January 1, 2015, and June 30, 2025.
The first motivation was to construct a rigorous prototype that addresses widespread algorithmic buying and selling pitfalls, reminiscent of look-ahead bias, incomplete Revenue and Loss (PnL) calculations, and insufficient a number of testing controls.
Technique & Implementation Methodology (Technical Breakdown)
The technique depends on a rolling walk-forward methodology using a 252 trading-day coaching window and a 21-day check step.
1. Pair Choice & Cointegration:
In the course of the coaching part, the hedge ratio (β) is estimated utilizing Unusual Least Squares (OLS).
Residual stationarity is then examined utilizing the ADF(0) t-stat to generate a MacKinnon p-value.
The Benjamini–Hochberg FDR is utilized at 5% to restrict false positives.
Three extremely cointegrated pairs emerged from the framework:
HDFCBANK.NS vs KOTAKBANK.NS,
HEROMOTOCO.NS vs ULTRACEMCO.NS, and
HCLTECH.NS vs ICICIBANK.NS.
2. Sign Era Logic:
To stop look-ahead bias, the rolling variables for traditional deviation and imply are strictly shifted by 1 day.
- Unfold Calculation:
St = At - β × Bt - Z-Rating Calculation:
zt = (St - μt-1) / σt-1 - Execution Guidelines: Enter when
|zt| > 1.5and exit whenztcrosses 0.
Python Implementation Code
Under is a conceptual Python snippet demonstrating the core mathematical logic utilized in Shant’s technique:
3. Portfolio & Danger Administration:
- Sizing: Equal-weight capital allocation, assigning ₹5,00,000 per lively pair.
- Prices: Transaction prices are explicitly modeled at 5 bps per leg per facet for entry and exit.
- PnL Calculation: PnL is mapped from each legs. Any open place is force-closed on the ultimate backtest day to make sure full reporting.
Key Findings & Portfolio Efficiency
The out-of-sample backtest generated the next portfolio-level efficiency metrics over the check interval:
Technique Efficiency Snapshot
Challenges & Limitations
- Sizing Constraints: The allocation is academic (equal capital per pair); it doesn’t dynamically mannequin capability limits or actual margin constraints.
- Transaction Prices: Modeled cleanly at 5 bps per leg per facet, however real-world execution slippage and bid-ask spreads can differ.
- ADF(0) Approximation: The mannequin makes use of a lag-0 ADF for computational pace. A full ADF check with optimized lags is advisable for future iterations.
- A number of Testing: Whereas the FDR methodology reduces false discoveries, it doesn’t fully remove them.
- Survivorship Bias: The 25-stock universe is fastened and doesn’t dynamically account for historic index reconstitution.
Subsequent steps
Enhancing Technique Efficiency
Whereas the present technique gives a clear educational baseline, a number of focused enhancements can meaningfully enhance its risk-adjusted returns and real-world applicability:
1. Optimise the ADF Lag Choice
Exchange the present ADF(0) shortcut with an information-criterion-based lag selector (AIC or BIC). This reduces the chance of spurious cointegration alerts and improves pair choice high quality, resulting in extra secure and dependable commerce entries.
2. Increase the Universe and Diversify Pairs
The present three-pair portfolio is very concentrated. Extending the inventory universe past 25 large-caps to incorporate mid-cap NSE shares throughout further sectors (Power, FMCG, Metals) would yield a broader set of cointegrated candidates, enhance diversification, and scale back the impression of any single pair breaking down.
3. Introduce Dynamic Place Sizing
The technique at the moment makes use of a hard and fast ₹5,00,000 per pair. Changing this with volatility-scaled sizing (e.g., inverse-volatility or Kelly-criterion weighting) would allocate extra capital to pairs displaying stronger mean-reversion alerts and tighter spreads, enhancing general Sharpe ratio and decreasing drawdowns.
4. Refine Entry/Exit Thresholds Adaptively
The fastened z-score thresholds of ±1.5 for entry and 0 for exit are static throughout all market regimes. An adaptive threshold mannequin; the place entry and exit ranges are calibrated to every pair’s rolling volatility or regime classification (trending vs. mean-reverting), can filter out low-quality alerts and enhance the win ratio past the present 63.47%.
5. Incorporate Cease-Loss Guidelines to Management Drawdown
The present most drawdown of -34.31% is excessive relative to the annualised return of 0.30%. Including a pair-level stop-loss (e.g., exit when the z-score breaches ±3.0 or when unrealised loss exceeds a hard and fast share of allotted capital) would cap draw back on regime-breaking occasions and considerably enhance the Sharpe ratio.
6. Deal with Survivorship Bias with a Rolling Universe
The fastened 25-stock universe inflates historic efficiency by solely together with firms that survived the total 2015–2025 interval. Utilizing a point-in-time NSE Nifty 50 or Nifty 100 constituent record that displays precise index composition at every coaching window would remove this bias and produce extra practical forward-looking efficiency estimates.
Steps for steady studying:
To construct on the ideas lined on this weblog, reminiscent of statistical arbitrage, cointegration testing, and mean-reversion technique growth, you may discover superior assets and structured studying paths that concentrate on algorithmic buying and selling.
Begin with foundational utility guides like Python for Buying and selling Fundamentals and Imply Reversion Buying and selling Technique by Dr Ernest P Chan, which stroll by how statistical fashions are constructed and evaluated in reside monetary contexts.
For these seeking to transcend supervised fashions, Studying Tarck on Superior Algorithmic Buying and selling is good for complicated quantitative methods, whereas Issue Based mostly Investing affords perception into methods that adapt over time and throughout market regimes.
To additional strengthen your modelling and analysis expertise, confer with Portfolio & Danger Administration and Backtesting Buying and selling Methods. These assets provide targeted steering on the varieties of statistical fashions Shant Tondon utilized in his EPAT mission.
When you’re prepared for hands-on studying with business steering, discover the Quantitative Buying and selling and Synthetic Intelligence in Buying and selling studying tracks. These curated paths provide end-to-end coaching from knowledge dealing with and have engineering to mannequin deployment.
Lastly, when you’re impressed by Shant Tondon’s structured strategy and wish to replicate an analogous end-to-end mission, think about the Govt Programme in Algorithmic Buying and selling (EPAT). It gives a complete curriculum overlaying Python, statistics, machine studying, backtesting, and real-world buying and selling purposes, all important parts behind this EPAT ultimate mission.
Disclaimer: The data on this mission is true and full to the perfect of our Scholar’s data. All suggestions are made with out assure on the a part of the scholar or QuantInsti ®. The coed and QuantInsti ® disclaim any legal responsibility in reference to the usage of this info. All content material supplied on this mission is for informational functions solely and we don’t assure that through the use of the steering you’ll derive a sure revenue.
