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.

modelrunleneffectfloorexcesspverdict
quadrant7.10.3540.316+0.0390.341at the floor
ma15042.30.1530.138+0.0150.341at the floor
ma5019.10.2310.113+0.1180.098at the floor
hmm24.90.0660.056+0.0100.415at the floor
Separation of 20-day forward returns. Copied from the verdict.
modelexpoflipssharpeholdrotp_rotmaxDDholdDDrotDDp_DD
ma15052%750.730.540.380.060-52.2%-76.6%-70.8%0.015
ma5053%1711.050.690.470.020-66.6%-83.2%-74.3%0.174
quadrant28%1790.660.660.290.070-63.3%-83.2%-64.9%0.418
hmm279%5730.400.800.580.856-83.8%-76.6%-75.8%0.905
As a long/cash filter. Copied from the verdict.

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.py
  • engine/scripts/regime_verdict.py
  • engine/scripts/strategy_verdict.py
python -m scripts.regime_verdict BTCUSDT
python -m scripts.strategy_verdict --symbols BTCUSDT
python -m pytest tests/test_hmm.py

The 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.