Interactive Guide

What Mood Is
the Market In?

How a Hidden Markov Model reads the market's emotional state, and why it matters for your trades

Part of the Trader Koo project · March 2026

Low Vol Normal High Vol
Scroll to explore

Markets have moods. Some weeks prices drift calmly upward. Other weeks, every headline sends stocks whipsawing 3% in an hour. A Hidden Markov Model (HMM) reads those moods automatically, classifying every day as calm, normal, or stormy, so you can adjust your trading strategy before the weather changes.

This guide assumes zero machine learning knowledge. If you trade stocks and want to understand what that "HMM LOW VOL" badge on your dashboard means, you are in the right place.

This is educational content only, not financial advice. Always do your own research and consult a qualified advisor before making investment decisions.

10-minute read · interactive demos · no ML background required
↓ Scroll to start
Section 1

Three States of Volatility

Think of the stock market like weather. Some days are sunny, some are cloudy, and some are full-blown storms. The HMM sorts every trading day into one of three regimes based on how wildly prices are swinging.

☀️

Low Volatility

Clear skies. Prices drift smoothly along a trend. Small daily moves, calm and confident.

Normal Volatility

Partly cloudy. Prices zigzag around a path. Moderate daily swings, business as usual.

⛈️

High Volatility

Thunderstorm. Wild price swings and gap moves. Fear and uncertainty dominate the tape.

Why three? Research shows that stock returns naturally cluster into roughly three volatility regimes. Two feels too coarse (you miss the "normal" middle). Four or more starts overfitting noise. Three is the sweet spot.
Section 2

The Hidden Part

You can see the price chart. You can feel the volatility. But you cannot directly see which regime the market is in. That state is hidden. You only see the symptoms, not the underlying condition.

Reveal the Regime

Below is a synthetic 120-day price chart. It looks like one continuous line, but the market quietly shifted between three different mood states. Click the button to color the background by the hidden regime.

This is why it is called "Hidden" Markov Model. The Markov part means: tomorrow's regime depends primarily on today's regime, not on what happened last week or last month. Like weather: if it is sunny today, it will probably be sunny tomorrow. But a storm front can roll in and change everything.
Section 3

How It Learns Patterns

The HMM looks at two things for every day: the daily return (how much the price changed) and the realized volatility (how big the recent swings have been). Then it finds three natural clusters.

Return vs. Volatility Scatter

Each dot is one trading day. The x-axis is the daily return; the y-axis is the 10-day rolling volatility. Click Cluster to watch the HMM sort them into three groups.

No labels needed. You never tell the model which days are "calm" or "stormy." It figures it out from the data alone. Days with small returns and low volatility group together naturally, and wild days cluster separately. This is unsupervised learning.
Under the Hood: The Math

For those curious about what is actually happening mathematically. The HMM has three components:

1. Hidden states. The model assumes $K = 3$ hidden states (Low Vol, Normal, High Vol). At each time step $t$, the market is in exactly one state $z_t \in \{1, 2, 3\}$.

Analogy: Think of the market as a person with three moods. At any moment they are either relaxed, alert, or panicking. You cannot read their mind directly, but you can observe their behavior (price movements) and infer the mood.

2. Transition matrix. The probability of moving from state $i$ to state $j$ tomorrow:

$$A_{ij} = P(z_{t+1} = j \mid z_t = i)$$

Each row sums to 1. The diagonal entries $A_{ii}$ are typically large (0.95+), meaning regimes are sticky. The transition risk shown on the badge is simply $1 - A_{ii}$ for the current state $i$.

Analogy: Like weather: if it is sunny today, there is a 95% chance it is sunny tomorrow. But there is a 5% chance a storm rolls in. The transition matrix is the weather forecast for regime changes.

3. Emission model. In each state $k$, the observed features (daily return $r_t$ and rolling volatility $\sigma_t$) follow a Gaussian distribution:

$$\mathbf{x}_t \mid z_t = k \sim \mathcal{N}(\boldsymbol{\mu}_k, \boldsymbol{\Sigma}_k)$$

Where $\boldsymbol{\mu}_k$ is the mean vector for state $k$. In our implementation, all states share a single covariance matrix $\boldsymbol{\Sigma}$ (tied covariance), which models feature correlations while keeping the model stable. The states differ in their means: Low Vol has small $|\boldsymbol{\mu}_k|$, High Vol has large $|\boldsymbol{\mu}_k|$.

Analogy: Each mood has a "fingerprint." A relaxed person speaks softly and moves slowly (small returns, low volatility). A panicking person shouts and flails (big returns, high volatility). The model learns each mood's fingerprint from data.

4. Learning (Baum-Welch / EM). The parameters ($A$, $\boldsymbol{\mu}_k$, $\boldsymbol{\Sigma}_k$) are learned from historical price data using the Expectation-Maximization algorithm. We run 10 random restarts and keep the model with the highest log-likelihood:

