Concerning the creator
Venture Summary
This venture 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 take a look at, 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 Fee (FDR) at 5% is utilized.
The technique trades mean-reversion through z-scores of the unfold utilizing a walk-forward practice/take a look at cut 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 threat metrics.
Introduction & Venture Motivation
Pairs buying and selling is a basic statistical arbitrage technique that seeks to use short-term worth divergences between two associated belongings whereas sustaining a market-neutral stance. This venture 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 frequent 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 take a look at step.
1. Pair Choice & Cointegration:
In the course of the coaching part, the hedge ratio (β) is estimated utilizing Atypical 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 Technology 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 & Threat 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 take a look at 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 velocity. A full ADF take a look at with optimized lags is advisable for future iterations.
- A number of Testing: Whereas the FDR technique 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 offers 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
Substitute the present ADF(0) shortcut with an information-criterion-based lag selector (AIC or BIC). This reduces the chance of spurious cointegration indicators and improves pair choice high quality, resulting in extra secure and dependable commerce entries.
2. Develop 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 (Vitality, 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 present 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 indicators and tighter spreads, enhancing general Sharpe ratio and lowering 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 indicators 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. Tackle Survivorship Bias with a Rolling Universe
The fastened 25-stock universe inflates historic efficiency by solely together with corporations that survived the complete 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 lifelike forward-looking efficiency estimates.
Steps for steady studying:
To construct on the ideas coated on this weblog, reminiscent of statistical arbitrage, cointegration testing, and mean-reversion technique improvement, you’ll be able to discover superior assets and structured studying paths that target algorithmic buying and selling.
Begin with foundational software guides like Python for Buying and selling Fundamentals and Imply Reversion Buying and selling Technique by Dr Ernest P Chan, which stroll by means of how statistical fashions are constructed and evaluated in dwell monetary contexts.
For these trying to transcend supervised fashions, Studying Tarck on Superior Algorithmic Buying and selling is good for complicated quantitative methods, whereas Issue Based mostly Investing provides perception into methods that adapt over time and throughout market regimes.
To additional strengthen your modelling and analysis expertise, discuss with Portfolio & Threat Administration and Backtesting Buying and selling Methods. These assets provide targeted steerage on the forms of statistical fashions Shant Tondon utilized in his EPAT venture.
In the event you’re prepared for hands-on studying with trade steerage, 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, for those who’re impressed by Shant Tondon’s structured method and wish to replicate the same end-to-end venture, think about the Govt Programme in Algorithmic Buying and selling (EPAT). It offers a complete curriculum protecting Python, statistics, machine studying, backtesting, and real-world buying and selling purposes, all important elements behind this EPAT closing venture.
Disclaimer: The data on this venture is true and full to the very best of our Scholar’s information. All suggestions are made with out assure on the a part of the coed or QuantInsti ®. The coed and QuantInsti ® disclaim any legal responsibility in reference to the usage of this data. All content material offered on this venture is for informational functions solely and we don’t assure that by utilizing the steerage you’ll derive a sure revenue.
