Skip to content
All library documents

Spot Grid Order Placement with Fixed Price Steps and Position Limits

Code Quant course library

Summary

This example implements a spot grid that keeps one buy and one sell order working around the latest top of book. At timed intervals, when neither side has an outstanding order, it places orders offset from the best bid and ask by half the configured grid spacing. The order size and a position-based cap are configurable. If only one side remains tracked, it cancels all orders to restore the paired setup.

When an order fills completely, the strategy removes it from tracking, cancels remaining orders, and places a new pair around the fill price, adjusted against the current bid and ask. The step multiplier is fixed at one, though commented alternatives describe widening spacing as position grows. The document provides no backtest or results, and does not explain how to choose grid parameters or account for fees and adverse price movement. Its cap check and order lifecycle behavior also warrant careful review before live use.

Key ideas

  • The strategy periodically places paired buy and sell orders around the current top of book.
  • Grid spacing, order size, and a position-based limit are configurable.
  • A full fill triggers cancellation of remaining orders and placement of a new pair around the fill.
  • The active step multiplier is fixed, while commented examples suggest increasing it with position size.
  • No performance evidence or fee analysis is provided, and order handling needs review.

Tags

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