-
Notifications
You must be signed in to change notification settings - Fork 44
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
[WIP]: fix(orderbook): fully remove matched own orders #1557
Conversation
33cf3bc
to
a8ffe79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sangaman can u please update this branch from master? It is pretty old version of xud)
The `ownOrder.swapped` event was not being listened to or used.
This ensures that orders that are internally matched get fully removed from the order book. Previously, internally matched orders would be removed from the trading pair queues but not from the global order book mapping between local order ids and global order ids. The `TradingPair` class now acts as an event emitter to notify its parent `OrderBook` when orders are matched and whether they were matched fully, with no remaining quantity or hold. Previously the `OrderBook` received a list of matches when calling the `match` method but wasn't aware when orders were fully matched. Fixes #1556.
a8ffe79
to
39f60d7
Compare
@raladev Done, but the sim test are still failing so this will need some more attention after other priorities are taken care of. |
This needs some rebasing and isn't a priority but I still think is relevant, so I'm moving it to draft status for now. |
I'm closing this since it is old and no longer worth rebasing but open a new PR soon that attempts to solve the same underlying issue. |
This ensures that orders that are internally matched get fully removed from the order book. Previously, internally matched orders would be removed from the trading pair queues but not from the global order book mapping between local order ids and global order ids.
The
TradingPair
class now acts as an event emitter to notify its parentOrderBook
when orders are matched and whether they were matched fully, with no remaining quantity or hold. Previously theOrderBook
received a list of matches when calling thematch
method but wasn't aware when orders were fully matched.Fixes #1556.
Some follow-ups that came to mind while investigating/working on this include:
Change the
hold
vsquantity
convention so thatquantity
only refers to the quantity available at that exact moment, excluding holds. In other words adding tohold
would involve subtracting fromquantity
. There are a few parts where this would make the code and matching routine simpler, and it seems more intuitive to me after thinking through it some.Further investigate a potential bug where if the best available order is completely on hold, matching will immediately stop and not go to the next best orders. This is due to encountering no "matching quantity" with this best order, and is partly related to the bullet point above.