State Machines for Single-Contract Orders and Two-Leg Arbitrage
Summary
The article explains why automated trading needs explicit order-state management. A signal does not guarantee a fill: an order may remain open, fill partially, be canceled, or require a replacement. The program should track the action it submitted and wait for the corresponding order or trade feedback before deciding what to do next. This helps prevent duplicate opens or closes and unintended simultaneous long and short positions.
For a single contract, the author recommends defining states around actions such as opening, canceling an opening order, closing, and canceling a closing order, then mapping each possible response to the next state. Cancellation handling can determine whether to retry at the same price, adjust for slippage, or use the opposing quote. For two-leg arbitrage, the state model must also represent each leg’s actions and the waiting period while the second leg catches up. The article refers to diagrams that are not included in the text, and offers conceptual examples rather than implementation details or performance evidence.
Key ideas
- Automated order handling must account for fills, partial fills, cancellations, and pending responses.
- Represent each submitted action and its expected feedback as explicit states and transitions.
- Cancellation logic can choose whether to retry at the same price or alter the price to complete an order.
- Two-leg arbitrage needs states that track both contracts and wait for the second leg to form the pair.
- The article is conceptual and its referenced state diagrams are unavailable in the text.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.