Order execution mechanics: from orders to actual fills · 3 / 6
Reconcile an IOC partial fill and the exposure it leaves behind
Immediate-or-cancel describes what happens to the unfilled portion of an order. It does not erase an existing position, undo a partial fill or promise that a requested exit will finish. Separating order state from position state is the central task. A cancelled order can coexist with a position that remains open.
Athenum6 minUpdated:
Reduce-only IOC exit against three bid levels
Assume an existing ten-unit long in a hypothetical linear product. A reduce-only sell limit for ten units has a limit of 99.80 USDT and IOC time in force. The available bids are four units at 100.00, three at 99.90 and five at 99.70. Assume those quotes remain available until matching, no other orders intervene, fees are charged in quote currency, and the venue applies the described IOC behavior. 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.
Check fills and position before retrying an exit order
Before sending another exit, reconcile execution identifiers, accumulated filled quantity and the current position. An acknowledgement is not a fill report, and a network timeout does not prove the first request failed. Repeating the original ten-unit sell without checking actual state can produce unwanted orders; venue reduce-only rules help constrain exposure but do not substitute for reconciliation. Use the order's stable client identifier and exchange status mechanisms where supported. Do not invent a universal retry rule across venues.
Example: IOC sell of 10 fills 7, leaving 3 units open
The first two bid levels are eligible. Four units sell at 100.00 and three at 99.90, producing 699.70 USDT of executed notional. The five-unit level at 99.70 is below the sell limit and is not eligible. Seven units fill, three units of the order cancel, and the original long position has three units remaining. Average execution price is 699.70 / 7 = 99.95714286 USDT, not the 99.80 limit price.
At an illustrative taker fee of 0.05%, the seven fills incur 0.34985 USDT. For this linear derivative, 699.70 USDT is the traded notional, not a cash receipt. If the original average entry was 90 USDT per unit, the closed portion realizes 699.70 − 7 × 90 = 69.70 USDT of price P&L. After the exit fee this is 69.35015 USDT, before allocated entry fees and funding. Released collateral is separate from profit. The remaining three units retain market and liquidation exposure.
| Bid level | Available units | Eligible units filled | Executed notional USDT |
|---|---|---|---|
| 100.00 | 4 | 4 | 400.00 |
| 99.90 | 3 | 3 | 299.70 |
| 99.70 | 5 | 0 | 0.00 |
| Total | 12 | 7 | 699.70 |
Open full-size diagram- Original long position: 10 units
- Units actually sold: 7 units
- Long units still exposed: 3 units
IOC vs FOK: fill-or-kill can leave the whole position open
A fill-or-kill instruction would have different semantics. Under the same static book and an atomic all-or-none rule, ten units cannot execute at or above 99.80, so the order would have no fill. That can protect a minimum executed quantity but leave all ten original units exposed. Choosing between IOC and FOK is therefore also a choice about tolerable residual exposure, not simply about avoiding fees.
Before acting
- Record requested quantity, side, limit and time in force.
- Sum fills by unique execution identifier.
- Compute average price and fees from executed quantity.
- Reconcile the remaining position separately from the cancelled order.
- Choose the next action from confirmed position state.
Check your understanding
If the first bid offers only two units while the other IOC assumptions stay unchanged, what fills, what fee is charged and what position remains?
Show the explained answer
Five units fill for 499.70 USDT, averaging 99.94 USDT. At 0.05%, the fee is 0.24985 USDT. Five units of the original long remain open even though the unfilled order remainder cancels.
Sources and further reading
Continue with Athenum
Related lessons
- Calculate realized R after partial profit taking
A 2R exit on a quarter of the position still left the whole trade at 0.625R gross. Weight each exit by its share, deduct fees and keep the original risk.
- Calculate execution VWAP by walking order-book depth
Walk a market order through order-book depth. Calculate the average execution price (VWAP) and slippage in basis points before costs outweigh the setup.