Skip to content

Handle new status messages from 1051 TWS - #237

Open
chyunsu3 wants to merge 1 commit into
ib-api-reloaded:next-protobuffrom
chyunsu3:next-protobuf
Open

chyunsu3 wants to merge 1 commit into
ib-api-reloaded:next-protobuffrom
chyunsu3:next-protobuf

Conversation

@chyunsu3

@chyunsu3 chyunsu3 commented Oct 9, 2026 •

Copy link
Copy Markdown

TWS 1051 now emits new status messages:

  • Filled Size: 10
  • Cancelled by Trader
  • Cancelled by System:\nCancel parent on new cancelling order

I use ib_async every day and would like to say thank you for this great software.

@chyunsu3 chyunsu3 changed the title Handle new status messages from 1050 TWS Handle new status messages from 1051 TWS Oct 9, 2026
mattsta added a commit that referenced this pull request Oct 13, 2026
…ncelled

What: `OrderStatus.terminalFromCompleted` classifies the status a
completed-order replay reports: a plain `DoneStates` name passes
through, the descriptive text TWS 10.51 sends — `Filled Size: <n>` and
`Cancelled by <who>[:\n<reason>]` — maps to Filled / Cancelled, and
anything else returns None. `Wrapper.completedOrder` uses it and keeps
its Inactive-with-warning fallback for None. Any rewritten status still
logs the original text on the trade. Tests cover the classifier table,
the wire shape (text in `completedStatus`, `status` empty), and the
completed echo terminalizing a trade already seen live.

Why: on TWS 10.51 `completedStatus` carries text instead of the status
names IBKR documents for it, and `status` stays empty on that path, so
none of it matched a terminal state. Every filled or cancelled order
from `reqCompletedOrders` came back as Inactive with a "non-terminal
status" warning, leaving fills and cancels indistinguishable. The
trades stayed out of `openTrades()`, but their reported outcome was
wrong.

How: the phrasing knowledge lives in one table beside the status
vocabulary, not inline in the wrapper, so the next phrasing IBKR
introduces is a one-line, separately testable addition. Only phrasings
observed on the wire are mapped. Unknown text still falls back to
Inactive, so a future wording change degrades the way it did before
instead of being guessed. `Filled Size` also accepts fractional and
comma-grouped sizes, which can only mean a fill. Based on Hyunsu Cho's
report and fix in #237. That version matched the text inline; this one
moves it into OrderStatus and tests the field the text actually
arrives in.

Closes #237.

Co-Authored-By: Hyunsu Cho <chohyu01@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mattsta

mattsta commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

Interesting find! Thanks for tracking that down so we can use more "actual meaning status details" for status reporting instead of less detailed "status fields" themselves.

I had this refactored a bit for just common platform structure. It'll be in the next major release here which will have to be soon because IBKR is moving to 10.51+ required by end of year.

This branch has not been deployed

No deployments
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.

2 participants