Skip to content
All library documents

Futures Order Execution with Retries and Partial Fill Aggregation

Article Strategy library · Author: 一拳男孩

Summary

This document describes a helper for opening and closing futures positions. It sets trade direction, adjusts the quoted last price by a configurable slippage amount, submits an order, and polls its status. If an order remains pending past the timeout, the helper cancels it and continues. Completed orders are accumulated so the requested amount can be filled across multiple orders, with a volume-weighted average price reported at the end. The example uses an ETH/USD futures contract and demonstrates opening, closing, and checking positions.

The material is implementation-focused rather than a tested trading strategy: it gives no performance results or systematic evaluation. Its behavior depends on exchange API conventions, contract face value, precision settings, and the reliability of cancellation and order-status calls. The recursive retry and cancellation logic also deserves careful review before live use, especially around partial fills and persistent pending orders.

Key ideas

  • The helper adjusts order prices by a configurable slippage amount before submission.
  • It polls pending orders and attempts cancellation after a configured timeout.
  • Completed fills are accumulated and combined into a volume-weighted average price.
  • Contract value and price and amount precision settings affect order calculations.
  • The example demonstrates futures order handling but provides no strategy performance evidence.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.