Why Does a Price Change Rejoin the Queue?
Cancel and reprice an order, then observe time priority reset and self-trade prevention block a false fill.
- Explain why cancel-replace loses the old time priority
- Observe self-trade prevention cancel a new remainder
- Separate risk rejection, cancellation, and a real fill
- PREVIOUSWho Leaves the Spread Behind?
- CURRENTWhy Does a Price Change Rejoin the Queue?
Cancel and reprice an order, then observe time priority reset and self-trade prevention block a false fill.
- NEXTFree sandbox
Think about these questions first.
Choose an answer before opening the explanation. You can add anything unexpected to your review list.
Q01Why lose queue priority when improving an order’s price?+
Changing price changes the promise to the market and creates a new order. Keeping the old timestamp would let traders repeatedly edit while camping at the front of the queue.
A matching engine must do more than find a counterparty: it must reject unsafe state transitions. Cancel-replace, self-trade prevention, and frozen-asset rules decide whether a quote becomes a fill, a cancellation, or a risk rejection.
Changing price is not editing text
Place a bid at 100, then change it to 102. The system should not mutate the old order in place, because a new price must not inherit old time priority. Release the old frozen balance, close the old order, then enqueue a new order with a new sequence.
LAB / credits
Limit orders enter the queue; only a crossed book turns them into fills.
Repricing is a new queue entry
Cancel-replace releases the old freeze and re-enters with a new sequence. If the new price crosses the book, self-trade protection still applies.
Read the book first: best ask is the lowest sell, best bid is the highest buy. Matching starts only when buy price reaches sell price.
- 01
Book created: best ask 102 分(两个价位相同's 订单),best bid 98 .price and time priority must be preserved。
Use the slider to return to an earlier step. Continuing from there replaces the later history with a new sequence.
Self-trade creates a false signal
If one account has a buy at 100 and a sell at 99, a naive loop lets the account trade with itself. No real risk transfers, but volume and last price change. The lab cancels the newer order’s remaining quantity, releases its freeze, and records the reason.
Expand: how this step works
replace(old, newPrice, newQuantity):
release(old.remaining)
close(old)
new = enqueue(newPrice, newQuantity, nextSequence)
match(new)
if buyer.trader == seller.trader:
cancel(new.remaining)
emit("SELF_TRADE_PREVENTED")
Risk controls are part of the state machine, not a post-processing decoration. Every rejection, cancellation, and fill should be replayable so an auditor can check balances, freezes, and book state.