Does a hidden Markov model beat simple regime filters? We tested it on Bitcoin
The HMM has the smallest excess over its floor of the four models, and as a long/cash filter its Sharpe is half of buy-and-hold's (0.40 against 0.80).
No edgeSource: docs/verdicts/2026-10-20-hmm.md
Found nothing on a test with strict parameters. That doesn't mean there is no edge or value to traders. A strict test asks one narrow question, on the markets, anchors and settings we chose. Many traders use these tools to organise a chart, frame a plan or decide when to pay attention, and your market, anchor or timeframe may behave differently. Test it on yours: Studio's Test button scores a drawing against chance.
The question
Is a hidden Markov regime model worth adding over the ported baseline filters? The roadmap deferred it until that advantage was tested.
Method
A two-state Gaussian HMM on daily log returns (Baum-Welch in numpy), fitted on the bars to date: starting after 500 bars, refitted every 250.
Each bar's label is the filtered state, from the forward pass alone, so no label has seen a later bar. A test checks this: appending a year of bars leaves every earlier label unchanged. The state with the higher fitted mean is labelled TREND_UP, giving two labels like the MA filter.
Judged on the same two questions as the ported models: separation of 20-day forward returns, and as a long/cash filter.
Data
BTCUSDT daily.
What chance looks like
Each model's surrogate floor for forward-return separation, and buy-and-hold and rotated positions for the strategy test, set up exactly as in regime filters and the trend filter. The baselines reproduce those numbers exactly.
The null
Separation: 40 surrogates, blocks a quarter of each model's own run length. Strategy: 10 bps a flip, 40 surrogates, 200 rotations.
The result
What it finds: a calm state and a turbulent one, daily σ 1.8% against 5.5%, with mean returns 0.10% and 0.07% a day. The split is by volatility, not by direction. Filtered labels flip every 4.9 bars.
Separation: the HMM has the smallest effect (0.066) and the smallest excess (+0.010, p 0.415) of the four.
As a filter: Sharpe 0.40 against 0.80 for buy-and-hold over the same bars, below its own rotated positions (p 0.856). Its drawdown is deeper than holding (−83.8% against −76.6%). It flips 573 times, so costs eat the rest.
| model | runlen | effect | floor | excess | p | verdict |
|---|---|---|---|---|---|---|
| quadrant | 7.1 | 0.354 | 0.316 | +0.039 | 0.341 | at the floor |
| ma150 | 42.3 | 0.153 | 0.138 | +0.015 | 0.341 | at the floor |
| ma50 | 19.1 | 0.231 | 0.113 | +0.118 | 0.098 | at the floor |
| hmm2 | 4.9 | 0.066 | 0.056 | +0.010 | 0.415 | at the floor |
| model | expo | flips | sharpe | hold | rot | p_rot | maxDD | holdDD | rotDD | p_DD |
|---|---|---|---|---|---|---|---|---|---|---|
| ma150 | 52% | 75 | 0.73 | 0.54 | 0.38 | 0.060 | -52.2% | -76.6% | -70.8% | 0.015 |
| ma50 | 53% | 171 | 1.05 | 0.69 | 0.47 | 0.020 | -66.6% | -83.2% | -74.3% | 0.174 |
| quadrant | 28% | 179 | 0.66 | 0.66 | 0.29 | 0.070 | -63.3% | -83.2% | -64.9% | 0.418 |
| hmm2 | 79% | 573 | 0.40 | 0.80 | 0.58 | 0.856 | -83.8% | -76.6% | -75.8% | 0.905 |
What this does not say
- Only Bitcoin: the other four instruments were not re-run in this environment.
- Only one HMM. A three-state model, one on features rather than raw returns, or a slower refit could behave differently. Each is a new hypothesis, and one more look at the same history.
- Not a verdict on volatility regimes as risk information. The calm and turbulent states are real; volatility clusters. They just don't predict the sign of the next 20 days.
Where the code is
The engine is PyraTime's test harness. This verdict is docs/verdicts/2026-10-20-hmm.md, and the code it ran is:
engine/validation/hmm.pyengine/scripts/regime_verdict.pyengine/scripts/strategy_verdict.py
python -m scripts.regime_verdict BTCUSDT
python -m scripts.strategy_verdict --symbols BTCUSDT
python -m pytest tests/test_hmm.pyThe tools this covers
Each of these pages says what the tool does and quotes this test:
Educational only, not financial advice. A test asks one narrow question on the data and settings named above.