Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement processing of market-to-limit orders in matching engine #2354

Merged

Conversation

filipmacek
Copy link
Member

@filipmacek filipmacek commented Feb 24, 2025

Pull Request

  • implemented function process_market_to_limit_order in OrderMatchingEngine and tested
  • removed PartiallyFilled variant in OrderEventAny
  • To account for valid scenario when processing market to limit orders, and correct sequence of emmited events:

Sequence of emmited events

  1. OrderUpdated - order was updated to new limit price where market order stopped filling
  2. OrderFilled - market order which was filled emits filled event
  3. OrderAccepted - remaining quantity of market order is accepted as limit order in the book

To account for this scenarios, two new order state transitions were aded:

  • (Self::Submitted, OrderEventAny::Updated(_)) => Self::Submitted order is submitted and we are first updating new limit price, order state after this event stays Submitted (we didnt fill it or accept it in the orderbook)
  • (Self::PartiallyFilled, OrderEventAny::Accepted(_)) => Self::Accepted - partially filling the order, after market fill, we are leaving it in the book and accepting it

@filipmacek filipmacek added the rust Relating to the Rust core label Feb 24, 2025
@filipmacek filipmacek self-assigned this Feb 24, 2025
@filipmacek filipmacek force-pushed the order-matching-engine-processing-market-to-limit-order branch 2 times, most recently from 963c03c to e6cb96f Compare February 25, 2025 13:37
@filipmacek filipmacek force-pushed the order-matching-engine-processing-market-to-limit-order branch from e6cb96f to 19d7391 Compare February 25, 2025 14:07
@cjdsellers cjdsellers merged commit 609fad1 into develop Feb 25, 2025
13 checks passed
@cjdsellers cjdsellers deleted the order-matching-engine-processing-market-to-limit-order branch February 25, 2025 20:46
Copy link
Member

@cjdsellers cjdsellers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Relating to the Rust core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants