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.

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.99 because 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.

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1

Why the downvote? Not at all a dupe if you read the question. For clarity @littleadv I've added a specific explanation of how this is case is unanswered by existing questions.
– tobekDec 14 '15 at 8:38

of course it is discussed. No matter how many times you emphasize the irrelevant "limit", it will still be irrelevant and the answer is exactly like in the question I linked. Downvote because you didn't bother looking through the myriad existing questions on this exact topic before posting. You're not a new SE user, you should know better.
– littleadvDec 14 '15 at 8:47

1

@littleadv I spent approximately an hour searching for and reading about this topic, largely on money.stackexchange, before asking my question. As you say, I'm not a new SE user. I've given you the benefit of the doubt and re-read the linked question and several others and have not found the answer to my questions, which concern unmarketable market orders on the books when new orders come in. For instance: how is the price determined when two market orders are matched to each other? Please give me the benefit of the doubt and read my question again and reconsider your downvote.
– tobekDec 14 '15 at 9:10

1

While I still consider your question a duplicate, now that you've actually referenced the prior questions and explained why you think they don't answer your question, I removed the downvote. I would expect you to do this ahead of time, without regarding the potential respondents as your servants and giving us the same respect you want to receive in return.
– littleadvDec 14 '15 at 10:08

1

@littleadv Fair enough - I definitely should have mentioned the near-dupe questions to show that I had considered them. Appreciate you taking another look.
– tobekDec 14 '15 at 10:11

1 Answer
1

On a illiquid stock, such situations do arise and there are specific mechanisms used by exchanges to match the order. It is generally not advisable to use market order on illiquid stock.

There are lots of different variations here. 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.

There are quite a few variations and different treatments.

Scenario 1:
Market order that are placed when the market is closed [Good till Cancelled] or just around market opening. There are held and not released immediately. Depending on the exchange, first 5 to 15 minutes the trades happen only on Limit Orders. After this; market orders are released and matched. Market buy orders get matched to market sell orders. The price algorithm kicks in. This is closely guarded secret so that price can't be influenced. Generally it factors in the trend for last 6 months of the share, the closing price of previous day, the stock market indexes and the average price for the limit trades in the 5 to 15 minutes the market are open.
Not all order get matched and there could be spill over's. These are then matched to limit orders.

Scenario 2:
On an ill-liquid stock, there are no orders, there is one buy market order and one sell market order. These get matched. The price is last traded price.

Scenario 3:
No order on book. Then there is a buy Limit Order followed by buy Market order [or vice versa]; post this there is a market sell order. The Market sell order is matched to the market buy order. The price is the best limit order on buy side.

Is this determined based on which sell order came first, or based on which would result in the best deal for the incoming buyer?

"It is generally not advisable to use market order on illiquid stock" this seems like a key takeaway! But thanks - simply treating market orders as higher priority narrows down the # of options greatly, and then as you say it simply has to come down to the market's own formula for determining that price.
– tobekDec 14 '15 at 10:09

Ultimately it is down to the exchange's specific matching rules, and how they programmed their system. There are sometimes edge cases that cause problems which they in turn subsequently fix.
– xirtDec 21 '17 at 18:53