Chapter 7 Key Takeaways

Core Concepts

  1. The order book is the central data structure of exchange-based markets. It organizes all outstanding buy (bid) and sell (ask) orders by price and time, providing a transparent view of supply and demand at every price level.

  2. The bid-ask spread is the cost of immediacy. The spread represents the price you pay for trading right now rather than waiting. Narrow spreads indicate liquid, competitive markets; wide spreads indicate illiquid or uncertain markets.

  3. The continuous double auction (CDA) uses price-time priority. Orders are matched using two simple rules: (a) the best-priced orders match first, and (b) among orders at the same price, the earliest order matches first. Trades execute at the resting order's price.

  4. Order types give traders control over execution. Limit orders specify a price and may rest in the book (maker). Market orders execute immediately at any available price (taker). Time-in-force conditions (GTC, IOC, FOK) control what happens to unfilled portions.

  5. Depth charts visualize the full supply-demand landscape. Cumulative depth plotted against price reveals liquidity concentrations, support/resistance levels, and the overall health of a market at a glance.

Technical Insights

  1. Building an order book requires three key data structures. An Order dataclass, a PriceLevel class (FIFO queue of orders at the same price), and the OrderBook class (sorted collection of price levels on each side).

  2. The matching engine is the heart of any exchange. It receives incoming orders, checks them against resting orders using price-time priority, generates trades, and manages the order book state. Our Python implementation handles limit orders, market orders, cancellations, and multiple time-in-force conditions.

  3. Market quality is quantifiable. Key metrics include: bid-ask spread (transaction cost), depth at best (how much you can trade at the current price), total depth (overall liquidity), order imbalance (directional signal), and VWAP (execution quality benchmark).

Prediction Market Specifics

  1. Prediction market order books differ from traditional finance. Binary payoffs bound prices between $0 and $1. Liquidity is thinner, spreads are wider, dynamics are event-driven, and high-frequency trading participants are fewer. These differences create both challenges and opportunities.

  2. Order book dynamics carry information. When new information arrives, the order book reshapes: one side thins, the other loads, spreads widen temporarily, and aggressive orders walk the book. Understanding these dynamics gives traders an edge in timing their entries and exits.

Practical Rules

  1. Use limit orders, not market orders, in prediction markets. With thin liquidity and wide spreads, market orders risk significant slippage. Limit orders let you control your execution price.

  2. Be skeptical of large resting orders. Large orders visible in the book may be spoofing -- placed with the intent to cancel before execution. Do not treat order book depth as guaranteed support or resistance.

  3. Spreads widen before and during major events. If you want to establish a position, trade before the event when spreads are tight. During the event, execution costs can increase 3-4x.

  4. Order book imbalance is a short-term directional signal. When bid depth exceeds ask depth at the top of the book, prices tend to rise. When ask depth exceeds bid depth, prices tend to fall. This signal is noisier in prediction markets due to thinner liquidity.

  5. Data quality matters. Prediction market data feeds can be unreliable. Build systems that handle reconnections, missing data, and inconsistencies gracefully. Always validate your data before drawing conclusions.