Note: This question is erroneously marked as a duplicate. It concerns a very specific situation with unfulfillable market orders in very illiquid markets, one that no other discussion here has covered. Related questions are addressed at the end.
TL;DR This is the entire order book:
__________________________________________________ |___________Buy__________|__________Sell__________| | Time | Price | Quant | Time | Price | Quant | | | | | 10:05 | market | 1 | | | | | 10:00 | $10.00 | 1 | |_______|________|_______|_______|________|_______|
There's an incoming buy order for 1 share, limit price $11. Which order gets matched and at what price?
With the above order book, if someone came in and placed a buy order for 1 share at limit price $9, I assume it matches the market order and trade is executed at $9. Straightforward. If instead the buyer placed a buy order with limit price $11, would it match the limit order or the market order?
Answering by determining "price" of unfulfilled market order
When the incoming order is a market order and there are only limit orders on the books, it's clear how to price it: based on the best bid or ask. But that doesn't help us here.
One option is that if we can figure out what to consider as the "price" for the unfulfilled market order on the books, we can decide based on price/time priority.
The possibilities are:
- Price market order at best ask: $10. Now we have two orders at the same price, so the earlier-placed one gets it: the limit order. But this seems unfair. The trader placing the market order is clearly willing to go below $10, so they should get the trade!
- Price market order at best bid: $11 or undefined? On the one hand, the incoming buy order is at $11, but on the other hand, by definition an incoming order isn't on the books yet, so there is no "best ask". If it were $11, the buy order would be matched with the $10 limit order, even if the market order had been placed first! Seems unfair that an earlier-placed market order would lose out to a limit order.
- Price market order at last traded price: let's say $11. Again the market order would unfairly lose out to the limit order here.
- Price market order at $0.01 better than best ask: $9.99. Okay, this works. But we can't simply treat it as
limit price $9.99because this market order would match an incoming buy order with limit price $9.
Always matching market orders first
As @Dheer's answer suggests, one approach is to simply match market orders first no matter what. This makes a lot of sense, though we still need to figure out at what price does the trade executes. Clearly not the buyer's limit price of $11, because they'd get a worse deal than the limit order on the books. So, $10? $9.99? Last trade price, or opening price (but no more than $10)?
What if the incoming buyer placed a market order instead. At what price do you match two market orders - same as the answer to the above?
I guess this comes down to specifications for individual exchanges, but I'm wondering if there's a standard here or a way to approach it from basic rules that clears up all these situations.
Edit: Some specifics of how limit orders are matched is discussed at How do exchanges match limit orders? This question is not a duplicate of that - my question is specifically about how an incoming limit order is matched when the other side of the order book has an unfulfilled market order. This case is not discussed at all by various existing questions, which only discuss matching incoming orders when there are sufficient limit orders already on the books.
Other relevant discussions that don't directly address these questions but are good background reading:
According to this answer https://money.stackexchange.com/a/57191/35787, some or all markets will reject incoming market orders if there are no orders on the books to match it to, so the situation I describe in this question wouldn't be possible in the first place. I don't have any sources to back this up but if someone can confirm or contradict this we can probably settle this question.