← Back

HMM Trader

Build a regime-detection trading system from scratch. Starting with price returns and ending with a live Python dashboard, each lesson adds one layer of the complete architecture.

Market DataOHLCV prices
Featuresreturns, range, vol
HMM7 hidden states
Regime LabelBull / Bear / Chop
Indicators7/8 confirmations
SignalEntry / Exit
BacktestP&L + metrics

Foundations

Lesson 01

Returns & Price Math

Why we model returns, not prices. Percentage change, log returns, and why financial data looks the way it does.

Finance · Math

Lesson 02

Market Regimes

Markets cycle between distinct states — trending bull, crashing bear, and choppy sideways. How to see and measure them.

Finance · Intuition

Lesson 03

Gaussian Distributions

Each regime has a characteristic return distribution. The Gaussian (normal) distribution and its parameters μ and σ.

Probability · Math

The Model

Lesson 04

HMM Foundations

Hidden Markov Models: hidden states, observable emissions, transition matrices. The three core components of an HMM.

AI · Probability

Lesson 05

Viterbi & Training

How the HMM decodes the most likely state sequence from observations. Viterbi algorithm and Baum-Welch EM training.

AI · Algorithms

Lesson 06

Feature Engineering

Transforming raw OHLCV market data into the three features the HMM trains on: returns, range, and volume change.

Data · Engineering

The Strategy

Lesson 07

Indicators & Signal Logic

Eight technical confirmations — RSI, MACD, ADX, and more. The 7/8 entry gate, hysteresis, and the 48-hour cooldown.

Trading · Strategy

Lesson 08

The Full System

Complete Python application: data loader, backtesting engine, and Streamlit dashboard. Architecture, code, and running instructions.

Python · Streamlit · Full Build
📦 View the complete Python source code → data_loader.py · backtester.py · dashboard.py · requirements.txt