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 strategies that look profitable on close prices lose money live. Your strategy decides what to trade; microstructure decides what it costs. The order book: what "the price" actually is An exchange matches orders through a limit order book - two sorted queues: - Bids - buy orders, highest-first. The top bid is the most anyone will pay. - Asks - sell orders, lowest-first. The top ask is the least anyone will sell for. The best bid and best ask form the top of the book. The gap is the spread; the midpoint is what charts draw as "the price," even though you can rarely trade there. The quantity resting at each level is depth - and depth determines what a real order costs. Market vs limit orders: taker vs maker - A market order says "fill me now." It crosses the spread and consumes resting liquidity from the top down. Certainty of execution, paid for in price - you're a taker. - A limit order says "fill me at this price or better." It rests and waits. Price control, paid for in uncertainty - it may never fill. When someone trades against it you're a maker, often earning a rebate. The maker/taker choice is frequently the difference between a strategy that's net profitable and one that isn't - especially at high turnover. Slippage: why your fill isn't the price you saw Send a market order bigger than the quantity at the best ask and it "walks the book" - part at the best level, part at the next, each worse. The gap between expected price and average fill is slippage, and it grows with your size relative to depth. This is exactly why a backtest on close prices lies: it assumes one clean price with infinite liquidity, while the real book charged you spread plus slippage on every fill. Market impact: you are part of the market Slippage is the immediate cost of consuming depth; market impact is the broader, lasting effect of your own trading on price. Large orders signal information and move the market away from you. That's why serious execution splits big orders into smaller pieces over time (TWAP/VWAP logic) - trading gradually to leak less information and let depth replenish. Why this matters when you build the system - Model costs from the book, not the mid. Backtest and live risk math must account for spread, depth, slippage, or your "edge" is an artifact. - Consume and maintain real depth data. Trading on microstructure means the L2 book over WebSocket, kept in sync with sequence numbers and re-snapshotted on gaps. - Choose order types deliberately. Taker for urgency, maker to earn spread - know which your turnover can afford. - Size against liquidity. A strategy that works at $1k can fall apart at $1M because the book can't absorb it. Capacity is a microstructure question. What to avoid - Treating the mid as a tradeable price - you trade against bid/ask and depth. - Backtesting on close prices with zero slippage - the most common way to overstate an edge. - Ignoring depth when sizing - a large order pays escalating slippage and signals your hand. - Always taking liquidity - paying the spread every time destroys high-frequency edges. - Assuming your fills don't move the market - above a certain size, you are the market. Microstructure is where a strategy meets reality. The signal tells you which way to trade; the order book decides how much of that edge survives contact with the spread, the depth, and your own footprint. We're Xingyao Byte - building quant trading systems, execution and market-data infrastructure, secure AI-execution layers, and payment platforms. Remote, async-first โ stellarbytecapital.com Top comments (0)
Comments
No comments yet. Start the discussion.