order book trading stocks

Order book – trading stocks and other securities

We know that a key feature of markets is that they bring buyers and sellers together. Markets facilitate trades between these two parties. One method markets can use to match buyers and sellers is through an order book. And, this is the topic of this post.

Learning objectives

  • Define what an order book is within the context of trading.
  • Understand the key features of order books such as the top of the book and the bid-ask spread.

How does an order book work?

An order book for trading a stock or another security is simply a list of orders submitted by potential buyers and sellers. We show an example in the table below. Imagine that this is for a particular stock and that you would like to buy 2,000 shares of that stock. In this case, the best ask price available to you based on limit orders submitted by sellers is £12.18. However, there are only 1,010 shares on offer at this price. If you submitted a market order for 2,000, you would expect to get 1,010 shares at £12,18. While the rest of your order (i.e., 990 shares) would be filled at £12,19.

What if you own 1,000 shares and want to sell them all? This time, you have to focus on limit orders submitted by traders who want to buy. The best bid price is £12.15. And, you can expect to sell all of your shares for £12.15. This is because the amount of shares available at this price (7,940) exceeds the amount you want to sell (1,000).

Buy ordersSell orders
Bid priceQuantityAsk priceQuantity

Top of the book and the bid-ask spread

The highest bid price and the lowest ask price constitute the top of the book. These are the best prices available to traders within the order book. Furthermore, we call the difference between the best bid and the best ask as the bid-ask spread. The bid-ask spread is an important measure of liquidity. The lower the bid-ask spread, the more liquid the market is. Why? Imagine that you buy 1,000 shares at the best ask price of £12.18. This costs you £12,180. Now, you immediately sell these shares at the bid price of £12.15. This earns you £12,150. Your net payoff from these two transactions is £12,150 − £12,180 = −£30. If the bid-ask spread was narrower (wider), your loss would be less (more). That is why a low bid-ask spread is desirable from a liquidity perspective.

The order book depth

The order book depth is positively related to the quantities offered at different prices. In particular, an order book could be considered as deep if there are large quantities of buy and sell orders on offer, especially not too far from the top of the book. If we revisit our example, there are 7,940 shares on offer at the best bid, whereas there are only 1,010 shares available at the best ask. This means that there is more depth at the best bid compared to the best ask.

Like the bid-ask spread, the order book depth is a dimension of liquidity. In particular, we can consider deeper markets as more liquid. When a market is not deep, the execution of large market orders becomes problematic. This is because the price could move substantially away from the top of the book in order to fill such orders. Naturally, that is not desirable from the point of view of the traders who submit those orders.


A related concept is slippage. This occurs, for example, when you submit a market order but the bid-ask spread moves before your order is executed. As a result, your order is filled at a price different than what you anticipated. For example, you submit a market buy order of 1,000 shares. Looking at the table above, you would expect that this trade would be executed at £12.18 as there is enough depth to cover your order at this price. What if another market order buy order of 500 shares beats you by a millisecond and is executed first? Well, now there would only be 1,010 – 500 = 510 shares left on offer at £12.18. Consequently, the rest of your order (490 shares) would be filled at £12.19, which is slightly worse. This is negative slippage as the best ask moved in a direction that is less favorable to you.

You could sometimes experience positive slippage as well. Suppose now a limit sell order of 800 shares at £12.17 arrives just before your market order is executed. This limit order suddenly becomes the best ask. So, you would pay slightly less (£12.17) for part of your order (800 shares). The rest of your order (200 shares) would still be filled at the price you anticipated when you submitted the market order (£12.18), though.

Wrapping up

It is important for traders to realize the dynamic nature of an order book. That is, when the market is open, buy and sell orders would keep arriving at the order book. Market orders, which demand liquidity, would be matched against existing limit orders on the book. On the other hand, limit orders, which supply liquidity, would add to the depth of the book. Moreover, in the process, the top of the book would keep moving. The bid-ask spread would continuously shift as well, expanding (contracting) when there is more (less) liquidity in the market. You can watch the animation to see how the order book evolves over time as orders keep coming. The horizontal (vertical) axis is the price (quantity). The green section represents buy orders and the red one shows sell orders. The gap in between is the bid-ask spread.

dynamic order book
What is next?

This post is part of the series on trading basics. In the previous post, we explained what is meant by an arbitrage opportunity and how traders may exploit them. Next, we will be discussing the concept of liquidity within the context of stock markets.

If you have enjoyed reading this post, feel free to share it with your friends and colleagues. If you have any questions or suggestions, you can leave a comment below.