Skip to content
All library documents

How Aggressive Limit Orders Match and Use Price Improvement

Article Quant Q&A · Author: Athena Wisdom

Summary

The example explains how a marketable limit buy interacts with resting asks at different prices. A buy limit specifies the maximum price the buyer will pay per unit, while matching proceeds against available sell orders from the lowest price upward. The buyer therefore takes the lower-priced offer first, then buys from the next offer at that offer’s listed price, up to the limit price.

In the example, two units are requested with a maximum price of $200 each. One unit is available at $100 and another at $200, so the buyer pays $300 in total; the remaining $100 of the initially reserved amount is not needed for the executed trade. This is a basic price-time matching illustration rather than a full account of exchange-specific balance reservation, fees, or order-book priority rules.

Key ideas

  • A limit buy sets a maximum price per unit rather than a fixed total spend.
  • Marketable buys match the lowest available asks first.
  • Each execution occurs at the resting ask price, which can be below the buyer’s limit.
  • The total debit reflects executed prices, so unused reserved funds are released or remain available.

Tags

Full text
# How should Aggressive Limit Orders be Processed in a Limit Order Book


# How should Aggressive Limit Orders be Processed in a Limit Order Book












I am a little confused about how orders get processed in a limit order book, hope to get a better understanding with this post.

If we start off with an order book

```
Asks:
SELL 2 units at 300
SELL 2 units at 200
SELL 1 units at 100

            Bids:
    BUY 1 units at 50
```

and a user places a new limit order which causes his account balance to decrease by `$400` (2x200 = `$400`),

```
New Order: BUY 2 units at 200
```

Is the resulting order book supposed to be

### Order book #1

```
Asks:
SELL 2 units at 300
SELL 1 units at 200

            Bids:
    BUY 1 units at 50
```

because his order of quantity `2` first matches with `1 units at 100` then matches `1 units at 200`

or should the resulting order book be

### Order book #2

```
Asks:
SELL 2 units at 300
SELL 0.5 units at 200

            Bids:
    BUY 1 units at 50
```

because his order is of `$400`, so it first matches with `1 units at 100` for `$100`, then the remaining `$300` matches with `1.5 units at 200`.

Based on casually trading on crypto exchanges, I think we should end up with Order book #2.

However, based on reading some code for a Limit order book, it appears we should end up with Order book #1. If so, then what happens to the `$400` that was deducted from the trading account when the order of `BUY 2 units at 200` was first placed? Is the unused $100 returned back to the user's account after his order has been processed by the matching engine?

Thank you!

## Answer by stackoverblown (score 2)

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

A limit buy means he is willing to pay up to \$200 for 1 unit. Since there is one offer of 1 unit at \$100 that one will be bought out first followed by 1 unit at \$200. So only a total of \$300 of his money will be deducted.

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.