Market Microstructure: Order Books & Execution Mechanics › Order Priority and Matching

Michael BrenndoerferJanuary 9, 20266 min read
Quantitative FinanceAll chapters
Part 12 of 15Market Making and High-Frequency Trading
Chapter 67Market Microstructure: Order Books & Execution Mechanics › Order Priority and Matching
Reading section 4 of 13 · Order Priority and Matching · 6 minSection 4 of 13 · 6 min

Book contents

Section 4 of 13 · 6 min read

Market Microstructure: Order Books & Execution Mechanics › Order Priority and MatchingOne section · Sections in this chapter4 / 13 ↓
Reading tools Definitions & inline links

Choose your expertise level to adjust how many terms are explained. Beginners see more tooltips, experts see fewer to maintain reading flow. Hover over underlined terms for instant definitions.

Article links

Make inline references clickable

When multiple orders exist at the same price level, the exchange must determine which orders execute first. The rules governing this priority are fundamental to understanding execution dynamics.

Price-Time Priority

The most common priority scheme is price-time priority (also called FIFO, first-in-first-out), used by exchanges like NYSE and NASDAQ. This system establishes a fair and predictable framework for determining execution order, rewarding both aggressive pricing and early arrival.

The priority rules work in a hierarchical manner:

  1. Price priority: Orders at better prices always execute first. A bid at $100.01 executes before a bid at $100.00. This makes economic sense: if you are willing to pay more (or accept less), your order should receive preferential treatment.

  2. Time priority: Among orders at the same price, earlier orders execute first. If you submit a bid at $100.00 at 9:30:00 and another trader submits at $100.00 at 9:30:01, your order has priority. This rewards market participants who commit to their prices early rather than waiting to see how the market evolves.

This creates a "queue" at each price level, and your position in the queue significantly affects fill probability:

In[14]:
Code
def simulate_queue_position_impact(
    queue_size: int,
    daily_volume_at_price: int,
    your_position: int,
    your_quantity: int,
) -> float:
    """
    Estimate probability of fill based on queue position.
    Simplified model assuming volume distributed evenly through day.
    """
    # Orders ahead of you in queue
    orders_ahead = your_position

    # If daily volume exceeds orders ahead + your order, you likely fill
    if daily_volume_at_price > orders_ahead + your_quantity:
        fill_prob = min(
            1.0, (daily_volume_at_price - orders_ahead) / daily_volume_at_price
        )
    else:
        fill_prob = max(
            0.0,
            (daily_volume_at_price - orders_ahead)
            / (orders_ahead + your_quantity),
        )

    return fill_prob


# Demonstrate queue position impact
queue_depth = 10000  # shares ahead at best bid
daily_volume = 50000  # daily volume at best bid

# Calculate probabilities for different queue positions
position_results = []
for position_pct in [10, 30, 50, 70, 90]:
    position = int(queue_depth * position_pct / 100)
    prob = simulate_queue_position_impact(
        queue_depth, daily_volume, position, 500
    )
    position_results.append((position_pct, position, prob))
Out[15]:
Console
Fill Probability by Queue Position
=============================================
Total queue depth at best bid: 10,000 shares
Expected daily volume at best bid: 50,000 shares

Position: 10% back in queue (1,000 shares ahead)
  Estimated fill probability: 98.0%
Position: 30% back in queue (3,000 shares ahead)
  Estimated fill probability: 94.0%
Position: 50% back in queue (5,000 shares ahead)
  Estimated fill probability: 90.0%
Position: 70% back in queue (7,000 shares ahead)
  Estimated fill probability: 86.0%
Position: 90% back in queue (9,000 shares ahead)
  Estimated fill probability: 82.0%

Being near the front of the queue dramatically improves fill probability. This is why high-frequency traders invest heavily in latency: arriving microseconds earlier can mean the difference between the front and the back of the queue.

Pro-Rata Matching

Some markets, particularly options exchanges and certain futures markets, use pro-rata matching instead of pure time priority. This alternative system creates different incentive structures for market participants. Under pro-rata:

  1. Price priority still applies: best-priced orders execute first
  2. Size priority: At the same price, orders are filled proportionally to their size

If 1,000 shares trade at $100.00 and there are three orders at that price (500, 300, and 200 shares), each gets a proportional fill: 500, 300, and 200 respectively if the incoming order is large enough, or proportionally smaller amounts.

Pro-rata matching encourages larger order sizes since bigger orders get proportionally larger fills, regardless of arrival time. This creates different strategic considerations compared to price-time priority.

Order Lifecycle

An order goes through several states from submission to final disposition. Its lifecycle defines the outcomes a trading system must handle. The journey begins when the order is submitted to the exchange or broker and ends in one of several terminal states.

When an order is first submitted, it enters an acknowledgment phase where the exchange validates its parameters. If the order passes validation, it may either execute immediately (if it crosses the spread) or join the queue at its specified price level. From the queued state, the order can follow multiple paths: it may receive partial fills as counterparties arrive, eventually completing when fully filled. Alternatively, it may be cancelled by you, or it may expire if it carries a time-in-force restriction that is reached. If the initial validation fails, perhaps due to an invalid price or insufficient margin, the order is rejected and never enters the book.

Out[16]:
Visualization
Flow diagram connecting submitted, acknowledged, queued, partially filled, filled, cancelled, expired, and rejected order states.
State-transition diagram for an electronic order. A valid submission is acknowledged and either fills immediately or joins the queue; queued orders can fill, partially fill, be cancelled, or expire, while invalid submissions are rejected.

A trading system must handle each state transition in the order lifecycle, including partial fills that may occur over extended periods and unexpected rejections due to risk checks or connectivity issues.