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

change price check in matching engine to match if longOrder price >= … #13

Merged
merged 5 commits into from
Jan 19, 2023

Conversation

vipulsharma21
Copy link

@vipulsharma21 vipulsharma21 commented Jan 18, 2023

Why this should be merged

In Matching engine the condition for matching long and short order was that they should have same price. We want to allow orders to match if longOrder.Price >= shortOrder.Price.
As longOrders are sorted by price from high to low and shortOrders are sorted by price from low to high
If price check conditions fails anytime it does not makes sense to run further iterations, so i also added logic to exit loop in that case.

How this works

Changed the price check from longOrder.Price == shortOrder.Price to longOrder.Price >= shortOrder.Price
also exit loop if condition(longOrder.Price >= shortOrder.Price ) fails.

How this was tested

I have updated unit tests which test this.

@lumos42 lumos42 merged commit 0cc71e2 into hubble-v2 Jan 19, 2023
@atvanguard atvanguard deleted the order_matching_better_price branch January 19, 2023 15:24
atvanguard added a commit that referenced this pull request Sep 30, 2023
#13)

* change price check in matching engine to match if longOrder price >= shortOrder price

* more aggresive assertions

* Add tests for getUnFilledBaseAssetQuantity

* refactor TestGetUnfilledBaseAssetQuantity

* refactor RunMatchingEngine in limit_order and add tests

Co-authored-by: atvanguard <3612498+atvanguard@users.noreply.github.com>
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.

3 participants