Support leveraged combo shadow runtime#299
Conversation
Co-Authored-By: Codex <noreply@openai.com>
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8f1601dec4
ℹ️ 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".
| managed_symbols = tuple( | ||
| dict.fromkeys( | ||
| str(position.symbol).strip().upper() | ||
| for position in decision.positions | ||
| if str(position.symbol or "").strip() | ||
| ) |
There was a problem hiding this comment.
Preserve the full managed universe for risk-off targets
When the leveraged combo is risk-off and the strategy returns only the safe-haven target (for example BOXX: 1.0), deriving managed_symbols solely from decision.positions records the managed universe as just BOXX. Downstream decision_mapper.map_strategy_decision builds allocation metadata from the same target-only positions, and application/rebalance_service._strategy_portfolio_view filters current positions by that universe before execution, so existing TQQQ/SOXL holdings can be excluded from the sell calculation instead of being liquidated to BOXX.
Useful? React with 👍 / 👎.
| if config_source_policy == "env_only": | ||
| optional_env.append("IBKR_STRATEGY_CONFIG_PATH") |
There was a problem hiding this comment.
Remove stale strategy configs when no override is supplied
For non-snapshot env_only profiles this keeps IBKR_STRATEGY_CONFIG_PATH as optional instead of removing it, so a service that previously had the shadow package config set and is later switched with the default plan keeps using that value. Since strategy_runtime.py now loads runtime parameters whenever runtime_settings.strategy_config_path is non-empty, the supposedly canonical runtime can continue to run the old shadow weights unless the operator explicitly replaces the path.
Useful? React with 👍 / 👎.
| if definition.profile == "us_equity_combo_leveraged": | ||
| hints["shadow_352045_strategy_config_path"] = ( | ||
| "package://us_equity_strategies/configs/" | ||
| "us_equity_combo_leveraged_shadow_352045.json" | ||
| ) |
There was a problem hiding this comment.
Point the shadow hint at a packaged config that exists
This hint tells operators to set IBKR_STRATEGY_CONFIG_PATH to package://us_equity_strategies/configs/us_equity_combo_leveraged_shadow_352045.json, but that file is not present in the us-equity-strategies revision pinned by this repo. In the shadow dry-run path described by the commit, following the generated plan therefore gives the runtime a config URI that the strategy parameter loader cannot open, instead of enabling the packaged shadow config.
Useful? React with 👍 / 👎.
Summary
market_datastrategies, includingus_equity_combo_leveragedSPY MA200 context construction.IBKR_STRATEGY_CONFIG_PATHoptional in switch plans for the leveraged combo shadow path.Safety
IBKR_DRY_RUN_ONLY=trueand runtime target execution modepaper.Validation
PYTHONPATH=.:../UsEquityStrategies/src:../HkEquityStrategies/src:../QuantPlatformKit/src python3 -m pytest tests/test_strategy_runtime.py tests/test_runtime_config_support.py -q-> 92 passed.python3 -m ruff check strategy_runtime.py scripts/print_strategy_switch_env_plan.py tests/test_strategy_runtime.py tests/test_runtime_config_support.py-> passed.{'BOXX': 1.0}.