Quantitative Research · BTC-USD

Market Regime Detection

7-State Gaussian Hidden Markov Model trained on hourly BTC/USDT data from Binance (asset_id 587). States ordered by mean log return — State 0 most bearish, State 6 most bullish.

BTC Price Coloured by Regime

BTC regime chart

Regime Summary

StateLabelCount% TimeAnn. ReturnAnn. VolHrly VolMean RangeVol ChgSharpe
0
Grind Down
7724.41%-85.24%92.03%0.00980.0218+0.529-92.6
1
Capitulation
2,83116.16%-23.71%25.34%0.00270.0070-0.007-93.6
2
Mild Bear
3,71421.20%-12.14%14.78%0.00160.0041-0.065-82.1
3
Sideways
2,70415.43%-1.73%49.18%0.00530.0102-0.217-3.5
4
Mild Bull
3,05017.41%+1.38%11.99%0.00130.0024-0.029+11.5
5
Bull
3,58220.45%+26.73%16.19%0.00170.0057+0.020+165.1
6
Rally
8664.94%+96.25%60.77%0.00650.0165+0.530+158.4

Ann. Return = Hourly log return × 8,760 · Ann. Vol = Hourly std × √8,760 · States sorted by mean return ascending

Regime Descriptions

State 0: Grind Down

Persistent grinding downtrend. Prices bleed lower slowly each hour.

  • ·Consistent small negative returns
  • ·Low intra-bar range (0.49%)
  • ·Falling volume
State 1: Capitulation

Flash crashes and panic sell-offs. Wild price oscillations trending down.

  • ·Massive intra-bar range (2.4%)
  • ·High volume surges
  • ·Wild price swings
State 2: Mild Bear

Moderate negative drift. Typical correction phases or uncertain macro.

  • ·Slightly negative mean return
  • ·Moderate range (1.0%)
  • ·Above-average volume
State 3: Sideways

Consolidation. Near-zero returns, tightest range, lowest volume.

  • ·Near-zero hourly return
  • ·Tightest range (0.24%)
  • ·Flat/falling volume
State 4: Mild Bull

Moderately positive drift. Recoveries and early-stage uptrends.

  • ·Positive mean return (+0.034%/hr)
  • ·Moderate range (1.2%)
  • ·Declining volume
State 5: Bull

Steady low-volatility uptrend. BTC climbs consistently. Sharpe of 165.

  • ·Consistent positive returns
  • ·Low range (0.66%)
  • ·Decreasing volume (-38%)
State 6: Rally

Mirror of Grind Down. Strong persistent uptrend. Sharpe +158.

  • ·Strongest positive mean return
  • ·Low range (0.47%)
  • ·Stable volume

How Hidden Markov Models Work

The Core Idea

A Hidden Markov Model assumes markets exist in a small number of unobservable hidden states. You cannot see the state directly — only its noisy effects in price and volume.

P(state[t+1] | state[t]) → Transition Matrix (7×7)
P(obs | state) → Gaussian Emission
P(state[0]) → Initial Distribution

Gaussian Emissions — 3 Features

Log Return
log(Closeₜ / Closeₜ₋₁)
Normally distributed, captures direction & magnitude
Price Range
(High − Low) / Close
Intra-bar volatility, normalised for price level
Volume Change
log(Volₜ / Volₜ₋₁)
Liquidity shifts; log ratio avoids sign asymmetry

Training: Baum-Welch (EM)

E-stepForward-backward algorithm computes state probabilities at each timestep given all observations.
M-stepUpdate transition matrix and Gaussian means/covariances to maximise expected log-likelihood.
RepeatUntil convergence (Δlog-likelihood < 1e-4). Converged in ~100 iterations.

Decoding: Viterbi Algorithm

Each bar is assigned a regime using the Viterbi algorithm — dynamic programming that finds the most probable hidden state sequence.

n_components = 7 states
covariance_type = "full"
n_iter = 100 · random_state = 42