Skip to content
All library documents

Exchange Order Handling with Cancellation and Repricing

Code Quant course library

Summary

This code describes an exchange-trading wrapper that submits orders, checks their status, and optionally manages unfilled quantities. Its order workflow can cancel and reissue an order after a price move or a configured wait, using the remaining amount after partial fills. A separate automatic-cancellation option attempts to cancel orders that remain open. The wrapper also exposes exchange operations such as retrieving order details and market data across spot and derivatives markets.

The evidence is the implemented branching logic for filled, pending, partially filled, rejected, and cancelled orders, along with distinct buy and sell handling. This is execution plumbing, not a trading signal or evidence of strategy performance. The behavior depends on configuration and exchange responses; recursive reissuance, timing, and cancellation races may affect the final order state and execution price. No slippage, fee, or performance analysis is supplied.

Key ideas

  • The wrapper checks order status after submission and returns early for completed or failed orders.
  • Price-triggered cancellation can reissue an order at a price derived from the latest quote.
  • Time-based cancellation can retry after a configured delay, adjusting the quantity for partial fills.
  • Automatic cancellation handles orders that remain unfilled when that option is enabled.
  • Order management logic does not establish that the execution approach is profitable or safe under all exchange conditions.

Tags

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