Execution Logic for Delivery Futures with Order Repricing and Cancellation
Summary
This document describes a wrapper for trading delivery futures. It places buy and sell orders, checks their status, and can respond to unfilled or partially filled orders using price-based cancellation, timed cancellation, or automatic cancellation. When an order is canceled, the wrapper can submit a replacement at a price adjusted from the latest market quote and reduce the replacement quantity by the amount already filled.
The implementation also exposes account equity, contract and position details, ticker data, and market depth. Its order-handling paths illustrate a practical execution approach, but there is no evidence that repricing improves fills or costs. The behavior depends on configuration and exchange responses, and the excerpt does not establish how repeated retries, interruptions, or edge cases are managed across the entire wrapper.
Key ideas
- The wrapper checks an order after submission and branches on its reported status.
- Price-triggered and time-triggered cancellation can lead to a replacement order.
- Replacement quantity is reduced by the amount already filled on the original order.
- Automatic cancellation can be used when other cancellation modes are not active.
- The code exposes futures account, position, quote, and depth information but provides no execution-performance evidence.
Tags
From a private course collection; the original is not published.