TradeViora AcademyLearn. Analyze. Practice. Trade Smarter.
Menu

FREE FINANCIAL EDUCATION

Cancel-replace races and order state

Track executions that occur while a cancellation request is in flight.

Learning objectives

  • Track executions that occur while a cancellation request is in flight.
  • Reconcile target position with confirmed fills and remaining live quantity.

Prerequisites: Understand asynchronous messages and partial fills.

Mechanism and interpretation

Sending a cancel request does not mean the exchange has already canceled the order. Until the matching engine processes it, the order may execute. The client should distinguish pending cancel, confirmed canceled, partially filled and fully filled states. A replacement sent without reconciling in-flight fills can create more exposure than intended.

Use exchange acknowledgments and execution identifiers to update a position ledger. Sequence and duplicate handling matter when acknowledgments and fills arrive through different paths. A target quantity is a desired economic state, whereas an order's total and remaining quantities are protocol fields. Their semantics vary across systems. The safe calculation in this lesson starts from confirmed filled quantity and the explicitly stated target, then accounts for any still-live orders.

Worked case · synthetic data

A synthetic client wants 100 units and has a live buy 100 with 20 already filled. It sends a cancel for the remaining 80. Before cancellation takes effect, another 30 fills. The cancel acknowledgment removes only the remaining 50. Confirmed position is now 50; to reach target 100, the new order should seek 50, not the earlier 80. Submitting 80 would produce 130 if fully filled.

Failure modes and context

A delayed fill notice may arrive after a cancel acknowledgment even though the match occurred earlier. Do not infer economic ordering solely from receipt order without protocol reconciliation. Replace messages may express total quantity or remaining quantity differently. Recovery after disconnect needs an authoritative order/position check before resubmitting presumed missing orders.

Practice assignment

Target position 200, current confirmed fills 60, live remainder 140. A cancel is sent, then 40 more units execute before the remaining 100 is canceled. Calculate current position and required replacement quantity. What happens if the old 140 is blindly resubmitted and fully filled?

Worked answer

Current position=60+40=100. Required replacement=200−100=100, assuming no other live buys or sells. Blindly submitting 140 produces 240 total, an overshoot 40. Preserve pending states and reconcile late fills; the cancel request itself is not proof that the old order stopped participating immediately.

Check your understanding

Question 1

Can an order fill while cancellation is pending?

  1. Only after a session ends
  2. Yes, until cancellation is processed
  3. No, the client request freezes the exchange
Reveal answer and reasoning

B. Yes, until cancellation is processed

Network and matching-engine processing create a period in which the order may remain live.

Question 2

What is case replacement quantity after 50 total fills?

  1. 50
  2. 80
  3. 100
Reveal answer and reasoning

A. 50

Subtract confirmed position 50 from the desired target 100.

Question 3

What is practice overshoot from blind 140 replacement?

  1. 100
  2. 140
  3. 40
Reveal answer and reasoning

C. 40

Existing 100 plus new 140 gives 240 against a 200 target.

Sources and further reading

The explanations, operational rules, numerical cases and questions on this page are original TradeViora Academy educational material. Source documents support definitions or conventions; they do not establish the profitability of an illustrated rule.

Third-party rights remain with their owners. TradeViora Academy is not affiliated with these organizations. Examples are hypothetical and exclude real orders. Source review: 26 November 2026.

Continue learning

Open related learning tools · Practice library · Learning downloads