Execution mechanics: from intended orders to actual fills · 6 / 6
Reconcile unique executions when order updates repeat
An order status is not an additional trade. Repeated delivery and fill/cancel races require a ledger that separates unique executions from cumulative summaries.
Athenum8 minUpdated:
Choose the unit of accounting
For this hypothetical linear instrument, use an execution identity scoped to the venue, account and product contract. An identical replay of the same execution is counted once. Distinct executions belonging to one order must still be counted separately: deduplicating by order ID alone would discard legitimate partial fills.
Retain execution quantity, price, fee and fee currency. Check the venue's identifier contract before assuming uniqueness across accounts or exchanges. If records with the same identity conflict, investigate instead of silently replacing a value. A disconnected stream is incomplete evidence; recover history and reconcile authoritative state.
Do not sum cumulative snapshots
Order updates often report cumulative executed quantity. A sequence showing 2, then 3, then 3 does not mean 8 units traded. Compare those snapshots with the unique execution ledger and the final position. An acknowledgement of a cancel request also does not prove that no simultaneous fill occurred.
Bybit documents a fill/cancel race that can produce two Filled order messages: one represents completion and the other a cancel rejected because execution already occurred. This is a venue-specific warning, not evidence of two separate transactions. The general audit task is to reconcile facts, not count status notifications.
Three units closed despite a repeated event
Start long 5 units with no other position changes. E1 sells 2 at 100 and charges 0.10 USDT; E2 sells 1 at 99.50 and charges 0.05 USDT. E2 is delivered again unchanged. Unique fills close 3 units, gross proceeds 299.50, average 99.833333… and fees 0.15 USDT. Two units remain long.
If the unfilled remainder is cancelled, those 2 units are not sold. Exit proceeds net of the specified fees are 299.35, not profit: entry cost and other costs are absent. In a separate race scenario, E3 sells the last 2 at 99 before cancellation; then 5 units close, even if two Filled status messages arrive.
| Delivery | Quantity | Price | New quantity counted |
|---|---|---|---|
| E1 | 2 | 100 | 2 |
| E2 | 1 | 99.50 | 1 |
| E2 identical replay | 1 | 99.50 | 0 |
Open full-size diagram- Scoped execution identities
- Unique fill ledger
- Cumulative order comparison
- Final position check
Original execution ledger; all stated fees in USDT. Reconcile distinct evidence without turning notifications into trades.
E2 identical replay: +0.
Missing history is not zero execution
After a connection gap, a locally empty ledger does not prove no trade occurred. Query the venue's execution history and position state before retrying blindly. Likewise, do not add fees in unlike currencies without keeping their units and a defensible conversion basis.
Before acting
- Scope identities to the actual venue contract.
- Count identical execution replays once.
- Keep distinct partial fills of one order.
- Compare rather than sum cumulative snapshots.
- Reconcile remaining position and unresolved history gaps.
Check your understanding
E2 arrives three times, no E3 exists, and cancellation of the unfilled remainder is confirmed. How much remains long?
Show the explained answer
2 units. E1 closes 2 and unique E2 closes 1, so 5 − 3 = 2 remain. Repeated E2 delivery adds no execution. Cancellation removes an instruction, not the remaining position.