Add market regime detection for conditional model selection - #190
Merged
Conversation
Agent-Logs-Url: https://github.com/ch55secake/hyperion/sessions/dae6ab1d-d0b0-4dac-8f2c-35f7ecc9636d Co-authored-by: ch55secake <87881861+ch55secake@users.noreply.github.com>
…REGIME_HMM→COL_REGIME_GMM, fix docstrings Agent-Logs-Url: https://github.com/ch55secake/hyperion/sessions/dae6ab1d-d0b0-4dac-8f2c-35f7ecc9636d Co-authored-by: ch55secake <87881861+ch55secake@users.noreply.github.com>
Owner
|
@copilot fix the typecheck |
Agent-Logs-Url: https://github.com/ch55secake/hyperion/sessions/60455644-c8bb-4793-9fe0-fedfbd39b3c1 Co-authored-by: ch55secake <87881861+ch55secake@users.noreply.github.com>
Contributor
Author
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.
Description
Adds three regime signals as first-class ML features and a regime-routing trading strategy. The pipeline previously applied identical logic regardless of market conditions; now each bar is labelled with volatility, trend, and GMM-based regime state so models and strategies can condition on market context.
Changes in this pull request
src/feature/regime.py(new) — three detectors exposed viaclassify_regime:detect_volatility_regime— rolling vol bucketed into low/medium/high via quantile thresholdsdetect_trend_regime— bull/bear/sideways from price vs 50d/200d MAsdetect_gmm_regime— Gaussian Mixture Model on (rolling mean return, rolling vol); components sorted so state 0 is always the most bearish; includesassert gmm.means_ is not Noneguard to satisfy static type checkingsrc/feature/feature_engineering.py—_add_regime_features()appendsRegime_Volatility,Regime_Trend,Regime_GMMto every feature matrix (shifted with all other indicators)src/feature/__init__.py— exportsclassify_regimeand regime constantssrc/simulation/strategy/regime_aware.py(new) —RegimeAwareStrategyregistered as"regime_aware", routes each bar to one of three sub-logics:src/simulation/strategy/__init__.py— imports the new strategysrc/pipeline/base_pipeline.py—_log_regime_coveragelogs train/test regime distributions per symbol; warns when the test split is single-regimetests/feature/test_regime.py— 28 unit tests covering all detectors, edge cases (tiny series fallback, state-count clamping), andFeatureEngineeringintegrationtests/simulation/test_regime_strategy.py— 21 unit tests covering all strategy branches and a full simulation loop