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

feat: Rewrite order matching strategy #2539

Closed
wants to merge 6 commits into from

Commits on Jun 7, 2024

  1. chore: Add order id to trades

    This will allow us to implement partial order matching, by summing the quantity of trades related to an order.
    holzeis committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    00a9b35 View commit details
    Browse the repository at this point in the history
  2. chore: Remove delete expired orders

    This is already done by the maker, also expired orders are not considered for matching.
    holzeis committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    8ca29e4 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    8cf4dae View commit details
    Browse the repository at this point in the history
  4. feat: Rewrite order matching strategy

    Refactors the current trading component into a clearly separated orderbook component and a trade execution component. The linking part is the `ExecutableMatch` which can be derived from the matches stored into the database.
    
    At the moment we assume optimistically that the trade execution will succeed. However, we should consider that a pending match may never get filled or it fails at execution in such a scenario we would need to rollback the matched orders.
    holzeis committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    f0cae92 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    37a7a73 View commit details
    Browse the repository at this point in the history
  6. fix: Drop foreign key constraint on order id

    The order and the matches are persisted by async actors. It can happen that the market order has not yet been persisted when the match is processed.
    
    Thus it could happen that the matches table is persisted before the order has been persisted, which resulted in a foreign key violation. By dropping the foreign key we don't care if the order is already persisted and can continue with eventual consistency.
    
    I think this is the better option than to synchronize the two inserts as we are anyways aiming for decoupling the orderbook from the coordinator.
    holzeis committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    51e49ec View commit details
    Browse the repository at this point in the history