Repository navigation
Market regimes computed by the terminal: MICRO, IMMINENT and MACRO - #20
Merged
Merged
Conversation
- fred.py: daily FRED series through the public CSV download (no API key), cached per series, refreshed every 6 hours; the last copy is used while FRED can't be reached, and a failed series is retried after 30 minutes. - regimes.py: per-asset HMM regimes (log 5-day realized volatility and the day's return, 2–4 states by BIC, ordered calm → stressed), labelled walk-forward with monthly warm-started refits so no day uses later data; 15-minute features with the time-of-day pattern removed and a switching hazard; macro quadrants (GOLDILOCKS / REFLATION / STAGFLATION / DEFLATION) from a four-state HMM pinned to growth/inflation corners. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01649i4SjUGvhXrPV3AiNhHN
The REGIMES strip and its chart shading now work without a data server:
- MICRO ({T}_regime.json): each instrument's volatility regime, calm to
stressed, from an HMM on its daily bars (2–4 states by BIC), refitted
walk-forward every month so every day is labelled with a model fitted
before it. Rows are dated by each completed bar's own day; the pill shows
the regime expected for today.
- ⚠ IMMINENT: 15-minute returns over their usual size at that time of day
(robust median scale, so neither the session clock nor a burst itself
sets the "usual"), a two-state normal/burst HMM, and an alarm when the
forecast volatility of the next two hours is ≥ 1.5× the usual.
Refreshed with every new 15-minute bar; the daily part is reused.
- MACRO (GLOBAL_macro_regime.json, GLOBAL_regime_transitions.json): the
GOLDILOCKS / REFLATION / STAGFLATION / DEFLATION quadrant from FRED
(S&P 500, 10-year breakeven, WTI), each 3-month change over its trailing
RMS so a long trend keeps its sign, smoothed by a four-state HMM pinned
to the corners; one row per calendar day.
- runner v3: a "regime" phase between live and replay, and a macro pass.
- Learning Center article "Market regimes (HMM)" (EN/AR), README sections
(EN/AR), CHANGELOG; the mean-reversion setup uses the strip's states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01649i4SjUGvhXrPV3AiNhHN
wJubran
added a commit
that referenced
this pull request
Oct 18, 2026
Market regimes computed by the terminal: MICRO, IMMINENT and MACRO
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
The REGIMES strip above the chart read "— no data" because nothing in the repository produced its files. The terminal now computes them itself, from the active data source and public FRED data, in the exact format the UI reads. I worked that format out from
RegimeBar.jsx,MainChart.jsxandReplayView.jsx, since no schema document exists.MICRO:
{TICKER}_regime.json(local_analysis/regimes.py, a newregimephase in the runner)history.slow_d1has one row per completed day, dated by the bar's own day. The forming bar is excluded, and there are no duplicates and no NaN.slow.regimeis the regime expected for today, from the last completed close.⚠ IMMINENT:
fast.imminent/fast.minutes_since_alarmMACRO:
GLOBAL_macro_regime.json(+GLOBAL_regime_transitions.json)SP500); inflation from the 10-year breakeven (T10YIE) and WTI crude (DCOILWTICO).local_analysis/fred.py): it caches each series and refreshes it every 6 hours. When FRED is unreachable it keeps the last copy, and retries a failed series after 30 minutes.Docs
README.mdandREADME.ar.md, plus the Arabic part of the main README.How it was tested
python -m pytestpasses inbackend/: 199 tests on Python 3.13 and 3.10, with 15 new or updated regime tests. The new tests cover:/api/regime/{T}served end to end on the simulator, dated by the bars' own days and NaN-free.No network calls.
UI changes: ran
npm run buildinfrontend/and committed the rebuiltfrontend_build/. A second build was identical.Tried it with
python launcher.py --simin Chromium:CURRENT MACRO GOLDILOCKS · 98%andEURUSD MICRO CALM · 81%with the QUIET chip. The macro file was built from synthetic FRED-format data, because FRED is blocked here.Not done: MACRO was not run against live FRED (
fred.stlouisfed.orgis blocked in this environment). The CSV format it parses is FRED's documentedfredgraph.csv(observation_date,<ID>,.for missing values).Screenshots
Taken locally, not attached:
Generated by Claude Code