Skip to content
All library documents

How Limit Order Books Fill Market Orders at Multiple Prices

Article Quant Q&A · Author: luchonacho

Summary

The document explains why buyers with resting limit orders may pay different prices when a large market sell arrives. In an order book, the seller’s market order consumes available bids from the highest price downward. Each resting buyer is filled at the price specified by their own limit order, so a buyer bidding above the eventual lowest execution price can still pay the higher bid.

The example is used to distinguish the market order’s demand for immediate execution from the limit orders’ specified maximum purchase prices. The exact sequence depends on which orders were placed and the exchange’s matching rules, and the source notes that the aggressor’s order type cannot be inferred from the trade display alone. It gives a basic account of price-time matching and execution across book levels, without covering exchange-specific details such as fees, hidden liquidity, or advanced order types.

Key ideas

  • A market sell executes against resting buy orders, generally beginning with the highest available bid.
  • A limit buyer can be filled at the price they specified even when later executions occur at lower prices.
  • A large order may trade across multiple price levels as it consumes available liquidity.
  • Trade prints alone may not reveal the aggressor’s exact order type or the full matching sequence.
  • Execution outcomes depend on the exchange’s order book and matching rules.

Tags

Full text
# Why was a buy position not closed at the seller's price?


# Why was a buy position not closed at the seller's price?












I'm trying to understand how the trading of crypto-currencies work. I imagine it's not that different from standard currency (or asset) trading, so I ask in this site.

Consider the crypto market shown in Kraken.com. The market can be nicely visualised as a list of sellers and buyers by price level, e.g. here. A capture of a crypto against the Euro:

There you see the current market price (exchange rate), given by the value of the last buy-sell match, and then the open bids for sell (red) and buy (green), with order's volumes and the accumulated volume.

So, say that, while the market price is at $p$, I open a buy (crypto) position at $p-\epsilon$, with $\epsilon > 0$, and volume $X$.

Then, at some point, someone decides to sell (crypto) a very large volume $Y$ ($Y>>X$) at $p - \eta$, with $\eta>\epsilon$ (i.e. at a lower price than mine). From the example below, I imagine the person puts out a sell position "at market price", which I guess is equivalent to instructing the system to "sell at whatever price is needed", i.e. lower the sell price until all my volume is satisfied". So, my order is executed, together with that of several buyers above and below my price, at exactly the same time. For instance, executed orders (visible in the market platform in the link above) looks like this:

There you see, for instance, that at 9:46:46, a person sold around 5,000 units of crypto for euros at a price 0.3515. Yet, those who had a buy position at a price above 0.3515 and which was triggered by the sell order above paid more than 0.3515. For instance, the person buying 248.2370 units of crypto paid 0.3545. Shouldn't that person have paid 0.3515?

More crucially, does the nature of the trade depends on the type of order? For instance, Kraken offers several types of order like market, stop loss, take profit, etc. I'm trying to understand how the trades work.

## Answer by Ezy (score 1)

https://quant.stackexchange.com/a/44053

Kraken implements an order book mechanism to match buyers and sellers.

You would need to dig into more details to know exactly what order was placed by the aggressor in this case (market order ? Limit order ?) as well as the people who got filled but to make it simple let’s assume the seller placed a market order and all the buyers at 0.3545 and below placed limit orders.

The role of the matching engine is to fill everyone at a price they are happy trading at and offer them best execution to be fair to all. The seller is happy selling at the necessary price to fill his liquidity demand if he placed market order but when he sees the best buy order at 0.3545 he can reasonably expect that a chunk of his order will be executed at that level even if the last chunk is executed at 0.3515. In other words executing the entire order at the final (and worst) price would be beyond the reasonable expectation of people willing to buy at 0.3545, and unfair to the seller (would not be « best execution to him »).

All in all this would drive away liquidity takers from the platform which is the opposite of what a good market microstructure is supposed to achieve.

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.