Add shared cash sweep whole-share helper#41
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4e9f95225
ℹ️ 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".
| for underweight_value, ask_price in funding_needs: | ||
| _ = underweight_value | ||
| quote_price = float(ask_price or 0.0) |
There was a problem hiding this comment.
Honor underweight when deciding whole-share sweep sale
should_sell_cash_sweep_to_fund_whole_share_buy ignores underweight_value, so it can return True even when no symbol has enough underweight for a whole share (for example, underweight < ask_price). In that case we may sell the full cash-sweep position even though no corresponding buy can be placed, which creates unnecessary churn and leaves cash idle. This differs from estimate_cash_sweep_sale_quantity_to_fund_buy, which explicitly skips entries where underweight_value cannot fund at least one share.
Useful? React with 👍 / 👎.
Add a shared helper that decides cash-sweep sells only when selling the full safe-haven position can fund at least one whole-share buy.\n\nValidation:\n- pytest tests/test_cash_sweep.py -q\n- py_compile on touched files