Order Book

Published by Mario Oettler on

An order book is a list of pending buy and sell orders for securities or tokens. The bids are cumulated by price level and quantity. Every time a buy or sell order arrives, it is added to the order book. If an order got fulfilled, it is removed from the order book.

The following tables show an example of an order book. The first table shows the buy orders, whereas the second table shows the sell orders.

NameQuantityUnit price in coins
John100800
Alice75805
Chris150810
Bob50820
Deborah30830
Buy orders (bid)

NameQuantityprice
Jamie50820
Anna25825
Clara100835
Bill25840
Daniel75845
Sell orders (ask)

Bob wants to buy 50 tokens for 820 coins each. Jamie wants to sell 50 tokens for 820 coins each. Bob and Jamie can trade with each other. Their positions are removed from the order book.

NameQuantityUnit price in coins
John100800
Alice75805
Chris150810
Deborah30830
Buy orders (bid)

NameQuantityprice
Anna25825
Clara100835
Bill25840
Daniel75845
Sell orders (ask)

Now, Deborah wants to buy 30 tokens for a unit price of 830 and Anna is willing to sell 25 tokens for 825. There are two things to notice here. First, we have a bid-ask spread. This gives the market organizer some price range to find the final price. It could lie somewhere between 825 and 830 coins.

Second, Deborah wants to buy 30 tokens, but Anna only offers 25. This means that the order cannot be fulfilled completely. If Deborah placed an all-or-none order, the trade would be cancelled. But if she places a normal order, she would receive 25 tokens. Anna’s order would be fulfilled and removed. Deborah’s order would be changed to a quantity of 5. The order book would then look like that.

NameQuantityUnit price in coins
John100800
Alice75805
Chris150810
Deborah5830
Buy orders (bid)

NameQuantityprice
Clara100835
Bill25840
Daniel75845
Sell orders (ask)

An order book can be displayed as a market depth chart.

Market depth chart. Left (green) buy orders and right (red) sell orders.

Order books work well in high liquidity markets. Each trader has to wait until a matching buyer or seller occurs. If the market is not very vibrant, it can take very long until a matching buyer and seller pair is found. In small markets with only a few traders, the order book mechanism doesn’t work very well.

The advantage of order books is that the slippage is low. Order books are also prone to manipulation like wash trading (creating artificial activity), pump and dump, and frontrunning. Such behavior is usually punished in traditional, centralized exchanges. But in a decentralized environment where actors are anonymous, this is difficult. For these reasons, order books are not the first choice for decentralized exchanges.

Categories:

if()