02 / 08Quant Research2025

Market Regime Detection Framework

Hybrid HMM + K-Means regimes on NIFTY 50

Hidden Markov Models and K-Means label the market’s regime; an XGBoost classifier predicts it; the strategy follows the regime.

Source private
Data
NIFTY 50 · 15 years
Regimes
Low-vol · Trending · Crisis
Strategies
Mean reversion · Breakout · Risk-off
Year
2025

01 Problem

Markets don’t behave the same way all the time. A strategy that works in a calm, trending tape can be ruinous in a crisis — so the first question isn’t what to trade, it’s what kind of market this is.

02 Approach

  1. Label the regimes

    A hybrid of Hidden Markov Models and K-Means clustering separates 15 years of NIFTY 50 history into three regimes: low-volatility, trending and crisis.

  2. Describe the market state

    28 engineered features describe the market at each point in time — including realized volatility, VIX dynamics and return skewness.

  3. Predict the regime

    An XGBoost classifier learns to predict the regime, using sample weighting to handle class imbalance — crisis periods are rare by definition.

  4. Allocate by regime

    Each regime maps to a strategy — mean reversion, breakout or risk-off — so allocation changes as the detected regime changes.

  5. Track and inspect

    Experiments are tracked in MLflow and explored through a Streamlit dashboard.

03 Results

Market regimes
3
NIFTY 50 history
15y
Engineered features
28
Regime prediction accuracy
78%
  • 78% regime prediction accuracy (XGBoost with sample weighting).
  • 14.2% CAGR for the regime-driven allocation vs 10.8% for buy-and-hold.
  • Maximum drawdown reduced from 50% to 18%.
  • Written up as an IEEE-format research paper.

Backtest results as reported in the project write-up. Historical, not a forecast.

04 Stack

  • Python
  • HMM
  • K-Means
  • XGBoost
  • MLflow
  • Streamlit
Next case study · 03DemandIQ