Markets coveredMatch OddsCorrect ScoreOver / UnderFirst HalfSecond Half
Statometrics
Model Library · Bayesian methods and time series

Hidden Markov Models

Infer which hidden state a market or match is in, such as calm versus informed money, from the patterns you can actually observe.

Advancedtradingin-play

In one sentence

A hidden Markov model (HMM) assumes a system switches between a few unseen states, each producing observable data in its own typical way, and works out the probability of being in each state right now.

How it works

You cannot see whether a pre-match market currently contains informed money. You can see traded volume, price moves and order book changes. An HMM links the two: each hidden state (say "calm" and "informed") has its own habits, such as how often it produces bursts of heavy volume.

The model has two ingredients. Transition probabilities say how likely the market is to stay in its current state or switch next minute. Emission probabilities say how likely each observation is in each state. Given these, the forward algorithm updates your belief every minute: predict using the transitions, then correct using what you observed.

The result is not a yes/no label but a running probability, for example "80% chance we are in an informed spell". That makes it a natural input for trading rules and stake sizing.

The maths

The forward (filtering) step for state j:

P(st=j∣y1:t)∝P(yt∣st=j)∑iP(st=j∣st−1=i) P(st−1=i∣y1:t−1)P(s_t = j \mid y_{1:t}) \propto P(y_t \mid s_t = j) \sum_i P(s_t = j \mid s_{t-1} = i)\, P(s_{t-1} = i \mid y_{1:t-1})
  • sₜ: the hidden state at time t (calm or informed).
  • yₜ: the observation at time t (for example, "large volume" or "normal volume").
  • P(sₜ = j given sₜ₋₁ = i): the transition probability from state i to state j.
  • P(yₜ given sₜ = j): the emission probability, how typical the observation is in state j.
  • The last term: your belief from the previous step.

In plain English: roll yesterday's belief forward using how states tend to switch, then re-weight by how well each state explains what you just saw.

Worked betting example

You watch the away side at 4.2 in Match Odds in the hour before kick-off, checking each minute for "large traded volume". From labelled past matches you set (illustrative figures):

  • Calm stays calm 95% of the time and switches to informed 5%. Informed stays informed 80% and returns to calm 20%.
  • Large volume appears in 10% of calm minutes and 60% of informed minutes.
  • Starting belief: 10% informed.
  1. Minute 1: large volume. Predict: 0.10 × 0.80 + 0.90 × 0.05 = 12.5% informed. Update: (0.125 × 0.60) ÷ (0.125 × 0.60 + 0.875 × 0.10) = 0.075 ÷ 0.1625 ≈ 46.2%.
  2. Minute 2: large volume again. Predict: 0.462 × 0.80 + 0.538 × 0.05 ≈ 39.6%. Update: (0.396 × 0.60) ÷ (0.396 × 0.60 + 0.604 × 0.10) ≈ 79.7%.
  3. Trading rule. Suppose your history shows a £40 back at this price averages +£2.00 after commission when entered in an informed spell and minus £1.50 in a calm one. Expected value = P × 2.00 minus (1 − P) × 1.50. Break-even is at P ≈ 42.9%.
  4. Decision. At the start (12.5%): about minus £1.06. After minute 1 (46.2%): +£0.12, barely worth it. After minute 2 (79.7%): +£1.29.
  5. If minute 3 is quiet, the belief falls back to about 45%, and the expected value to about +£0.08. The model reacts quickly both ways.

Where it's good

  • Detecting informed-money spells in pre-match markets, especially around team news, from volume and price behaviour.
  • In-play football "tempo" states (cagey versus open) that change the rate of goals.
  • Tennis momentum or fatigue states inferred from points won on serve.
  • Separating a trading strategy's good and bad regimes to decide when to switch it off.
  • Any setting where a few distinct behaviours alternate and you only see their side effects.

Limitations and pitfalls

  • You must choose the number of states. Two is interpretable; more usually fits better in-sample and worse out of sample.
  • The standard HMM assumes the time spent in a state follows a simple geometric pattern, which rarely matches real markets that speed up as kick-off approaches.
  • Parameters fitted by the Baum-Welch algorithm can land on poor solutions; run from several starting points.
  • States found automatically may not mean what you hope. A "state" can just be "near kick-off" rather than "informed money".
  • Labelled data for training (which spells were really informed) is scarce, so emission probabilities are often guesses.
  • The per-state P&L figures that drive decisions are themselves noisy estimates; small errors move the break-even point a lot.

How to build it

  • hmmlearn (Python) for Gaussian and discrete HMMs; pomegranate for more flexible models; depmixS4 in R.
  • Data: minute-by-minute or second-by-second features (volume, price change, order book imbalance) across many markets.
  • Practical tip: include minutes to kick-off as an input or fit separate models by stage of the market, so the model does not simply rediscover the clock.
18+ only. Educational content, not financial or betting advice. Past results do not guarantee future returns. If gambling stops being fun, get free, confidential help at BeGambleAware.org.
Members