Skip to content
All library documents

A Spot Grid Strategy That Replaces Filled Orders at Fixed Price Gaps

Code Quant course library

Summary

This implementation describes a two-sided spot grid. It tracks buy and sell limit orders, checks their exchange status, and, when one fills, places a replacement order on the other side at a configured percentage gap. It rounds prices and quantities to configured increments and adjusts prices against the current best bid or ask. When one side has no working orders, it seeds an order near the market; it also cancels an order when the tracked count exceeds a configured limit.

The evidence is the order-management logic itself: the same replacement cycle is applied after buy and sell fills. No backtest, profitability data, or explicit market-selection criteria are supplied. The code depends on external configuration and exchange responses, and it does not discuss inventory limits, fees, partial fills, or robust recovery after restarts. A comment notes that high volatility may suit grid trading while warning about liquidation risk when using contracts; the implementation shown is configured for spot trading.

Key ideas

  • The strategy maintains buy and sell limit orders around the current market.
  • A filled order leads to a replacement on the opposite side at a configured percentage gap.
  • Prices and quantities are rounded to configured exchange increments.
  • The strategy seeds an order when a side is empty and cancels orders when counts exceed a limit.
  • The document provides no backtest or evidence of profitability.

Tags

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