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

Add pendingmatch flag to orderbook query response #714

Merged
merged 1 commit into from
Apr 22, 2020

Conversation

EnderCrypto
Copy link
Contributor

@EnderCrypto EnderCrypto commented Apr 7, 2020

Description

Prevent cross order
Meanwhile, need merge https://github.com/binance-chain/http-ap/pull/85 and bnb-chain/go-sdk#110 with this change

Rationale

Here is an example of crossed price levels in websocket depth:
After BeginBlock of height 101, the round order (sell, price=3,quantity=5) was inserted into order book. Websocket queried node depth API and the response included this order. and then an order (buy price=3,quantity=9) was also inserted into order book. After matching, in the endblock the remaining price level (buy, price=3,quantity=4) was published to websocket as delta. However, the price level (sell, price=3,quantity=5) still stayed in websocket depth cache, hence the crossed order (buy, 3,5) and (sell, 3,4) received by websocket subscriber. The price level (buy, 3,5) actually doesn’t exist in the real order book.

Solution:

Add a boolean flag “pending_match” in node depth API response to indicate the case of unmatched round orders in order book.
If len(roundOrders[symbol])>0, “pending_match” = true. The drawback is for mini-tokens, the roundOrders will be kept for several blocks until match, and hence the client has a lower chance to get order book with pending_match=false.

The client (websocket-ap) will discard this query result when pendingMatch is true.

Example

RUN TestGetDepth
{"Height":2644,"Levels":[{"buyQty":"0.00000000","buyPrice":"0.00000000","sellQty":"0.00000000","sellPrice":"0.00000000"},{"buyQty":"0.00000000","buyPrice":"0.00000000","sellQty":"0.00000000","sellPrice":"0.00000000"}],"PendingMatch":true}

Changes

Notable changes:

  • Add a bool flag pending_match in orderbook API

Preflight checks

  • build passed (make build)
  • tests passed (make test)
  • integration tests passed (make integration_test)
  • manual transaction test passed (cli invoke)

Already reviewed by

...

Related issues

@EnderCrypto EnderCrypto merged commit b64de8b into develop Apr 22, 2020
@EnderCrypto EnderCrypto changed the title add pendingmatch flag Add pendingmatch flag to orderbook query response Jun 2, 2020
@EnderCrypto EnderCrypto mentioned this pull request Jun 2, 2020
@unclezoro unclezoro deleted the pending_match_flag branch May 10, 2022 06:11
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.

None yet

3 participants