DEV Community

TateLyman
TateLyman

Posted on

Grid Trading on Solana: How I Made 11.7% While SOL Dropped 37%

Grid trading works by placing buy orders below the current price and sell orders above it. When price oscillates, you profit from every swing.

I built a grid trading bot for Solana that uses Jupiter DEX. Here's exactly how it works and the results.

The Strategy

  1. Pick a center price (e.g., SOL at $150)
  2. Place 10 grid levels with 2% geometric spacing
  3. Below center: buy orders at $147, $144.06, $141.18...
  4. Above center: sell orders at $153, $156.06, $159.18...

When price drops to a buy level → buy SOL → place paired sell one level up.
When price rises to a sell level → sell SOL → place paired buy one level down.

Why Geometric Spacing?

Linear spacing (e.g., every $3) means upper levels have smaller percentage returns than lower levels. Geometric spacing (e.g., every 2%) gives equal percentage returns at every level.

Dynamic Grid Threshold (DGT)

The killer feature. If SOL breaks out of the grid range entirely:

  1. Sell all SOL positions
  2. Calculate total capital
  3. Rebuild grid around new center price
  4. 5-minute cooldown prevents rapid repositioning

This prevents the grid from being "stranded" when price trends hard in one direction.

Backtesting Results

576-config parameter sweep over 90 days of hourly SOL data:

Metric Best Config
Grid levels 10
Spacing 2.0% geometric
Reserve 5%
DGT Enabled
Return +11.7%
SOL price change -37%
Max drawdown -8.2%
Trades 847
Win rate 100% (completed cycles)

The Code

Python async architecture:

  • Pyth Network oracle for real-time pricing
  • Jupiter V6 for order execution
  • Paper trading mode for risk-free testing
  • Full backtester with parameter sweep
  • Deploy free on Oracle Cloud

Get the SOL Grid Bot — 0.5 SOL →

Want a Telegram trading bot instead? Try @solscanitbot — free, 42 commands.

Top comments (0)