The order book represents open (i.e. not yet executed, not cancelled) limit orders. It does not include:
-
market orders since they are executed immediately.
-
stop loss orders: before triggering, they are not in the book.
-
hidden orders e.g. iceberg orders where only the successive small orders are seen when executed.
Fetching
To fetch the order book, we need 2 things:
-
a websocket that listens real time events -> some events can be missed
-
a snapshot that gives the complete order book -> can be outdated
To make sure that we don’t miss any event, a first check can be made: