Skip to content
All library documents

A Single-Asset Grid Bot with Paired Limit Orders

Article Strategy library · Author: 红色的雪

Summary

This document describes a continuously running, single-asset grid bot that monitors the order book and outstanding orders. It proposes selling when the best bid rises sufficiently above a reference derived from existing sell orders or a base price, then placing a buy order one configured spread lower after the sale fills. Conversely, a sufficiently low ask can trigger a buy, followed by a sell order above it once the buy fills. Parameters set the base price, spread, grid spacing, trade size, and upper and lower price bounds. The loop polls periodically and cancels an entry order if it remains unfilled through its checking window.

The code provides no backtest configuration or performance evidence. Its behavior depends on exchange depth and order-status data, and the bounds can suppress trading outside a specified range. The implementation also contains details that warrant scrutiny: the buy-side liquidity test checks bid size, and the buy signal records the bid as its order price despite being triggered by the ask. Thus the example illustrates a paired-order grid structure, but should not be treated as verified production logic or evidence of profitability.

Key ideas

  • The bot pairs filled limit orders with opposing orders at a configured price offset.
  • Order-book prices and existing orders determine whether a grid trade is attempted.
  • Parameters define the reference price, spread, grid spacing, trade quantity, and trading bounds.
  • Unfilled entry orders are canceled after repeated checks, while the main loop runs continuously.
  • The code reports no performance evidence and includes order-book price and liquidity checks that merit validation.

Tags

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