To learn more about Market Orders, please read What are Market orders?
A long/buy market order will be filled at the best or lowest ask price in the order book.
A short/sell market order will be filled at the best or highest bid price in the order book.
To help clarify how market orders fill, we will use our ADAUSD order book as an example. The contract size for this pair is 20 ADA.
We can tell from the order book that the best ask price (Sell) is $2.6590 and the best bid price (Buy) is 2.6589. The second-best ask price (Sell) is $2.6591 and the second-best bid price (Buy) is $2.6586.
Long/Buy Market Order
If you place an ADA/USD buy market order with a quantity of 100, the order will be filled and executed immediately at the best ask price of $2.6590.
If you place an ADA/USD buy market order with a quantity of 300, the market order will be filled immediately, with 224 contracts filled at the best ask price of $2.6590, and the remaining 76 contracts filled at second best ask price of $2.6591. This is because at the best ask price of $2.6590, there are only 224 contracts available. The rest must be filled at the next best price available.
When orders fill at different prices due to limited availability of contracts for each price, this is known as Slippage.
The average fill price will be:
{[(Quantity A X ADA Contract Size X Execution Price A) + (Quantity B X ADA Contract Size X Execution Price B)] / (Total Quantity X ADA Contract Size)}
{[(224 X 20 X 2.6590) + (76 X 20 X 2.6591)] / (300 X 20)} = $2.65902533333
Short/Sell Market Order
If you place an ADA/USD sell market order with a quantity of 500, the order will be filled immediately and executed immediately at the best bid price $2.6589.
If you place an ADA/USD sell market order with a quantity of 1500, the order will be filled immediately, with 1005 contracts filled at best bid price 2.6589), and the remaining 495 contracts filled at second best bid price of $2.6586. This is because at the best bid price of $2.6589, there are only 1005 contracts available. The rest must be filled at the next best bid price available.
Once again, you would experience Slippage.
The average fill price will be:
{[(Quantity A X ADA Contract Size X Execution Price A) + (Quantity B X Contract Size * Execution Price B)] / (Total Quantity X ADA Contract Size)}
{[(1005 X 20 X 2.6589) + (496 X 20 X 2.6586)] / (1500 X 20)} = $2.658801