The Runtime Theory
High-Frequency Trading

Order Types and the Order Book

Limit orders vs market orders, how they fill, and how the order book depth works.

The Runtime Theory Team1 min read
▸ On this page

Order Types and the Order Book

Market Orders

A market order says: "I want to trade immediately at the best available price."

cpp
// Buy 100 shares of AAPL at market price
// Best ask is 150.05 for 30 shares, then 150.06 for 100 shares
// You pay: 30 shares × 150.05 + 70 shares × 150.06 = 15,008.50

Market orders always fill but you don't control the price.

Limit Orders

A limit order says: "I want to trade at a specific price or better."

cpp
// Buy 100 shares of AAPL at $150.00 or better
// If the ask is $150.05, your order sits in the book
// It only fills if someone sells at $150.00 or lower

Limit orders give you price control but may not fill at all.

How the Order Book Matches Orders

The exchange maintains a sorted list of orders by price:

  • Buy side (bids): sorted highest first (willing to pay the most)
  • Sell side (asks): sorted lowest first (willing to sell for the least)
plaintext
Bids              |  Asks
100.03 × 50       |  100.05 × 30
100.02 × 100      |  100.06 × 200
100.01 × 75       |  100.07 × 150

When a new market order comes in:

  • A buy market order hits the lowest ask (100.05) first.
  • A sell market order hits the highest bid (100.03) first.

Order Book Depth

The depth of market (DOM) shows how many shares are available at each price level. It tells you:

  • How much volume is available before the price moves (slippage).
  • Where large buy/sell walls exist.

High liquidity (many orders at each price) means you can trade large quantities with minimal price impact.

Not started

Sign in to save your learning progress.

Sign in to save