Skip to content

Add OrderRemovedEvent for the orderbook stream#172

Open
markuspluna wants to merge 1 commit into
mainfrom
add-order-removed-event
Open

Add OrderRemovedEvent for the orderbook stream#172
markuspluna wants to merge 1 commit into
mainfrom
add-order-removed-event

Conversation

@markuspluna
Copy link
Copy Markdown
Member

Summary

tplus-core emits a Removed variant on /orders for every order that leaves the book — fully filled, canceled, GTD-expired, or rejected by the clearing engine (see tplus-core/messages/orderbook_messages/src/events/order_removed.rs). The Python order-event parser was missing this model, so each Removed event raised "Unknown order event type: Removed" inside BaseClient._stream_ws and was silently dropped — masking real order-removal state from downstream consumers.

This PR adds OrderRemovedEvent matching the Rust OrderRemoved struct field-for-field, registers it in _EVENT_TYPE_MODEL_MAP["REMOVED"], and includes it in the OrderEvent union.

reason is the OrderRemovalReason variant serialized as its name string ("Completed", "Canceled", "Expired", "Rejected").

Test plan

  • New tests in tests/model/test_order_events.py cover parse_order_event against both a fully-filled ("Completed") and a zero-fill ("Canceled") Removed payload — both pass.
  • Verified downstream against the tplus-integrations SDK consumer: 27 stream-orders tests pass after dropping the local _order_removed.py workaround that previously monkey-patched this same registration.

🤖 Generated with Claude Code

tplus-core emits a `Removed` variant on /orders for every order that
leaves the book (fully filled, canceled, GTD-expired, or rejected by
the clearing engine; see tplus-core
messages/orderbook_messages/src/events/order_removed.rs). The Python
order-event parser was missing this model, so each Removed event
raised "Unknown order event type: Removed" inside
BaseClient._stream_ws and was silently dropped — masking real
order-removal state from downstream consumers.

Field set matches the Rust OrderRemoved struct exactly: order_id,
asset_id, user_id, timestamp_ns, operator_pubkey, reason,
filled_quantity, filled_amount, confirmed_quantity, confirmed_amount,
book_quantity_decimals. `reason` is the OrderRemovalReason variant
serialized as its name string ("Completed", "Canceled", "Expired",
"Rejected").

Adds tests/model/test_order_events.py covering Removed parsing
through parse_order_event for both a fully-filled (Completed) and a
zero-fill (Canceled) shape.
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.

1 participant