Skip to content

Support leveraged combo shadow runtime#299

Merged
Pigbibi merged 1 commit into
mainfrom
codex/combo-shadow-live-readiness
Jul 4, 2026
Merged

Support leveraged combo shadow runtime#299
Pigbibi merged 1 commit into
mainfrom
codex/combo-shadow-live-readiness

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add IBKR runtime support for direct market_data strategies, including us_equity_combo_leveraged SPY MA200 context construction.
  • Load explicit strategy config paths for non-snapshot strategies, enabling packaged shadow config dry-run.
  • Keep IBKR_STRATEGY_CONFIG_PATH optional in switch plans for the leveraged combo shadow path.

Safety

  • Does not enable live trading.
  • Intended shadow env keeps IBKR_DRY_RUN_ONLY=true and runtime target execution mode paper.

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.
  • Package config smoke verified risk-off target {'BOXX': 1.0}.

Co-Authored-By: Codex <noreply@openai.com>
@cursor

cursor Bot commented Jul 4, 2026

Copy link
Copy Markdown

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.

@Pigbibi Pigbibi enabled auto-merge (squash) July 4, 2026 13:14
@Pigbibi Pigbibi merged commit 0f87e46 into main Jul 4, 2026
2 checks passed
@Pigbibi Pigbibi deleted the codex/combo-shadow-live-readiness branch July 4, 2026 13:19

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread strategy_runtime.py
Comment on lines +653 to +658
managed_symbols = tuple(
dict.fromkeys(
str(position.symbol).strip().upper()
for position in decision.positions
if str(position.symbol or "").strip()
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +251 to +252
if config_source_policy == "env_only":
optional_env.append("IBKR_STRATEGY_CONFIG_PATH")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +269 to +273
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"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant