Order Retry and Market Data Handling for Perpetual Futures
Summary
This document presents an exchange interface for perpetual futures that combines account and market queries with order placement, cancellation, and status checks. Its buy and sell routines submit orders, inspect their reported state, and can react to incomplete fills using configurable price-based or time-based cancellation. When a cancellation succeeds, the routines may resubmit the remaining quantity using a price derived from the latest ticker and a configured adjustment. An automatic cancellation option can instead cancel an order that remains incomplete.
The interface also exposes position, contract value, order book, ticker, and funding-rate information, alongside leverage setup for different margin modes. The code illustrates order-management mechanics rather than a trading signal or tested execution policy. It provides no evidence on fill quality, slippage, reliability, or profitability, and behavior depends on exchange responses and configuration. Recursive resubmission and cancellation races can affect live execution, so the described mechanics alone do not establish safe order handling.
Key ideas
- Orders are checked after submission, with handling that depends on whether they filled, partially filled, or remain open.
- Configurable price and time conditions can trigger cancellation and resubmission of the unfilled amount.
- Buy and sell routines apply direction-specific price comparisons when checking for price movement.
- The interface retrieves perpetual futures positions, contract values, depth, ticker data, and funding rates.
- No execution quality or strategy performance evidence is provided.
Tags
From a private course collection; the original is not published.