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

[WIP]: fix(orderbook): fully remove matched own orders #1557

Closed
wants to merge 2 commits into from

Conversation

sangaman
Copy link
Collaborator

@sangaman sangaman commented May 14, 2020

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.

Some follow-ups that came to mind while investigating/working on this include:

  • Change the hold vs quantity convention so that quantity only refers to the quantity available at that exact moment, excluding holds. In other words adding to hold would involve subtracting from quantity. 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.

@sangaman sangaman added bug Something isn't working order book labels May 14, 2020
@sangaman sangaman self-assigned this May 14, 2020
@kilrau
Copy link
Contributor

kilrau commented May 14, 2020

since the bug is relatively minor (and doesn't affect swapping with peers)

I agree and think we can leave this in draft state for now. We have more urgent things to get done:
#1472
#1473

@ghost ghost self-requested a review May 14, 2020 13:42
@ghost ghost changed the title fix(orderbook): fully remove matched own orders [WIP]: fix(orderbook): fully remove matched own orders Jun 5, 2020
@kilrau kilrau requested a review from raladev June 12, 2020 17:34
@kilrau kilrau added the P2 mid priority label Jun 12, 2020
Copy link
Contributor

@raladev raladev left a 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.
@sangaman
Copy link
Collaborator Author

@raladev Done, but the sim test are still failing so this will need some more attention after other priorities are taken care of.

@sangaman
Copy link
Collaborator Author

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.

@sangaman
Copy link
Collaborator Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working order book P2 mid priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ALREADY_EXISTS error for id of maker order after self-match
3 participants