I'm trying to gain some insight into how orders on an exchange are matched to design a proof of concept matching system.

Am I correct in assuming market orders are immediately executed against the best priced limit order in the limit order book if there is not another market order at the same time to fill the opposite side ?


Limit order book

Time|Buy | Time|Sell

00:01|50 | 00:02|55

00:03|53 | 00:01|60

Market buy order comes in at 00:05

Would it match with the sell limit order at 55 (because $55 is the best price) or with the order at 60 since it's the oldest ?

  • "sell limit order at 50" You wrote 55. The 50 is a buy order.
    – base64
    Mar 30, 2015 at 21:11

1 Answer 1


Yes, only if the sell order quantity available at $55 is greater than or equal to the quantity of the market order you entered, and that sell order is not an "All or None" order.

If you submitted a market order to buy 100 shares, and there are 30 shares available at $55 and 70 shares available at $60, your order will be filled at two different prices, resulting in a weighted average of $58.5 to you.

Not the answer you're looking for? Browse other questions tagged .