Why Atomic Order Processing Matters
FOK (Fill-or-Kill) and IOC (Immediate-or-Cancel) orders require transactional semantics:- FOK: either the full quantity fills, or nothing changes. If the book doesn’t have enough liquidity, no balances should move.
- IOC: the filled portion commits, the unfilled remainder is silently discarded.
How DeltaBuffer Works
TheDeltaBuffer is an overlay on top of the engine’s balance and order state. It intercepts all writes during an order’s execution and holds them in memory until either commit() or rollback() is called.
commit().
commit() vs rollback()
commit() — flushes the overlay into the committed state. All buffered balance and order changes become permanent. Called on:
- Successful GTC order placement
- Successful IOC partial/full fill
- Successful FOK full fill
rollback() — discards the overlay entirely. Zero-cost: the overlay maps are cleared and the entry log is dropped. The underlying state is unchanged. Called on:
- FOK order that cannot fully fill
- Any order that fails validation mid-execution
Integration with FOK
FOK uses a two-phase approach enabled by the delta buffer:Integration with IOC
IOC uses a single-pass approach:Performance
The 841ns rollback cost is amortized over all FOK rejections. For a strategy placing many FOK orders, this overhead is negligible compared to network round-trip time.