Methodology
How the causal pipeline, filtered HMM, conformal forecaster, MLP anomaly siren, Advisor stability index, and hash-chained ledger work.
Pipeline writes, app reads
Every weekday a scheduled pipeline downloads daily prices, cleans corrupted prints (dropped, never repaired), builds strictly backward-looking features (returns, 20/60-day volatility, 5d/60d volatility ratio, 1-month momentum, intraday range, cross-pair correlation), scores filtered regimes with a hidden Markov model, and publishes immutable artifacts. Both the Streamlit console and this GitHub Pages web app read those artifacts only.
The regime model, in plain English
A hidden Markov model infers four unobserved market moods — calm trend chop crisis — where moods are sticky through a learned transition matrix rather than flickering every day. States are fitted on 2005–2016 data only and named by a frozen rule: lowest average volatility is calm, highest is crisis; between the two remaining states, stronger momentum is trend and the other is chop.
Filtered vs smoothed — the honesty rule. Every probability here is strictly filtered ("given data up to and including day t only"), verified by truncation-invariance tests. Smoothed hindsight paths never appear anywhere in this project.
Out of sample & the Orb
The orb on Pairs is a display of the same numbers as the cards: the regime sets its colour and motion (calm drifts, trend spins, chop jitters, crisis is fast and chaotic), the 5-day change risk scales the jitter, and a siren reading above 98 fires a decaying pulse. It computes nothing new.
The model is trained once on 2005–2016 and scored forward; the dashed line marks where the out-of-sample period begins (2017). Everything to the right is data the model had never seen when it was fitted, and the regime anatomy table is computed on that out-of-sample period only.
The Advisor page — stability, durability, risk budget
Market Stability Index (0–100). A transparent weighted mix of five instability signals, each 0–1: the filtered regime (calm 0 · trend 0.35 · chop 0.55 · crisis 1, blended with residual probability mass) at 35%, 5-day regime-change risk at 20%, siren percentile above 80 at 20%, volatility front (vol_ratio above 1) at 15%, and HMM entropy at 10%. 100 = fair, below 55 unsettled, below 35 stormy.
Durability. An HMM regime with self-transition probability p lasts 1/(1−p) days on average. Because the chain is memoryless, a long run is not "due" to end — the change-risk gauge, not age, carries transition pressure.
Risk budget. The share of your own normal position size justified by current conditions: 100% by default; ×(1 − change risk) when change risk exceeds 30%; ×0.5 in crisis, ×0.8 in chop; ×0.7 when siren exceeds 90; 0 above 98 (the siren stop). Never directional.
Ask the radar. The assistant receives a structured JSON snapshot of computed numbers and answers strictly from those fields — never predicting prices or giving personal advice, and uses deterministic templates with no API key required.
Change-risk forecaster, conformal intervals & anomaly siren
An XGBoost forecaster trained on ≤2016 data, Platt-recalibrated on 2017–2018 validation, and scored once on 2019+ test estimates the 5-day probability of a regime transition (test PR-AUC 0.548 vs 0.162 base rate; test Brier 0.102 vs 0.136 base rate). Split-conformal bands target 90% empirical coverage. An 8-3-8 MLP autoencoder anomaly siren trained only on calm training days scores how unlike calm history today's features look (0–100 percentile).
The live ledger. Every weekday's published forecasts are appended to an immutable SHA-256 hash chain before outcomes are known, then resolved five trading days later using the exact same scoring code.
Limitations
- Daily data only: intraday shocks are averaged away; daily closes lag intraday extremes.
- Label boundary noise: filtered labels can flicker near state boundaries; read confidence alongside the regime word.
- Descriptive, never directional: no model here forecasts whether a currency pair moves higher or lower.
- Rare events & Gaussian emissions: extreme shocks such as January 2015 CHF can dominate a single state; fat tails are absorbed into high-volatility states.