General
Modeling Bitcoin volatility with a Markov-switching model
Aethan Lee DEV Community 周榜
2 views
A Bitcoin price chart shows the path prices took. For this report, I wanted to estimate how the volatility of daily returns changed along that path.
I used a Markov-switching model and built the visual report in OWL Compose. The report includes state probabilities, a transition matrix and a comparison between two-state and three-state specifications.
Explore the full report.
Start with returns and a fixed cutoff
The input is Binance Spot BTCUSDT daily OHLCV data, using completed UTC candles through September 13, 2026. Daily returns are calculated as:
100 * ln(close_today / close_yesterday)
I kept weekends and excluded the incomplete daily candle. The training period runs from January 2, 2022 through June 30, 2026: 1,641 daily returns. The holdout contains 75 days, from July 1 through September 13.
That split matters. Parameters fitted over the entire history would let later observations influence the apparent success of an earlier classification.
Fit states with different variances
The analysis uses statsmodels MarkovRegression with switching means and variances. Both the two-state and three-state models were fitted using multiple starting values and three random seeds. I retained the converged fit with the highest likelihood for each specification.
In the two-state model, the fitted daily return standard deviations are about 1.53% and 4.30%. Both means are close to zero, so I label the states by volatility. Large positive and negative returns can both fit the high-volatility state.
Keep the probability path visible
For the holdout period, training parameters stay fixed. Filtered probabilities update using returns observed up to each day.
The report places the most likely state on the price timeline, then shows the full probability series below it. A hard label can change when the probabilities cross 50%; the probability chart shows whether that change was decisive or marginal.
The January–June portion is explicitly marked as a retrospective training view.
Check the model choice
The three-state model has a slightly lower training BIC. The two-state model has a slightly better mean predictive log score over this holdout. That is useful evidence of sensitivity, rather than proof of a universal winner.
The score evaluates the probability density assigned to observed returns. It does not measure directional trading accuracy.
Make the assumptions inspectable
The report includes fitted distributions, model parameters, transition probabilities and reproducibility notes. Constant transition probabilities and Gaussian returns remain simplifying assumptions.
I built OWL Compose, and used it to present this analysis alongside its charts and data. If you work on time-series analysis, the English report shows the complete result.
What would you test next: rolling refits, a different training window, or a heavier-tailed return distribution?
Read original: https://dev.to/aethanlee/modeling-bitcoin-volatility-with-a-markov-switching-model-5a6o
← Previous
How to Record Matches on Club Courts Automatically
Next →
How to automatically find the batch size when using Accelerate with FSDP2? [D]
Related
Semantic tag vs Non-Semantic tag
General
5
Dev.to (EN Zone)
How LinkedIn "Bold" Text Actually Works (It's Not Bold At All)
General
5
Dev.to (EN Zone)
Google ADK Callbacks Are a Policy Plane, Not Just Hooks
General
7
DEV Community 周榜
How I Modelled My Power BI Data — Data Modelling, Relationships & Joins (Kenya Crops Dataset)
General
3
DEV Community 周榜
Comments0
No comments yet — be the first