Handle zero-equity Firstrade strategy runs#61
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: be3beb5128
ℹ️ 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".
| balance_total = _positive_or_none( | ||
| _first_numeric_by_keyword_groups(balances, _TOTAL_EQUITY_KEYWORD_GROUPS) | ||
| ) |
There was a problem hiding this comment.
Preserve explicit non-positive account equity
When Firstrade returns an authoritative non-positive total/account value, such as a margin-deficit balance formatted as ($50.00), _positive_or_none treats it as missing and falls through to cash/position fallbacks. If the positions endpoint still reports positive market values, the snapshot becomes positive and weight targets can be translated and executed instead of hitting the total_equity <= 0 no-execute guard. Only absent/unparseable totals should fall back; parsed <= 0 totals should be preserved so the execution block remains effective.
Useful? React with 👍 / 👎.
Summary
Tests