Market regime¶
Unsupervised market-regime labelling by clustering rolling volatility / return
features (built by regime_features).
detect_regimes is the in-sample convenience (for
analysis only — it sees the whole series).
For backtests use RegimeDetector, the causal
variant: fit clusters on the train window only, then predict assigns
each later bar to its nearest centroid online — no future information leaks
into a label. Use the resulting regime as a feature column in the X matrix you
pass to a strategy (see Strategy (fynance.strategy) and Research workflow).
|
Label market regimes by k-means on rolling vol / return features. |
|
Build the causal regime feature matrix: trailing vol and mean return. |
|
Causal market-regime detector (fit on the past, assign online). |