Commit Graph

1 Commits (e02a6431e3ff57cb6f27c82c79405c05c3243ad8)

Author SHA1 Message Date
Gud Boi dae575e1b5 Preserve IB order state through notices and late fills
IB's 10349 TIF-preset notice made `ib_async` synthesize a
`Cancelled` status for an order which subsequently filled. EMS
then discarded its `Order`, recreated `Error(req=None)` for the
separate error callback, and crashed while routing the fill.

Treat 2181 (unsupported SmartRouting opt-out) and 10349 (preset
sets TIF to DAY) as notices: preserve diagnostic callbacks without
manufacturing order failures or relaying them as `BrokerdError`.
Leave actual cancellation handling, including code 202, intact.

Also,
- snapshot `ib_async.Trade` order/status fields and its fill list
  at callback time so queued events cannot observe later state;
- retain canceled/closed dialogs in `DarkBook._closed` while the
  order-ID mapping exists, keeping `Order.symbol` for late-fill
  routing and `Order.account` for commands after a reopen;
- keep late errors out of `_active` and reactivate retained dialogs
  only on a subsequent pending/open status;
- cover cancel/close/error/fill sequences, continued msg handling,
  callback snapshots and notice-vs-cancellation behavior offline.

Explain the `ib_async.wrapper.Wrapper.error()` state mutations
apart from EMS request retention; name the retained request fields
needed by client routing and reopened dialogs.

Human-tested live/dark fills and order cancellation on an IB paper
Gateway. Exact-tree offline checks are retained in the commit plan.

(this patch was generated in some part by `opencode` using
`gpt-6.1-sol` (`openai`))
2026-10-30 18:50:06 -04:00