Urgent.News

What's breaking now, across thousands of outlets.

Finance & Markets

Order book & market microstructure: what every trading system builder needs to know

Cross-post. Original: stellarbytecapital.com/blog/order-book-market-microstructure Most people building a trading system think in terms of one number: the price . But there is no single price — there's a bid, an ask, and a stack of resting orders in between. The moment you send an order you interact with that structure, not a clean number on a chart. Ignoring microstructure is why so many…

Many traders focus on a single metric when building a trading system: the price. However, the reality is far more complex. The order book presents a multi-layered landscape of bids, asks, and resting orders, each with its own price and depth. Ignoring this intricate structure is the reason why strategies that appear profitable on paper often fail in real-world trading.

The order book comprises two sorted queues: bids (buy orders) and asks (sell orders), each ordered from highest to lowest and lowest to highest, respectively. The top bid represents the maximum price anyone is willing to pay, while the top ask signifies the minimum price at which someone is willing to sell. The midpoint between these two extremes forms what charting tools display as the price, even though actual trades rarely occur at this level.

The quantity of orders at each level, known as depth, determines the actual cost of executing a trade.

When a trader sends a market order, it immediately crosses the spread, consuming resting liquidity from the top down. This action is taken by a taker, paying for certainty in execution with a higher price. Conversely, a limit order waits for the price to reach or surpass a specified threshold, allowing the trader to control the entry point at the cost of uncertainty and potential non-execution. When someone trades against a limit order, the trader becomes a maker, often receiving a rebate for providing liquidity.

Slippage, the discrepancy between the expected price and the actual fill price, arises when a market order exceeds the quantity available at the best ask. The difference between the anticipated price and the average fill price, exacerbated by the size of the order relative to the depth of the book, is a critical consideration. This phenomenon is precisely why backtesting a trading strategy using close prices, which assumes a single price with limitless liquidity, frequently results in an overstated edge.

Moreover, market impact represents the enduring effect of a trader's activities on the market. Large orders not only create immediate slippage but also signal information, leading to price movements away from the executing trader. To mitigate these effects, many traders split large orders into smaller batches, a technique known as TWAP (Time Weighted Average Price) or VWAP (Volume Weighted Average Price), allowing for more discreet execution and reduced market disruption.

When constructing a trading system, it is imperative to model costs based on the microstructure of the order book rather than relying on a single midpoint price. Backtesting and live risk assessment must account for factors such as spread, depth, and slippage to ensure the strategy's viability. Real-time depth data should be continuously consumed and maintained, as trading on microstructure necessitates access to the Low Latency (L2) book through WebSocket connections, synchronized with sequence numbers and resnapshotted upon gaps.

Choosing the appropriate order type is crucial, depending on the urgency of the trade and the trader's preference for earning spread through maker orders or avoiding spreads as a taker. The size of the order must also be carefully considered in relation to the available liquidity, as a strategy that performs well with small positions may falter when scaling up due to the book's inability to accommodate the increased demand.

A common mistake in trading system design is treating the midpoint as a tradeable price, which overlooks the bid/ask spread and depth. Backtesting on close prices, assuming zero slippage, is another frequent error that often inflates the perceived edge of a strategy. Ignoring depth when sizing orders can lead to escalating slippage and unintentionally signaling trading intentions.

Constantly consuming liquidity through frequent trading eliminates high-frequency trading advantages, while assuming that small fills do not affect the market is a misconception, as larger players ultimately shape market dynamics. Ultimately, microstructure serves as the bridge between trading signals and the realities of executing those trades, emphasizing the need for traders to consider all aspects of the order book when developing and refining their strategies.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Finance & Markets

More from Wednesday 2 September →