regimes
Skill17 starsChanged 7 days agoMITView on GitHub
Estimates which market regime is in force, as a probability for each regime, from relative features such as the ratio of short to long volatility, trend strength, drawdown, and cross asset correlation, using only data available at each date. Use when asked what kind of market we are in, whether volatility or stress is rising, for regime probabilities, or for exposure that adapts to the regime.
In this repository5 other files it gives its agents.
- earningsSkill
- eventsSkill
- riskSkill
- sizingSkill
- validationSkill
The file
We split this skill into the rules it gives an agent
2 rules. About 0 are common, 1 is distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 30
Read the JSON. If passed is false, report the failed check and stop.
- Distinctive: line 36
No future data: probabilities recomputed from prices cut at a check date match the full run exactly.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Regime detection
Answers one question: what kind of market are we in? Fits a Gaussian hidden Markov model (Hamilton, 1989) to relative features and reports filtered probabilities. Every number comes from scripts/regimes.py.
Inputs
prices.csv: a date column, then daily price levels. One column is the series whose regime is measured (for example an equity index). Extra columns, such as bonds, credit, or currencies, feed the average correlation feature.- At least three years of daily history: one year to warm up the features and enough to train and then report.
- A training end date. The model is fitted only on data up to that date; report dates after it are out of sample. If the user gives none, the script uses the midpoint of the history and flags it.
- Optional: a target exposure for each regime, ordered from lowest to highest volatility. These are the user's own policy. Never propose them yourself.
Procedure
- Confirm the series, the correlation series, the number of regimes (2 or 3), and the training end date.
- Run the model:
python scripts/regimes.py --prices prices.csv --asset INDEX --states 3 \ --train-end 2019-12-31 --exposures 1.0,0.6,0.2 --history regimes_history.csv - Read the JSON. If
passedis false, report the failed check and stop. - Report the probability of each regime, the most likely regime, the feature values behind it, and the blended exposure when targets were given.
Checks
- Probabilities sum to one on every date.
- No future data: probabilities recomputed from prices cut at a check date match the full run exactly.
- The EM fit converged.
- The report date lies after the training period.
Output
results.probabilities (one per regime: low_vol, normal, high_vol, or two of them), results.most_likely, results.features, results.regime_means, results.transition_matrix, results.expected_duration_days, and with targets results.blended_exposure. --history writes the daily probabilities to a CSV.
Explaining the result
- Lead with the probabilities, not only the most likely label; a 55 to 45 split is a different message from 95 to 5.
- Tie the answer to the features: for example, short term volatility running above its one year level with a falling trend and rising correlation.
- Regimes are labeled by their average volatility ratio. Describe them with the
regime_means, which show what each regime looked like in training. - Expected duration comes from the transition matrix and describes typical persistence in the training period.
- The blended exposure moves smoothly as probabilities change, which avoids abrupt switches on noisy signals.
For features, the model, and the filter, see references/methodology.md.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

