Event-Driven Order Cancellation and Replacement in a Tick Handler
Summary
This forum post analyzes how a trading strategy’s tick callback interacts with order cancellation and order status updates in an event-driven trading engine. A cancellation request does not immediately change an order’s status: the engine waits for an order event reporting the cancellation. Repeated ticks may therefore invoke cancellation logic while the original order remains active. Once the cancellation event is processed, the strategy can proceed to submit a replacement order.
The author identifies a potential issue when several active orders exist for one symbol. If the strategy cancels only the first active order but then tracks the latest order identifier, later callback cycles may move on to another order, leaving earlier orders canceled without replacement. This is a reasoned account of event sequencing and state tracking, not a documented test or general guarantee about every engine configuration. It suggests that strategies handling multiple active orders need explicit logic to iterate over and track each order’s lifecycle.
Key ideas
- Cancellation requests and cancellation status updates occur at different points in the event cycle.\nTick callbacks can repeat cancellation logic before the cancellation event is processed.\nA strategy that tracks only one order identifier may mishandle several active orders.\nOrder replacement logic should account for each active order’s status and lifecycle.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.