Skip to content
All library documents

A Futures Grid Strategy That Replaces Filled Orders at Fixed Gaps

Code Quant course library

Summary

This example describes a two-sided grid for a futures market. It tracks open buy and sell limit orders, checks their statuses, and after a fill places a replacement order on the opposite side at a configured percentage gap. It also maintains another order farther along the grid, rounds prices and quantities to exchange increments, and seeds an initial order near the current bid or ask when one side has no orders.

The logic cancels orders that are too close together and caps the number of resting orders by removing an outer order. It relies on configured parameters such as quantity, price and quantity increments, gap, and maximum order count, alongside exchange ticker and order-status responses. This is an implementation example, not an evaluated strategy: it gives no backtest, profitability evidence, fee model, or position and liquidation controls. The accompanying warning highlights the substantial risk of leveraged grid trading in extreme moves.

Key ideas

  • The grid maintains buy and sell limit orders around the current market.
  • A filled order prompts replacement orders on the opposite side at configured price gaps.
  • Price and quantity are rounded to configured exchange increments.
  • Orders that are too closely spaced or exceed the configured count are canceled.
  • The example supplies no performance evidence and warns that futures grids can face liquidation risk in extreme markets.

Tags

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