$$\mathcal{L} = \log P(\mathbf{x}_1, \mathbf{x}_2, \ldots, \mathbf{x}_T \mid A, \boldsymbol{\mu}, \boldsymbol{\Sigma})$$
Analogy: Imagine guessing someone's moods from a diary of their daily activities. EM is like reading the diary 100 times, each time refining your guess of when they were relaxed vs. panicking. The 10 random restarts are like having 10 different people read the diary independently and picking whoever's interpretation fits best.

5. Decoding. Once trained, the Viterbi algorithm finds the most likely state sequence, and the forward algorithm gives us the posterior probabilities $P(z_t = k \mid \mathbf{x}_{1:T})$ shown in the stacked area chart.

Analogy: After reading the full diary, you go back and label each day: "they were definitely relaxed here," "this week they were panicking." That labeled timeline is what you see in the stacked area chart on the dashboard.
Section 4

Reading the Dashboard Badge

On the Trader Koo stock chart, you will see a badge like this at the top. Let us break down exactly what each part means.

Badge Anatomy
HMM LOW VOL (5D) · 1.8% SHIFT RISK
HMM Model Type
·
LOW VOL Current Regime
·
(5D) Days in State
·
1.8% SHIFT RISK Transition Probability
LOW VOL
The model's current verdict on the market's mood. Green = calm, amber = normal, red = stormy.
5D
The market has been in this same regime for 5 consecutive days. Longer streaks = more stable.
1.8%
Probability of switching to a DIFFERENT regime tomorrow. Low = regime is stable.
The stacked area chart. Below the stock chart on the dashboard, you will also see a stacked area chart showing regime probabilities over time. The three colors (green, amber, red) show how confident the model is in each regime for each day. When one color dominates, the model is sure. When colors are mixed, the market is at a crossroads.
Section 5

Transition Risk

The HMM does not just tell you today's mood. It also learns how likely the market is to switch moods. This is captured in a 3×3 transition matrix, a table of probabilities.

Transition Probability Heatmap

Read it left to right: "If the market is currently in [row], what is the probability it will be in [column] tomorrow?" Notice how the diagonal is bright. Regimes tend to persist.

Low Vol
Normal
High Vol
1.8% shift risk means: the model assigns a 98.2% probability that tomorrow's regime will be the same as today's. In other words, regimes are sticky. Once the market enters a calm phase, it tends to stay calm for many days. But when a shift finally happens, it can be sudden, and that is exactly when you want to adjust your strategy.
Read the off-diagonals carefully. If "Low Vol → High Vol" shows 0.5%, the market almost never jumps straight from calm to chaos. It usually transitions through Normal first. This gives you a warning window.
Section 6

Days in Current State

The "(5D)" in the badge tells you how many consecutive days the market has stayed in the same regime. A long streak means the regime is well-established. A short streak means it might have just flipped.

Interactive Timeline

Click any circle to cycle its regime (Low → Normal → High → Low). The counter below shows the current streak length, counting backwards from the last day until the regime changes.

0
Days in Current Regime
-
Current Regime
Why streaks matter: A stock that has been in Low Vol for 15 days is much more likely to stay there than one that just entered Low Vol yesterday. The longer the streak, the more confident you can be that the trend will continue. But extremely long streaks also mean a regime change is increasingly "due." Nothing lasts forever.
Section 7

How to Use This

Understanding the regime adds context to your analysis. Here are some ways traders think about each state. Here is a practical playbook for each state.

Low Volatility

  • Trends persist. Ride momentum. Breakouts tend to follow through.
  • Tighter ranges. Smaller daily swings mean risk per trade is naturally lower.
  • Trends persist. Calm markets tend to trend more smoothly with fewer false reversals.
  • Selling premium? Low IV means options are cheap. Not ideal for selling, but great for buying cheap protection.

Normal Volatility

  • Standard conditions. The market is behaving within typical parameters.
  • Balanced risk. Neither unusually calm nor unusually volatile.
  • Watch for transitions. Normal can shift to either calm or stormy. Monitor the shift risk % closely.
  • Both trend and mean-reversion strategies can work. Be flexible.

High Volatility

  • Elevated risk. Daily swings are large, meaning the same position carries more dollar risk.
  • Wider ranges. Price tends to move further from mean, so narrow levels get tested more often.
  • Mean-reversion works. Big moves tend to snap back. Fade extremes.
  • Patience pays. High-vol regimes eventually resolve. Some traders prefer to wait for clearer conditions.
Regime Characteristics at a Glance
0.3 – 0.8%
Typical Daily Range (Low Vol)
0.8 – 1.5%
Typical Daily Range (Normal)
1.5 – 4.0%+
Typical Daily Range (High Vol)
The key insight: The HMM does not tell you what to buy. It tells you what kind of environment you are operating in. Same stock, same signal, but the regime context changes how you interpret it and how you manage risk around it.