An Intro to Market Microstructure
Gabriel Bridger · 27 September 2026
So we've constructed an order book, but how do we actually use it?
Intro
This post is created as a guide to help understand how we identify common orderbook states and then how we can exploit them to our advantage.
Naturally this is somewhat of a follow on from Szymon's post about how orderbooks are initially created from market data - this can be found here.
Orderbook Basics
How to Read an Orderbook
The first step in understanding market microstructure is knowing how to read an orderbook ladder. (If you are already familiar with orderbook mechanics, feel free to jump to the next section).
Take the following orderbook for the fictional NEFS ticker as an example:
| Bid Size |
Price |
Ask Size |
|
$107.00 |
2,500 |
|
$106.00 |
800 |
|
$105.00 |
400 |
|
( Spread ) |
|
| 500 |
$100.00 |
|
| 1,200 |
$99.00 |
|
| 3,000 |
$98.00 |
|
(Note: There are a few different ways to visually represent an orderbook, but this "Price Ladder" layout is often the easiest to intuitively understand).
Instantly, we can deduce a few critical data points from this book:
- The lowest price someone is currently willing to sell
NEFS is $105.00, this is called the Best Ask.
- The highest price someone is currently willing to buy
NEFS is $100.00, this is called the Best Bid.
Next, we can determine the Bid-Ask Spread by taking the Best Ask and subtracting the Best Bid ($105.00 - $100.00 = $5.00).
At a basic level, the spread is simply the price gap between buyers and sellers. But mechanically, it represents the cost of immediacy. If you want to buy NEFS right this exact second, you can't wait in line at $100.00 - you have to cross the spread and pay $105.00.
As we will see in the next section, understanding this spread is the foundation for almost every automated trading strategy.
Matching Mechanics
Now that we know how to read an orderbook ladder, we need to understand the underlying mechanics of how it actually works - specifically, how the exchange matches a buyer and a seller at the same price.
Imagine the NEFS orderbook has a Best Ask of 400 shares resting at $105.00. If we submit a buy limit order for 100 shares at $105.00, our order is immediately marketable: its limit price is high enough to trade against the existing Best Ask.
Rather than joining the bid side of the book, the matching engine immediately matches our incoming order against the resting sell orders at $105.00. Since we only want 100 shares and 400 are available, 100 shares execute at $105.00 and the remaining Ask Size falls to 300.
To us as traders, it looks simple: we crossed the spread and got filled.
But that 400-share Ask Size may actually represent several individual orders, and the exchange still needs to decide which of them we trade against first. Say it looks like this:
| Id |
Size |
Price |
| Trader A |
50 |
$105.00 |
| Trader B |
200 |
$105.00 |
| Trader C |
150 |
$105.00 |
Since we only bought 100 shares, how does the exchange determine whose specific shares we just bought?
Price-Time Priority
The most common algorithm exchanges use to solve this problem is Price-Time Priority.
Under this rule, the best prices (highest bid / lowest ask) always get filled first. If multiple orders are sitting at the exact same price level, the engine acts as a FIFO (First-In, First-Out) queue meaning the order that arrived at the exchange first gets filled first.
To visualise this, we need to add a timestamp column to our table to see the exact arrival times of the resting orders:
| Id |
Size |
Price |
Arrival Time |
| Trader A |
50 |
$105.00 |
09:00:01.000 |
| Trader B |
200 |
$105.00 |
09:00:02.000 |
| Trader C |
150 |
$105.00 |
09:00:05.000 |
Because Trader A was the first to submit their order to the exchange, they are at the very front of the line for the $105.00 price level.
When our aggressive buy order for 100 shares arrives, the matching engine works its way down the queue:
- Trader A gets filled completely. They sell their 50 shares, and our remaining order size drops to 50.
- Trader B is next in line. They are offering 200 shares, so the engine takes the 50 shares we still need from them. Trader B is left with 150 shares still resting on the orderbook.
- Trader C gets nothing. They were too slow to the market, so they remain at the back of the queue, waiting for the next buyer to cross the spread.
After our trade executes, the new aggregated L2 ladder will update instantly. The Ask Size at $105.00 will drop from 400 to 300, reflecting the remaining shares of Trader B and Trader C.
Now that we know better-priced orders are matched first, with earlier orders taking priority at the same price, can we use these mechanics to find value in the orderbook?
Trading with an Orderbook
Now that we understand the rules of the game - the spread and price-time priority - how do traders actually use these mechanics to extract value? Broadly speaking, orderbook strategies fall into two camps: making liquidity and taking liquidity.
1. Making Liquidity
Imagine our current NEFS orderbook looks like this:
| Bid Size |
Price |
Ask Size |
|
$106.00 |
800 |
|
$105.00 |
400 |
|
( $5.00 Spread ) |
|
| 500 |
$100.00 |
|
| 1,200 |
$99.00 |
|
If a new Market Maker wants to capture this spread, they have a problem: there are already 500 shares waiting at the $100 Bid, and 400 shares waiting at the $105 Ask. Due to Price-Time priority, the new Market Maker would be stuck at the very back of the queue if they quoted the current spread.
To avoid being stuck at the back of the queue the Market Maker sacrifices some of their profit margin (narrowing the spread) to get price priority, placing a Bid at $101 and an Ask at $104:
| Bid Size |
Price |
Ask Size |
|
$105.00 |
400 |
|
$104.00 |
100 (MM) |
|
( $3.00 Spread ) |
|
| 100 (MM) |
$101.00 |
|
| 500 |
$100.00 |
|
The Market Maker successfully narrowed the spread from $5 to $3.
By sacrificing $2 of potential spread, they gain price priority on both sides of the book. If both quotes are filled before the market moves adversely, the Market Maker buys at $101 and sells at $104, capturing a gross spread of $3 per share. However, the two fills will not necessarily happen at the same time: once one side trades, the Market Maker temporarily holds inventory and is exposed to both price movement and adverse selection.
2. Taking Liquidity
Not everyone trades randomly. Large institutional traders often need to execute orders far bigger than the liquidity available at the top of the book. Submitting the entire order at once could consume several price levels, creating substantial market impact and a poor average execution price.
To reduce this impact, large orders can be hidden or broken into smaller pieces. An iceberg order displays only part of its total quantity on the book, replenishing the visible quantity from a hidden reserve as it is filled. Execution algorithms can achieve a similar effect by repeatedly submitting smaller child orders from a much larger parent order.
If we observe, for example, repeated 100-share buy orders arriving with similar timing and behaviour, we might infer that a larger hidden buyer is active. If that flow is sufficiently predictable, a strategy could attempt to position ahead of its expected future demand.
So let's run through how this works, imagine our algorithm detects that the Whale is about to submit their next buy order for 100 shares, and they are willing to pay up to $104.00. Currently, the orderbook looks like this:
| Bid Size |
Price |
Ask Size |
|
$105.00 |
800 |
|
$104.00 |
400 |
|
$103.00 |
50 |
|
$102.00 |
50 |
|
( $2.00 Spread ) |
|
| 500 |
$100.00 |
|
As we can predict when the Whale's order is coming about to come through, just before it does we aggressively buy the 50 shares at $102.00 and the 50 shares at $103.00 which creates a liquidity vacuum and clears out any trades that could take price priority over us.
Now, we've gained 100 shares at an average cost of $102.50 - that we don't really want - and now we need to sell them off to the Whale to produce a profit. However, if we place a sell order at $104.00, we'll be placed at the very back of the time priority queue behind the existing 400 shares.
To guarantee we get the Whale's trade, we undercut the $104.00 level and place our sell limit order at $103.00 then as we just cleared out all the old cheaper liquidity we are now sitting completely alone at the Best Ask:
| Bid Size |
Price |
Ask Size |
|
$105.00 |
800 |
|
$104.00 |
400 |
|
$103.00 |
100 (Us) |
|
( $3.00 Spread ) |
|
| 500 |
$100.00 |
|
A split-second later, the Whale's algorithm blindly submits its buy order for 100 shares at $104.00. The matching engine looks for the Best Ask, sees our order sitting at $103.00, and immediately executes the trade.
Finally, we finish the cycle back at a flat position, meaning our net inventory has returned to 0, where we bought 100 shares at an average cost of $102.50, and sold them back to the Whale for $103.00 making $0.50 profit per share. This may seem like a tiny amount of profit but when this is done at an incredibly high frequency on a high volume of trades it starts to add up nicely.
The Reality of It: Order Flow Toxicity
So far, market making has looked like free money: sit at the front of the queue, wait for a buyer and a seller to cross your quotes, and pocket the spread. But if it were really this easy, everyone would be doing it. There's a catch, and it's called adverse selection.
When a market maker posts a quote, they accept the risk that the trader on the other side may have better information about the asset's short-term value or direction. That does not necessarily mean private or inside information: an informed trader might simply have a better model, react to public information faster, or possess information about their own future trading demand.
Suppose a market maker is offering to sell at $104.00. An informed participant begins aggressively buying because their estimate of the asset's fair value is substantially higher. The market maker sells at $104.00, only for the market price to move sharply upward moments later. The problem is not simply that the market moved - it is that the market maker was disproportionately likely to be filled precisely when their quote was stale or mispriced.
This is what quants mean by toxic order flow: a situation where an unusually high proportion of the traders taking your liquidity are informed rather than random. For a market maker, surviving means spotting the early signs of toxicity before it eats into the books.
Measuring Toxicity
Spotting toxic flow before it does damage is one of the more important jobs in market making. Two models in particular have become the standard tools for the job.
1. Order Book Imbalance
Order Book Imbalance measures the relative amount of displayed buying versus selling liquidity resting on the orderbook. It can be calculated from executed trades, but it's most intuitive when read straight off the resting orders on the L2 orderbook.
Take the following extreme orderbook state:
| Bid Size |
Price |
Ask Size |
|
$105.00 |
50 |
|
$104.00 |
20 |
|
( $3.00 Spread ) |
|
| 8,500 |
$101.00 |
|
| 12,000 |
$100.00 |
|
There's a severe imbalance here. Over 20,000 shares of buying interest are stacked on the bid side, while only 70 shares of liquidity remain on the ask. A market maker sitting in those 20 shares at $104.00 is dangerously exposed: a whale is clearly accumulating, and the remaining ask liquidity is likely to get swept.
A common normalised formulation for OBI over a given interval $t$ is:
$$
I_t=\frac{Q_{B,t}-Q_{A,t}}{Q_{B,t}+Q_{A,t}}
$$
Where $Q_B$ and $Q_A$ are bid and ask quantities at time $t$.
A related concept, Order Flow Imbalance (OFI), instead measures how buying and selling pressure changes through order submissions, cancellations and executions over time.
An OFI value approaching $+1$ signals pure buying pressure, while $-1$ signals pure selling pressure. Persistent OFI in one direction is a strong tell that informed traders are at work.
2. VPIN (Volume-Synchronised Probability of Informed Trading)
Where OFI looks at a static snapshot of the book, VPIN evaluates the intra-day dynamics of executed order flow itself.
Developed by Easley, López de Prado and O'Hara (2012), VPIN is a real-time estimator of the probability of informed trading. Rather than measuring time, it groups trades into volume-synchronised buckets (a new bucket forms every time $V$ shares are traded), then classifies the trades in that bucket as either 'buy-initiated' ($V^B$) or 'sell-initiated' ($V^S$).
VPIN is calculated as:
$$
VPIN = \frac{\sum_{i=1}^{n} | V_{i}^{B} - V_{i}^{S} |}{n \cdot V}
$$
Where:
- $n$ is the number of volume bars in the sample.
- $V$ is the total volume of each bar.
- $V_{i}^{B}$ and $V_{i}^{S}$ are the buy and sell volumes in the $i$-th volume bar.
The absolute difference between buy and sell volume in each bar captures that bar's imbalance. A high VPIN reading means a persistent, significant imbalance, which points to informed traders systematically building or unwinding a position. On our platform, tracking VPIN in real time serves as an early warning system for incoming toxic flow.
The Market Maker's Defence: Toxicity-Adjusted Spreads
The relationship between toxicity and liquidity is fundamentally inverse. The more toxic the flow, the less profitable market making becomes.
A market maker's optimal spread is a function of how toxic they perceive the order flow to be. When real-time metrics like VPIN or OFI spike, the market maker has to recalculate on the fly, widening their spreads to compensate for the added risk, or pulling their resting orders and stepping back from the market entirely.
Understanding market microstructure isn't just about knowing how to mechanically execute a trade, it's about quantifying the informational asymmetry of whoever's sitting on the other side of it.
Part of Quant Foundations · Previous: From Market Data to Order Book · Next: Intro to Market Making
NEFS Quant · About · Blog · News & Events · People · Privacy policy