Skip to content

[codex] filter IBKR strategy portfolio equity#156

Merged
Pigbibi merged 1 commit into
mainfrom
codex/fix-strategy-total-equity
Jun 10, 2026
Merged

[codex] filter IBKR strategy portfolio equity#156
Pigbibi merged 1 commit into
mainfrom
codex/fix-strategy-total-equity

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Project IBKR portfolio snapshots to configured strategy symbols before strategy evaluation.
  • Filter dashboard and execution account values to strategy positions plus buying power.
  • Add a local total-equity override so the platform is protected even before the shared kit pin advances.

Root Cause

IBKR account snapshots use broker account net liquidation, so non-strategy positions could inflate strategy logs, notifications, and value-target inputs.

Validation

  • python3 -m py_compile application/rebalance_service.py strategy_runtime.py
  • Lightweight direct checks for _strategy_portfolio_view and projected PortfolioSnapshot equity.

@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: ae8394f95d

ℹ️ 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 on lines +545 to +552
strategy_market_value = sum(
float(details.get("quantity") or 0.0) * float(details.get("avg_cost") or 0.0)
for details in filtered_positions.values()
)
buying_power = float(dict(account_values or {}).get("buying_power") or 0.0)
filtered_account_values = {
**dict(account_values or {}),
"equity": buying_power + strategy_market_value,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Base projected equity on market value, not cost basis

For accounts that already hold any strategy symbol whose current price differs from its average cost, this projection changes account_values["equity"] from broker net liquidation to buying power plus cost basis (quantity * avg_cost). execute_rebalance then sizes targets from this equity while valuing current holdings with live quotes, so appreciated positions can be under-targeted and depreciated positions over-targeted even when the account contains only strategy positions. The projection needs to carry/use actual market value from the portfolio snapshot or quote the filtered symbols rather than using average cost.

Useful? React with 👍 / 👎.

@Pigbibi Pigbibi merged commit 332ea32 into main Jun 10, 2026
1 check passed
@Pigbibi Pigbibi deleted the codex/fix-strategy-total-equity branch June 10, 2026 20:18
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