[codex] fix strategy total equity filtering#91
Conversation
There was a problem hiding this comment.
💡 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()) |
There was a problem hiding this comment.
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 👍 / 👎.
Summary
total_strategy_equityas strategy-symbol market value plus liquid cash whenstrategy_symbolsare supplied.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_orderpython3 -m py_compile src/quant_platform_kit/common/runtime_inputs.py