Sub topic 8
Limit Orders: Certain Price, Uncertain Fill
What a limit order controls
A limit order tells the market the worst price you will accept.
- A buy limit sets the highest price you will pay.
- A sell limit sets the lowest price you will accept.
The limit protects your price, but it does not guarantee that the order will trade. Another trader must be willing to sell or buy at your limit, and your order must reach its place in the exchange’s price-and-time queue.
This chapter assumes you understand shares, tickers, brokerage accounts, and the basic meaning of bid, ask, and spread.
Suppose XYZ is quoted at a bid of $49.98 and an ask of $50.02. A buy limit order at $50.00 will not immediately fill because the lowest available seller is asking $50.02. If sellers later offer shares at $50.00 or less, your order may fill.
A buy limit at $50.05 could fill immediately because it is above the current ask. It still cannot pay more than $50.05. This is sometimes called a marketable limit order. It provides a price ceiling while allowing an immediate fill when enough liquidity is available.
A fill walkthrough
Assume the sell side of the order book contains these offers:
| Ask price | Shares available |
|---|---|
| $50.02 | 100 |
| $50.05 | 200 |
| $50.10 | 500 |
A market buy for 400 shares could consume all 100 shares at $50.02, all 200 at $50.05, and 100 at $50.10. A buy limit at $50.05 could consume only the first 300 shares. The remaining 100 shares stay unfilled because the next available price exceeds the limit.
def fill_buy(asks, qty, limit=None):
"""Simulate a buy against (price, size) asks."""
filled, cost = 0, 0.0
for price, size in sorted(asks):
if limit is not None and price > limit:
break
take = min(size, qty - filled)
filled += take
cost += take * price
if filled == qty:
break
average = cost / filled if filled else None
return filled, average
asks = [(50.02, 100), (50.05, 200), (50.10, 500)]
print(fill_buy(asks, 400)) # (400, 50.055)
print(fill_buy(asks, 400, limit=50.05)) # (300, 50.04)The limit order received a better average price, but it filled fewer shares. The unfilled portion may remain open, expire, or be canceled depending on its time-in-force setting.
Choose the limit deliberately
Before submitting, check the current ask for a buy or bid for a sell. Decide whether your priority is price control or a complete fill. A limit placed far from the current quote may remain open while the market moves away.
Check the time in force as well. A day limit order normally expires at the end of that trading session. A good-til-canceled (GTC) order can remain active longer, subject to your broker’s maximum duration and rules. Review open GTC orders because an old order can fill after your intentions have changed.
Exercise
XYZ has an ask of $25.10. You submit a buy limit for 50 shares at $25.00. What is guaranteed, and what is uncertain?
Show answer
The order cannot pay more than $25.00 per share. Whether it fills, and how many shares fill, are uncertain.