Add unified market regime control plugin#5
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 965a01faed
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| external_age_days = int((signal_date - external_as_of).days) if external_as_of is not None else None | ||
|
|
||
| kill_reasons: list[str] = [] | ||
| if benchmark_symbol not in close.columns: |
There was a problem hiding this comment.
Block stale benchmark rows in the governor
When the input has a fresh row for any non-benchmark symbol (for example VIX/credit) but QQQ is missing or stale, resolve_signal_date(close, as_of) still selects that fresh matrix date and price_age_days stays within the limit. This column-only check does not catch that close[benchmark_symbol].loc[signal_date] is NaN, so the macro governor can emit no-action or an actionable VIX/credit route while its benchmark trend/drawdown inputs are absent or older than max_price_age_days.
Useful? React with 👍 / 👎.
|
Historical tuning update (2026-05-28):\n\n- Re-ran real-product TQQQ history using the unified market_regime_control wrapper; wrapper reproduced legacy macro payload behavior exactly.\n- Best default candidate now uses realized_vol_threshold=0.30, requires VIX/credit/financial-stress confirmation before realized vol contributes to actionable_score, and sets delever_risk_asset_scalar=0.0.\n- Full sample 2010-02-12..2026-04-16 vs baseline: CAGR 25.77% (+1.03pp), max drawdown -34.77% (+0.29pp), Sharpe 1.006 (+0.039), Calmar 0.741 (+0.036).\n- Window check: 2022 rate-bear CAGR improves by +0.46pp vs baseline, Covid crash max drawdown improves by +4.15pp.\n- Verification: pytest tests/test_macro_risk_governor_plugin.py tests/test_market_regime_control_plugin.py tests/test_strategy_plugin_runner.py -q; ruff check src tests. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ed07ba91c0
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } | ||
| ) | ||
|
|
||
| vix_symbol = _first_available_symbol(close, vix_symbols) |
There was a problem hiding this comment.
Try later VIX aliases when the first column is stale
When the input contains multiple configured VIX aliases and the first alias column exists but has no usable value at the selected signal_date (for example VIX is stale/NaN while ^VIX has a fresh row), _first_available_symbol stops at the stale column and the code never checks the later aliases or external context. In that scenario vix_level/vix_spike remain None, so the governor can miss VIX watch/crisis evidence and understate the de-risking score even though a configured VIX source is available.
Useful? React with 👍 / 👎.
|
Added a follow-up commit for versioned plugin contracts. Highlights:
Validation:
|
|
Update: broadened market_regime_control compatibility registration beyond TQQQ/SOXL to the weight-based rotation profiles now able to consume the unified artifact. README now states levered strategies consume direct position controls, while stock/ETF rotation strategies consume the same artifact through local risk-scaling policy and keep TACO notification-only.\n\nValidation: .venv/bin/python -m pytest tests/test_strategy_plugin_runner.py -q; ruff check touched runner/tests. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 886e20545e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| components, | ||
| strategy_policy=str(plugin_config.get("strategy_policy", "levered_growth_income_v1")).strip(), | ||
| taco_opportunity_size_scalar=float(plugin_config.get("taco_opportunity_size_scalar", 0.0) or 0.0), | ||
| as_of=str(plugin_config.get("as_of", "") or "").strip() or None, |
There was a problem hiding this comment.
Preserve component signal dates in the facade
When as_of is a non-trading day or newer than the latest usable prices, each component builder rolls back to the resolved signal_date, but passing the original requested value here forces the facade's top-level as_of (and dated artifact name) to that later date. Downstream freshness checks that look only at the unified artifact can treat stale or weekend evidence as current even though the component payloads are dated earlier; let the arbiter infer from component as_of values instead of overriding it with the request.
Useful? React with 👍 / 👎.
|
更新:补充了 Market Regime Control 统一插件方案文档。 本次新增:
方案摘要:
验证:
最新提交: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e68b8688d1
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| or taco_route == "taco_fake_crisis" | ||
| ) | ||
| ) | ||
| taco_watch = bool(isinstance(taco, Mapping) and _normalized_action(taco) == ACTION_WATCH_ONLY and not _blocked(taco)) |
There was a problem hiding this comment.
Do not turn unavailable TACO data into a watch route
When market_regime_control is mounted for a non-TQQQ strategy and the config omits taco_enabled or a matching attack_symbol, the runner still builds the TACO component by default; taco_rebound_shadow reports missing attack prices as suggested_action == "watch_only", not as blocked. This condition then promotes that unavailable component to taco_watch, so the unified artifact can emit a top-level watch notification every run even though there is no active TACO event or market-risk evidence. Gate this on real event/rebound context or treat TACO price-data suppression as unavailable for the facade.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5b2d774de6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| params["coed"] = str(end) | ||
| query = f"&{urlencode(params)}" if params else "" | ||
| frame = pd.read_csv(f"{FRED_GRAPH_URL.format(series_id=series_id)}{query}") | ||
| values = _clean_numeric_series(frame, date_column="observation_date", value_column=series_id) |
There was a problem hiding this comment.
Read the FRED graph CSV date column
When qsp-build-macro-external-context uses the default fetch_fred_series, FRED graph CSVs are parsed with a required observation_date column, but the public fredgraph.csv endpoint emits the date column as DATE. This makes every default FRED source raise during fetch and get recorded as status="error", so HY/IG OAS, financial stress, yield-curve, dollar, and funding fields are silently absent from the external context even though the CLI reports a completed output.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 75401d1f37
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| execution_controls["repository_allocation_mutation_allowed"] = False | ||
| if consumption_policy is not None: | ||
| execution_controls["notification_allowed"] = bool(consumption_policy.notification_allowed) | ||
| execution_controls["position_control_allowed"] = bool(consumption_policy.position_control_allowed) |
There was a problem hiding this comment.
Honor notification-only position policy
When market_regime_control runs under the market_regime_notification policy, this correctly records position_control_allowed = false in execution_controls, but the already-built payload["position_control"]["allowed"] remains true with live scalars from the facade. A consumer that reads the documented position_control block instead of the runner-specific execution_controls can therefore treat a notification-only artifact as an automated position-control signal; clear or disable that block whenever the consumption policy disallows position control.
Useful? React with 👍 / 👎.
Summary
Validation