DEV Community

TateLyman
TateLyman

Posted on

I Built a Grid Trading Bot for Solana That Made 11.7% While SOL Crashed 37%

Grid trading is one of the few strategies that can profit during a market crash. I built a production-grade grid bot for Solana that trades on Jupiter DEX, and backtested it through a major downturn.

Results

  • +11.7% return while SOL dropped 37%
  • 100% win rate on completed grid cycles
  • Realistic fee model including Jupiter, Orca, and Solana base fees

How Grid Trading Works

Grid trading places buy and sell orders at regular intervals around the current price:

  1. Buy low: Place buy orders below current price at each grid level
  2. Sell high: When price rises to the next grid level, sell
  3. Repeat: Each completed buy-sell cycle captures the spread
  4. Both directions: Works whether price goes up, down, or sideways

The key insight: you profit from volatility, not direction. A crashing market with lots of bouncing is actually ideal for grid trading.

Architecture

  • Python async — non-blocking I/O for all network calls
  • Pyth Network oracle — real-time on-chain pricing
  • Jupiter V6 — optimal swap routing
  • Dynamic Grid Reset (DGR) — automatically re-centers the grid when price moves too far
  • Geometric spacing — wider grids at extreme prices, tighter at center

Built-in Backtester

The bot includes a 576-configuration sweep backtester:

  • Test different grid sizes (5, 10, 20, 50 levels)
  • Compare geometric vs arithmetic spacing
  • Optimize rebalance thresholds
  • Model realistic fees

Deployment

Comes with a guide for deploying on Oracle Cloud free tier — runs 24/7 at zero cost.

Get It

Full source code + backtester + deployment guide: devtools-site-delta.vercel.app/sol-grid-bot


Also check out my free Solana trading bot for Telegram: @solscanitbot — copy trading, sniping, DCA, and 40+ commands.

Top comments (0)