Grid Strategy
The Grid Strategy is a mean-reversion trading strategy that profits from price oscillations within a range by placing buy and sell orders at fixed price intervals.
How It Works
The strategy creates a "grid" of price levels around a base price. When the price moves up through grid levels, it sells. When price moves down through grid levels, it buys. This captures profits from price bouncing back and forth.
The Trading Logic is as follows:
Price moves UP (crosses to higher level) → SELL (take profit or short)
Price moves DOWN (crosses to lower level) → BUY (buy the dip or cover short)
Parameters
grid_size (default: 5)
Number of grid levels above AND below the base price
Total levels = 2 × grid_size + 1 (e.g., 5 gives 11 levels: -5 to +5)
grid_spacing (default: 0.01 = 1%)
Percentage price difference between adjacent grid levels
Example: If base price is $100 and spacing is 0.01, levels are at $99, $100, $101, etc.
order_size (default: 100)
Dollar amount to trade at each grid level crossing
initial_balance (default: 10000)
Starting capital for the strategy
Protection Threshold (default: 1)
In prediction markets, prices can go to 0. This setting sells ALL positions if price drops X extra levels below your grid bottom.
Fee Rate (default: .001)
Works in fee per taker transaction during your PnL simulation


Example Scenario
Setup:
grid_size=3, grid_spacing=0.01, base_price=$100
Grid levels: $97 (level -3), $98 (-2), $99 (-1), $100 (0), $101 (+1), $102 (+2), $103 (+3)
Trading sequence:
Price at $100 (level 0) → No action
Price moves to $101 (level +1) → SELL $100 worth
Price moves to $102 (level +2) → SELL another $100
Price moves back to $101 (level +1) → BUY $100 worth
Price moves to $100 (level 0) → BUY another $100
This captures profit from the oscillation!
Last updated