Skip to content

[codex] fix managed portfolio equity#80

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

[codex] fix managed portfolio equity#80
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

  • Prefer cash plus filtered managed position value for portfolio total equity when strategy_symbols are configured.
  • Keep full account balance total for unfiltered account snapshots.
  • Add regression coverage showing managed snapshots ignore non-strategy holdings.

Root Cause

Firstrade balances can expose full-account value, which was preferred even after positions were filtered to managed symbols.

Validation

  • python3 -m py_compile application/runtime_broker_adapters.py
  • Lightweight adapter check with pandas/requests import stubs for managed and unmanaged equity behavior.
  • Full pytest was not run on this VPS because the environment is missing pandas and requests.

@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: 22415491a6

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

position_market_value: float,
prefer_cash_plus_positions: bool = False,
) -> tuple[float, str]:
resolved_cash = _positive_or_none(cash_balance)

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 Handle zero managed cash before using account totals

When a strategy-managed account is fully invested (cash_balance is reported as $0.00) and also has unmanaged holdings, _positive_or_none(cash_balance) makes resolved_cash None, so the new managed override is skipped and the later balance_total branch still returns the full account value. That reintroduces the exact sizing bug this change is trying to avoid for a common fully-invested portfolio: managed snapshots can include unmanaged holdings in total_equity instead of using the filtered position value (plus zero cash).

Useful? React with 👍 / 👎.

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