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

Concerning possible matching design flaw when losing events #2843

Open
juanigsrz opened this issue Mar 4, 2021 · 3 comments
Open

Concerning possible matching design flaw when losing events #2843

juanigsrz opened this issue Mar 4, 2021 · 3 comments

Comments

@juanigsrz
Copy link

The matching queue is configured with the setting clean_start: true. I assume this is because when initializing matching we load all wait orders and try to match them, and we do not have a straightforward way to know if a submit event in the queue corresponds to an already-loaded order or not, which might trigger processing an order twice.

Consider the following case:

  • Market maker publishes an order A, Peatio answers 201
  • matching crashes, starts restarting
  • Market maker cancels order A, Peatio answers 201
  • matching finishes restarting, purging its queue, deleting all cancel events
  • Market maker assumes it has no active orders
@martianatwork
Copy link

This is not a design flaw.
The market maker should listen for websocket events and then cancel the order from its memory.

When exchange replies 201 for orders api it means instruction received not executed.

@juanigsrz
Copy link
Author

This is not a design flaw.
The market maker should listen for websocket events and then cancel the order from its memory.

When exchange replies 201 for orders api it means instruction received not executed.

I understand that you may do a workaround by listening to the websocket, but note that the cancellation event has been lost and thus the order status will not be updated to cancel. You can only know about this situation and how to create a hacky workaround by understanding the underlying exchange implementation.

Second consideration, what exchange (or just any popular service in general) in the world asks you to implement a client for a RESTful API along with a websocket client to check if your request has actually been processed successfully?

@martianatwork
Copy link

I understand what you mean but don't expect any changes.

You should implement your own matching engine and use 2.6.

Crypto.com is the exchange that does this or at least it used to do this.

To cancel the order immediately you have to be using in memory trading engine to be effective.

We have developed our own implementation of this if you are interested.
Note: I'm not related to openware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants