7 days Pro+ free · no cardStart my free trial

Order execution mechanics: from 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:

Deduplicate by execution ID, not by order ID

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. Here quantities denote units of the underlying asset and prices are USDT per unit. The derivative examples settle linearly in USDT; a contract multiplier would first need conversion into these units.

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.

Cumulative fill updates and fill/cancel races

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.

Example: two fills close 3 of 5 units despite a repeat

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, executed notional 299.50 USDT, average 99.833333… and fees 0.15 USDT. Two units remain long.

If the unfilled remainder is cancelled, those 2 units are not sold. The 299.50-USDT notional is not a cash receipt on this derivative. At an original average entry of 90 USDT per unit, the closed price P&L is 299.50 − 3 × 90 = 29.50 USDT; after the specified 0.15-USDT exit fees it is 29.35 USDT, before allocated entry fees and funding. Released collateral is not profit. 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.

Original execution ledger; all stated fees in USDT
DeliveryQuantityPriceNew quantity counted
E121002
E2199.501
E2 identical replay199.500
Reconcile distinct evidence without turning notifications into trades.Open full-size diagram
  1. Scoped execution identities
  2. Unique fill ledger
  3. Cumulative order comparison
  4. Final position check
Reconcile distinct evidence without turning notifications into trades.
Reconcile distinct evidence without turning notifications into trades.

Original execution ledger; all stated fees in USDT. Reconcile distinct evidence without turning notifications into trades.

E2 identical replay: +0.

Mistake: assuming no fills after a connection gap

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.

Sources and further reading

Continue with Athenum

Related lessons

Related courses