How Matching Engines Handle Crossing Limits and Empty-Book Markets
Summary
The document considers two unusual order-book situations: a buy limit order priced above a sell limit order when the book is empty, and two opposing market orders arriving when there is no resting liquidity. The accepted answer describes the limit-order case as dependent on arrival order: the first order may rest in the book, and the later crossing order can execute against it at the resting order’s price. This illustrates how matching priority and execution price can differ from an intuitive midpoint.
For market orders against an empty book, the answer says behavior depends on exchange matching-engine rules; orders may be rejected because no contra-side liquidity exists. Another answer suggests a midpoint execution for the crossing limits, showing that the precise outcome is not universal. These are edge cases, and the post offers no exchange-specific rulebook or experimental evidence. Traders and researchers should treat fill outcomes as venue-dependent and consult the relevant matching rules rather than assume one price convention.
Key ideas
- A crossing pair of limit orders may be resolved according to which order reaches the book first.
- The later limit order may execute at the resting order’s price under price-time matching.
- Market orders cannot necessarily execute when the book has no opposing liquidity.
- Matching-engine rules vary, so edge-case fills require exchange-specific investigation.
Tags
Full text
# Fill prices on limit and market orders # Fill prices on limit and market orders Suppose the book of ticker `X` is empty. Simultaneously trader `A` sends a limit buy order for 1 unit of `X` at price `2$` and trader `B` sends limit sell order of 1 unit of `X` for `1$`, what will happen? What is going to be the fill price? Same question for market order, suppose the book for ticker `X` is empty and traders `A` and `B` send a buy and sell market orders (without prices) is the fill price going to be the last fill price? how is the fill price determined in such case? ## Answer by nbbo2 (score 3, accepted) https://quant.stackexchange.com/a/31448 In the first case it is a "race condition": whichever order is received first (even if it is only one microsecond before the other) will populate the Book and the second limit order will execute against it, at the price of the first order. In the second case it is indeterminate and may depend on the details of how the "matching engine" works. Probably when the first market order is received against an empty Book, it will be rejected and so will the second since the Book is still empty. Both of these are "edge conditions" or peculiar cases where the result may be highly implementation dependent. ## Answer by LazyCat (score 1) https://quant.stackexchange.com/a/31447 While the behavior is generally exchange-dependent, in the first case, the orders are likely to get crossed at $1.50, and in the second, both return unfilled.
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.