Now, let's talk a bit more about the Limit Order Book that we already mentioned in the last video. As we already mentioned, the Limit Order Book is so to say a heart of an electronic exchange. It aggregates all limit orders on both the buy and sell sides at each price level, and price levels are measured in ticks which are elementary units of price. As we already mentioned, in the US market, one tick is one cent. So, interestingly, the real market price is actually quantized like in physics and the true price dynamics are fundamentally discrete which is actually opposite to what is done in classical quantitative finance because in this models, you usually start with a continuous model and then discretize it for numerical implementation. But it's a side remark. Let's come back to the Limit Order Book and a good way to visualize it with diagrams like the one shown here. We have the buy side in blue on the left and the sell side in red on the right. The position of each bucket is a price level, like a cent for the US market, and the height of each bucket is the total quantity. The rightmost blue bar is the best buy quote which is called the bid price and the leftmost red bar is the best cell quote which is called the ask price. The gap or difference between them is called the bid-ask spread. As you can see, the gap is always non-zero. So, when a trader does an actual trade, he or she crosses the spread. This means that the trader will pay the ask price if buying or get a bid price if selling. The main function of the Limit Order Book is to aggregate orders and implement a matching mechanism. To understand how it's done, let's talk again about two types of orders in the LOB. So, when a limit order arrives, a score is placed in the bucket corresponding to each price level. If there are other orders with the same price level, all orders are organized as a queue. A queue is essentially a structure or a datatype in computer science that a has two points, a point of entry and the point of exit. Therefore, queues are often called First-In First-Out or FIFO structures. A simple analogy within every day life is when you call customer support of say your utility provider or company. At this point, you are put at the end of the queue of customers that waits to be served, and you wait until other customers' calls are answered. So, a new limit order will sit in there and will be until it's executed by matching a market order from the opposite side. Alternatively, it can get cancelled at anytime. In case the order waits for a match, the first execution price is known but the execution time is uncertain. If the price level in order is very close to the current bid-ask spread, it will be executed very quickly. But on the other hand, if it's too far from the current bid-ask spread, such order may sit long in LOB. Alternatively, the initial price level can be close to the current bid-ask spread but the market itself can move away from that level. Now, let's talk about market quotes. A market order is an order to buy a certain quantity X of the asset at the best available price as we've said. So, what happens with the Limit Order Book when such market order arrives? The first thing that happens is that, jurors will start trading on behalf of the trader that submits this market order. The first share or the first block of shares will be traded at the bid-ask spread, but the main part will be traded at some ticks up or down. This is because both the current trades and other trades by other participants will move the execution price away very quickly. Therefore, the final cost per share would be uncertain with such market orders. The uncertainty will depend on the size of the trade, the state of the LOB, and actions of other participants. Now, it might happen that as a result of market orders and cancellations, a bid or ask queue will be depleted. In this case, the price will be simply updated to the next price level. This will constitute the actual price moves of the stock. As I showed in tables in the previous video, this happens all the time and many thousands of times a day. Now, let's talk about what happens with the opposite side of the LOB when a market order, say, a sell order arrives. In this case, buyers are sorted according to priority rules, a price priority, and the time priority. The price priority rule is that the best price is always executed first, and the time priority is that if FIFO rule over a queue that we already mentioned. Now, let's talk about cancellations. Agents can cancel their order. So if the order of X is cancelled, then the queue size is reduced by X. If either of the size of the LOB is depleted as a result of market orders and cancellations, the price will move up or down the next level, and it turns out the vast majority of limit orders sometimes up to 95 percent is canceled. Therefore, if you only look into actual paid events, we might miss some important features of the LOB. The paper by Rama Cont and co-workers looked into the importance of using non-trade data called event data from the LOB to study impact on prices. Here is one example of a simple LOB that I borrowed from the blog referenced on the slide. In this example, the current best bid is 17.33 and the current best-ask is 17.35, and you want to buy 200 shares. So, let's assume that we bought the first 80 shares for 17.35. This produces an immediate execution and now the LOB has only 80 stocks left for 17.35. So, now we have 80 stocks and we need 120 more. So, we can put a limit order for 120 stocks, the price of 17.34, and after a while nothing happens as no one wants to trade with us at this price. So, we cancel this order and now the LOB looks like that. There are still remaining 80 stocks for grab for 17.35. So we buy this 80 stocks for 17.35 and now we have 160 stocks which is short of our target of 200 stocks. Because the queue is now depleted, so we buy remaining 40 stocks for the next best price of 17.37. So, this is a simple visualization of mechanics of the LOB. In the next video, we will talk about modeling of the LOB.