Order events and queue changes
Reconstruct identified queues and prove what aggregate depth cannot reveal about a resting fill.
32 minutes · intermediate · Original Poker4Quant lessonWhat you will learn
Replay additions, cancellations and FIFO executions, certify per-order conservation and derive sharp own-fill possibility bounds when cancellation locations are hidden.
Prerequisites: Price-time order matching · Quotes, spreads and reference prices · Book depth and execution curves
Follow identified orders through time
A depth snapshot answers how much supply is displayed at a price. A queue history asks which identified order still owns each unit after arrivals, withdrawals and executions. These are different questions. A reduction in displayed size might be a trade, a cancellation, or the net effect of several events. It cannot automatically be counted as trading volume or progress toward your own fill. This lesson constructs a small history whose accounting is exact, then deliberately hides cancellation locations to find what the remaining observations can and cannot identify.
Assume one synthetic venue and one ask price of 101 chips per indivisible unit. All orders are fully displayed and execution is strictly first in, first out at this price. Initially A offers four units, Your order offers two, and B offers four, in that arrival order. There are no hidden orders, auctions, replacements, fees, lost messages, other price levels or simultaneous events. An optional new order C adds two units after B. A cancellation then removes c units from A and B, never from Your order or C. Finally an incoming buyer executes exactly q available units. These are stipulated histories, not observations from a real exchange or a stochastic forecast.
Replay events without turning cancellations into trades
Store an order identifier, queue position and remaining quantity for each order. An add creates a new entry at the back of this same-price queue. A cancel reduces the specified entry without creating a transaction. An execution consumes available units from the front, reducing each affected order and recording its traded quantity. Remove an entry from the active queue when its remaining quantity becomes zero, while retaining its history in the audit ledger. Reject a cancellation exceeding that order’s available units. Silently clipping an impossible event would conceal a broken reconstruction.
The Nasdaq TotalView specification distinguishes order additions, executions and cancellations with order references. Its separate delete message removes all remaining shares. Those distinctions motivate our typed ledger, but this activity is not an implementation of that protocol. Here a full withdrawal is represented by a cancel quantity equal to the remaining amount. Coinbase’s displayed time-priority rule motivates the FIFO assumption for fully displayed orders. Real feeds and venue rules include additional cases excluded here. In particular, a generic trade print should not be subtracted again after its corresponding identified execution has already reduced the book.
Derive the queue and conservation certificates
Let a be the canceled quantity from A and let c−a be the canceled quantity from B, where 0≤a≤c≤4. Immediately before the buyer arrives, the queue quantities are (4−a, 2, 4−c+a, L), where L is either zero or two for C. Let h=4−a be the units ahead of Your order. The own fill is f=min(2,max(0,q−h)). Subtracting h accounts for earlier supply, taking the maximum prevents a negative fill, and the minimum prevents selling more than your two units. If q=h, the buyer stops exactly before Your order and f=0.
For every order i, initial quantity plus newly added quantity equals canceled quantity plus executed quantity plus final resting quantity. Summing gives 10+L=c+q+R, so final displayed depth is R=10+L−c−q. Both identities are necessary checks. Neither alone certifies FIFO: allocating a unit to B while an executable unit remains in A can conserve all units and still violate priority. The remaining amount ahead of Your order after the buyer is max(0,h−q). Your remaining amount is 2−f. Keep those two quantities separate from total displayed depth, which also includes later orders.
Build two histories with the same aggregate tape
Take c=2, q=5 and no C arrival. Cancel both units from A, so a=2. Before execution the queue is (2,2,4). Five purchases consume A’s two, your two and one from B. Final quantities are (0,0,3), and your fill is two. Independently enumerate the five executed unit labels: A,A,Your,Your,B. The aggregate depth starts at ten, falls to eight after cancellation and falls to three after execution. There were five traded units, not seven.
Now cancel both units from B instead, so a=0. The pre-execution queue is (4,2,2). The same buyer consumes A’s four and one of yours. Final quantities are (0,1,2), and your fill is one. Enumerating A,A,A,A,Your confirms it. The aggregate depth tape is again ten, eight, three, with two canceled units and five executed units. Even knowing which depth change was cancellation and which was execution does not locate that cancellation within the queue. The pair is a constructive failure of identification, rather than a statement that the two histories are equally likely.
Bound a hidden cancellation and challenge the result
Suppose c and q are known but the split a is hidden. Every integer a from zero through c is allowed under our four-unit A and B capacities. Own fill increases as a increases, so its smallest possible value is min(2,max(0,q−4)), and its largest is min(2,max(0,q−4+c)). Enumerating the finite splits gives the exact set of compatible integer fills. In the worked example that set is {1,2}. The lower and upper limits are possibility bounds under this specified observation model. They are not confidence limits and assign no probabilities to either fill.
In the workshop, move cancellation units between A and B while conserving c, change the buyer’s quantity and optionally append C. Construct each order’s execution allocation and select every own fill compatible with hiding only the cancellation split. Then audit the remaining-ahead, own-remaining and total-depth entries. The actual identified fill can change while the compatible set remains fixed: hiding an identifier deliberately changes the question. Adding C behind B changes total depth and available buyer capacity, but does not improve your priority for a fixed feasible q. At q=0 nobody trades; at full depletion every available order fills. With c=0 the compatible set is a singleton. An interval collapses whenever every allowed split implies the same own fill, even if the split itself remains unknown.
A deterministic replay explains a supplied history. To predict a future fill probability, you would also need a probability model for future arrivals, withdrawals, competing prices and timing. A favorable reconstruction does not provide that model. Likewise, if only beginning and ending depth were available, even the cancellation and execution totals might be unknown. Our possibility bounds deliberately use more information than those two snapshots. Always state exactly which event attributes were observed before declaring a fill identified or ambiguous.
Worked example
Initial queue A:4, Your:2, B:4 at 101. Two units cancel before a five-unit buyer. Compare cancellation entirely from A with entirely from B, then hide that location.
- Cancel A: pre-buyer queue (2,2,4); execute (2,2,1); residual (0,0,3). Your fill=2.
- Cancel B: pre-buyer queue (4,2,2); execute (4,1,0); residual (0,1,2). Your fill=1.
- Both aggregate histories are 10 → 8 → 3. Conservation is 10=2 canceled+5 executed+3 resting.
- For hidden split a=0,1,2, compute h=4,3,2 and own fills 1,2,2. Exact compatible set is {1,2}.
- Endpoint formulas give lower=min(2,max(0,5−4))=1 and upper=min(2,max(0,5−4+2))=2. Physical unit enumeration independently verifies both witnesses.
Equal aggregate event totals need not identify own execution. The identified tape gives an actual fill; the coarsened tape gives a set without probabilities.
Hands-on: Reconstruct and hide a queue history
Move cancellation locations, construct identified executions and select all fills compatible with an anonymous cancellation.
Reconstruct and hide a queue history
One ask price 101; whole displayed units; FIFO; no hidden orders or fees. Initial oldest-to-newest queue: A four, Your two, B four. New C joins behind B. Draft lasts for this visit and earns no game or lesson credit.
Edit the identified history
Total canceled 2: from A 2, from B 0. Buyer executes 5. C arrival zero units.
Event order: optional add C, cancel named units, then execute buyer. Aggregate depth tape: 10 → 10 → 8 → 3. If capacity falls, buyer size is capped to available units.
Construct identified executions
Allocate the buyer across surviving orders. Your draft may conserve volume yet violate priority.
Order A
Available before buyer 2; canceled 2; draft executed 0; draft resting 2.
Order Your
Available before buyer 2; canceled 0; draft executed 0; draft resting 2.
Order B
Available before buyer 4; canceled 0; draft executed 0; draft resting 4.
Order C
Available before buyer 0; canceled 0; draft executed 0; draft resting 0.
Draft total executed 0; required buyer 5.
Hide only the cancellation split
Keep total cancellation, buyer, arrival and aggregate tape. Forget how cancellation was divided between A and B. Select every possible own fill. No probabilities are supplied.
Construct identified executions and the hidden-split set.
Common mistakes
- Counting a canceled unit as a transaction.
- Using all depth as units ahead, including orders behind you.
- Treating a conserved but out-of-priority allocation as valid.
- Assuming all compatible hidden histories have equal probabilities.
- Using a supplied deterministic history as a forecast of future fills.
Keep these ideas
- Replay each identified event against current remaining quantity.
- Check per-order and total conservation, then check FIFO separately.
- Own fill is min(2,max(0,q−units ahead)).
- Hidden cancellation locations can leave a sharp set of possible fills.
Further reading
- Nasdaq TotalView-ITCH 5.0: Add and Modify Order Messages ↗
Read sections 1.3, 1.4.1, 1.4.3 and 1.4.4, printed pages 12-15, including identified cumulative reductions and zero removal. PDF pages 14-15 also inspected. Supports distinctions among add, execution, cancellation and delete only. Toy FIFO histories, bounds and exercises are original; not a protocol implementation or video review. Checked 2026-10-25.
- Coinbase Exchange Trading Rules: 1.71-1.72 ↗
Read 1.71-1.72: earliest displayed maker at best price, followed by subsequent displayed orders. Used only to motivate the fully displayed same-price FIFO assumption. Icebergs and real venue completeness are excluded; original synthetic queue and hidden-cancellation proof. No video reviewed. Checked 2026-10-25.