Add fill-aware order status helpers - #216
Conversation
Co-Authored-By: Codex <noreply@openai.com>
🤖 Codex PR Review🚫 Merge blocked: 2 serious issue(s) found in high-risk files ⚖️ Codex Review Arbitration🚫 block: At least one blocking finding remains valid, in fact both do. First, 🚫 Blocking IssuesThese issues must be fixed before this PR can be merged: 1. 🟠 [HIGH] Logic in
|
Co-Authored-By: Codex <noreply@openai.com>
Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a10f4c76e7
ℹ️ 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".
| "filledShares", | ||
| "executedShares", | ||
| "quantityFilled", | ||
| "quantity", |
There was a problem hiding this comment.
Do not treat submitted quantities as fills
When a status lookup is unavailable or a broker payload includes submitted quantity before/without true fill fields, this fallback normalizes the order size as executed_qty (and the price fallbacks below can similarly use submitted/limit price). Since compute_confirmed_sell_release_value accepts any positive executed quantity even for non-fill statuses, an accepted/working sell order dict such as quantity=8, limit_price=100 releases $800 before any fill is confirmed, which can make buy-after-sell flows overspend.
Useful? React with 👍 / 👎.
| return None | ||
| if order_status_context is not None: | ||
| try: | ||
| return fetch_order_status(order_status_context, broker_order_id) |
There was a problem hiding this comment.
Support Schwab's two-part status context
The shared helper only calls contextual fetchers as fetch_order_status(order_status_context, broker_order_id), but the Schwab fetcher added in this commit is fetch_order_status(api_client, account_hash, order_id) in src/quant_platform_kit/schwab/execution.py. Passing (api_client, account_hash) as the context therefore raises TypeError and then falls through to the one-arg call, so compute_confirmed_sell_release_value cannot use the new Schwab lookup without every caller writing a custom adapter.
Useful? React with 👍 / 👎.
| if isinstance(order, ExecutionReport): | ||
| return str(order.broker_order_id or "").strip() | ||
| if isinstance(order, Mapping): | ||
| direct = str(order.get("broker_order_id") or "").strip() |
There was a problem hiding this comment.
Resolve raw broker order IDs before fetching
If callers pass a raw broker order mapping that uses the supported orderId/orderNo fields instead of the normalized broker_order_id, this resolver returns an empty ID and the supplied status fetcher is never called. In that scenario a sell order submitted as {"orderId": "OID-1", "status": "accepted"} will keep using the stale local payload and miss later fills even though normalize_order_status_payload already knows how to extract the broker order ID from those fields.
Useful? React with 👍 / 👎.
Co-Authored-By: Codex <noreply@openai.com>
Summary
get_orderTesting