# 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?

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.

• I would add that at the CME the depletion of the limit order book during trading hours would be considered highly unusual and probably triggers a market halt, with the market re-opening only if and when the limit order book fills again. In this "pre-market" state arriving market orders are held back in a queue awaiting market re-open. – noob2 Dec 12 '16 at 18:07
• Although there is another answer which says differently, your answer makes more sense to me. – e271p314 Dec 13 '16 at 14:43

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.