A Gaussian HMM from scratch, with no timing edge claimed
Baum-Welch EM and a log-space forward-backward, validated against hmmlearn to 1e-6. It labels persistent low- and high-volatility regimes, and the timing overlay does not beat buy-and-hold out of sample.
00Overview
Markets feel like they switch between calm and turbulent states. A Gaussian Hidden Markov Model makes that intuition testable. This is a from-scratch implementation of the full EM machinery, validated to 1e-6 against hmmlearn, then used to ask whether regime labels are actually tradable.
01Method
- Baum-Welch EM for parameter estimation.
- Log-space forward-backward for numerical stability over long sequences.
- Viterbi decoding for exploratory analysis only.
- An online causal filter is the only signal allowed to drive a trade (no peeking at the smoothed posterior).
02What it finds
The model recovers two highly persistent regimes: a low-volatility state (sigma ~ 0.10) and a high-volatility state (sigma ~ 0.19), each with self-transition probability above 0.98. The labels are stable and interpretable.
03The honest test
Stable regimes do not imply a tradable edge. The regime-timing overlay never clears its Deflated-Sharpe threshold out of sample after costs, and the pure verdict reads no_timing_edge. The model is useful for describing risk, not for beating buy-and-hold.