Add OrderRemovedEvent for the orderbook stream#172
Open
markuspluna wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tplus-core emits a
Removedvariant on/ordersfor every order that leaves the book — fully filled, canceled, GTD-expired, or rejected by the clearing engine (seetplus-core/messages/orderbook_messages/src/events/order_removed.rs). The Python order-event parser was missing this model, so eachRemovedevent raised"Unknown order event type: Removed"insideBaseClient._stream_wsand was silently dropped — masking real order-removal state from downstream consumers.This PR adds
OrderRemovedEventmatching the RustOrderRemovedstruct field-for-field, registers it in_EVENT_TYPE_MODEL_MAP["REMOVED"], and includes it in theOrderEventunion.reasonis theOrderRemovalReasonvariant serialized as its name string ("Completed","Canceled","Expired","Rejected").Test plan
tests/model/test_order_events.pycoverparse_order_eventagainst both a fully-filled ("Completed") and a zero-fill ("Canceled") Removed payload — both pass.tplus-integrationsSDK consumer: 27 stream-orders tests pass after dropping the local_order_removed.pyworkaround that previously monkey-patched this same registration.🤖 Generated with Claude Code