Skip to content
All library documents

Futures Order Execution with Adaptive Cancellation and Repricing

Code Quant course library

Summary

This document describes an execution wrapper for futures orders. It submits an order, checks its status, and can respond to an unfilled or partially filled order in several ways: cancel and reissue when the market price moves beyond a configured threshold, cancel and reissue after a configured wait, or cancel outstanding quantity automatically. When reissuing after a partial fill, it subtracts the filled quantity from the original size. The buy and sell paths apply opposite price movement tests and adjust replacement prices in the corresponding direction.

The wrapper also exposes account equity, ticker, depth, contract value, positions, and raw exchange information. Its order-handling logic includes retries and status checks intended to account for fills that occur during cancellation. However, the excerpt provides no execution measurements, slippage analysis, or comparison with passive alternatives. Recursive reissuing and exchange status timing can affect actual behavior, so the described controls do not guarantee a fill price or complete execution.

Key ideas

  • The order workflow checks status after submission and can cancel orders that remain unfilled.
  • Price-based cancellation can trigger a replacement order after the market moves past a configured threshold.
  • Time-based cancellation can reissue outstanding quantity after a configured delay.
  • Replacement order quantity accounts for the quantity already filled.
  • Cancellation races and recursive retries can affect execution, and the document provides no performance evaluation.

Tags

From a private course collection; the original is not published.