Order book specifics

Hi there. I’m not very experienced in Binance API, so I’ve got couples of questions about ‘order book’ web service. I’ll be glad to get exhaustive answers.

  1. The ‘/api/v3/depth’ return a list of buy/sell orders from actual order book. But single item (buy/sell order) does not have any individual identification number. So how to distinguish old orders from new ones? Is JSON message keeps the orders sorted (in some way)? For example by time created?

  2. The service has a limit of 5000 orders to show in the one JSON message. Is this mean that the oldest orders which exceeds list of 5000 items will not be shown? This question is linked to the first one.

  3. For how long one particular order can be active (and visible in order book) if it is not completed because of (for example) ridiculous price?

  4. The service has this unique identification value ‘LAST UPDATE ID’ dedicated whole message. I was wandering is this value changes after every (even smallest) change in order book? For example only one order is cancelled/completed/added. Or maybe there is a minimal time interval after which new ‘LAST UPDATE ID’ is assigned?

Hi,

  1. The orders returned by the /api/v3/depth endpoint are typically sorted by price and timestamp. The order book represents the current state of the market, with newer orders appearing at the top of the list. By comparing the timestamp of the orders, you can determine the relative age of each order.
  2. The limit of 5000 orders in a single JSON message means that if there are more than 5000 orders in the order book, the API will only return the most recent 5000 orders. The older orders that exceed this limit will not be included in the response. Therefore, if you rely solely on the /api/v3/depth endpoint, you may not have access to the complete order book.
  3. It depends on what you put for the timeInForce parameter. GTC for example stands for GoodTilCancelled meaning it will remain on the orderbook until it is either filled or cancelled manually. Whereas IOC (ImmediateOrCancel) must either be filled immediately or otherwise it will be cancelled and removed.
  4. The “LAST UPDATE ID” provided in the order book message represents the last update that occurred in the order book. It is not a unique identification value for individual orders. The “LAST UPDATE ID” changes whenever there is even a small change in the order book, such as an order being added, canceled, or updated.

Hope that helps.

One clarification: /api/v3/depth does not return individual orders, but rather total volume of outstanding orders at a particular price.

That is, when /api/v3/depth?symbol=BTCUSDT&limit=2 returns

{
  "lastUpdateId": 19724300,
  "bids": [
    [
      "31271.87000000",
      "0.02552900"
    ],
    [
      "31270.84000000",
      "0.06395800"
    ]
  ],
  "asks": [
    [
      "31272.02000000",
      "0.00267600"
    ],
    [
      "31272.07000000",
      "0.08474100"
    ]
  ]
}

The ask 31272.02000000 for 0.00267600 means that for the price 31272.02 USDT the total volume of orders is 0.002676 BTC. There could be 1 order for 0.002676 BTC, or 4 orders for 0.000669, or any other combination. It is not possible to see individual orders.

/api/v3/depth is ordered by price, from best to worst. That is, bids are ordered from the highest price to lowest, asks are ordered from the lowest price to highest.

Thank you guys so match for your answers. Now it is much more understandable how it really works. Cheers!