Order Book
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.
Name | Quantity | Unit price in coins |
John | 100 | 800 |
Alice | 75 | 805 |
Chris | 150 | 810 |
Bob | 50 | 820 |
Deborah | 30 | 830 |
Name | Quantity | price |
Jamie | 50 | 820 |
Anna | 25 | 825 |
Clara | 100 | 835 |
Bill | 25 | 840 |
Daniel | 75 | 845 |
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.
Name | Quantity | Unit price in coins |
John | 100 | 800 |
Alice | 75 | 805 |
Chris | 150 | 810 |
Deborah | 30 | 830 |
Name | Quantity | price |
Anna | 25 | 825 |
Clara | 100 | 835 |
Bill | 25 | 840 |
Daniel | 75 | 845 |
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.
Name | Quantity | Unit price in coins |
John | 100 | 800 |
Alice | 75 | 805 |
Chris | 150 | 810 |
Deborah | 5 | 830 |
Name | Quantity | price |
Clara | 100 | 835 |
Bill | 25 | 840 |
Daniel | 75 | 845 |
An order book can be displayed as a market depth chart.
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.