Skip to content

[codex] fix strategy total equity filtering#91

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

[codex] fix strategy total equity filtering#91
Pigbibi merged 1 commit into
mainfrom
codex/fix-strategy-total-equity

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Compute total_strategy_equity as strategy-symbol market value plus liquid cash when strategy_symbols are supplied.
  • Preserve full snapshot equity when no strategy symbol filter is configured.
  • Add regression coverage for filtered and unfiltered account-state conversion.

Root Cause

Filtered account state still copied broker snapshot.total_equity, so non-strategy holdings could leak into strategy logs and notifications.

Validation

  • PYTHONPATH=src python3 -m unittest tests.test_strategy_contracts.StrategyContractMigrationTests.test_build_account_state_from_portfolio_snapshot_filters_strategy_symbols tests.test_strategy_contracts.StrategyContractMigrationTests.test_build_account_state_without_strategy_symbols_preserves_snapshot_equity tests.test_strategy_contracts.StrategyContractMigrationTests.test_build_portfolio_snapshot_from_account_state_keeps_strategy_symbol_order
  • python3 -m py_compile src/quant_platform_kit/common/runtime_inputs.py

@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: 2098bf9de6

ℹ️ 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".

resolved_liquid_cash = 0.0

total_strategy_equity = (
float(resolved_liquid_cash) + sum(float(value) for value in market_values.values())

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 Include all duplicate strategy positions in equity

When a filtered snapshot contains more than one Position for the same strategy symbol, this sums market_values after the loop above has overwritten earlier rows for that symbol. That can happen with the IBKR snapshot path when multiple selected accounts hold the same ticker (fetch_portfolio_snapshot appends per-account positions while summing account values), so total_strategy_equity will include only the last account's holding plus cash and understate the strategy equity. Sum the matching positions directly or aggregate duplicate symbols before computing this value.

Useful? React with 👍 / 👎.

@Pigbibi Pigbibi merged commit ac9277c 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