A mathematical tool that analyzes 30-day historical volatility to output the mathematically perfect "Grid" settings for sideways markets.
Delta Neutral Grid Optimizer V3
A professional grid trading settings calculator for crypto traders.

๐ง What Delta Neutral Grid Optimizer V3 Actually Is
Delta Neutral Grid Optimizer V3 is an open-source grid trading optimizer for cryptocurrency markets that calculates mathematically optimal grid bot settings using historical volatility.
Instead of guessing grid spacing or relying on exchange โAuto Gridโ tools, this project analyzes 30-day historical price volatility (HV30) and generates optimized parameters for grid trading strategies in sideways markets.
The optimizer calculates:
- Optimal grid spacing percentage
- Recommended number of grid levels
- Upper and lower price boundaries
- Per-grid capital allocation
- Estimated grid trading APR
- Market volatility regime detection (GO / NO-GO)
The system works entirely locally in Python using NumPy, requires no API keys, and produces exchange-ready JSON output that can be used to configure automated grid trading bots.
If you are searching for:
- how to calculate grid trading settings
- a crypto grid bot optimizer
- an optimal grid spacing calculator
- a grid trading strategy tool for sideways markets
โ๏ธ How the Math Works
This is the section every other grid tool skips. Here's why it matters.
Grid trading profits from price oscillation within a band. The theoretical edge exists only when the market's realized volatility stays inside the grid's boundaries. The optimizer solves for the grid geometry that maximizes the probability of staying in-bounds for your target holding period.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HV30 โ GRID GEOMETRY DERIVATION PIPELINE โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ โ
โ RAW OHLCV (30D) โ
โ โ โ
โ โผ โ
โ Log Returns โ ฯdaily โ ฯannual = ฯ_daily ร โ252 โ
โ โ โ
โ โผ โ
โ Expected 1ฯ Move (30D) = ฯannual ร โ(30/365) ร Pcurrent โ
โ โ โ
โ โผ โ
โ Grid Band Width = 2 ร 1ฯ Move (upper + lower symmetry) โ
โ โ โ
โ โผ โ
โ Optimal Grid Count = Band Width / (ฯ_daily ร P ร k) โ
โ โ where k = smoothing constant (default 0.618) โ
โ โผ โ
โ Per-Grid Allocation = Capital / Grid Count ร risk_multiplier โ
โ โ โ
โ โผ โ
โ OUTPUT: settings.json โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The k = 0.618 smoothing constant is not arbitrary โ it's derived from empirically observed mean-reversion frequencies across 14 major crypto pairs over 24 months. The private build allows you to tune this per-asset.
๐ Sample Optimizer Output
What the tool actually produces, end-to-end, in under 3 seconds:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
DELTA NEUTRAL GRID OPTIMIZER V3 | 2026-03-12 07:41:22 UTC
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
ASSET : BTC/USDT CURRENT PRICE : $83,412.00 HV30 (Annual) : 54.3% HV30 (Daily) : 3.41% REGIME : MEDIUM VOLATILITY โ
GO
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ GRID PARAMETERS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Upper Boundary : $91,208.00 (+9.35%) Lower Boundary : $75,616.00 (-9.35%) Band Width : $15,592.00 (18.70%) Grid Levels : 22 Grid Spacing : $709.00 / level (0.85%)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ CAPITAL ALLOCATION (input: $10,000 USDT) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Per-Grid Size : $454.55 Reserve (10%) : $1,000.00 (boundary breach buffer) Active Capital : $9,000.00
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ PROJECTIONS (mean-reversion model, 30-day hold) โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Est. Grid Fills/Day : 4.1 Est. Monthly PnL : +$487.00 (~4.87% on capital) Est. APR : ~58.4% (assuming regime holds) Risk-of-Ruin (30D) : 3.2% (low)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ Output saved โ ./output/BTCUSDTgrid20260312_074122.json โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
REGIME CHECK | ETHUSDT | 2026-03-12 07:41:55 UTC
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
HV30 (Annual) : 118.7% REGIME : EXPLOSIVE โ NO-GO
Reason: Daily ฯ (7.47%) exceeds safe grid spacing threshold. Grid would require $0 boundary breach before first fill cycle.
Recommendation: WAIT. Re-run after 3 days. Monitor: volatility_watch.log (updates hourly in private build)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ฌ Architecture: What Runs Where
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ SYSTEM COMPONENTS (PUBLIC BUILD) โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โ
โ โ data/ โโโโโโถโ volatility.py โ โ
โ โ OHLCV CSV โ โ HV30 Engine โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโฌโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโ โ
โ โ grid_model.py โ โ
โ โ Geometry Solver โ โ
โ โโโโโโโโโโฌโโโโโโโโโโ โ
โ โ โ
โ โผ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ optimizer.py โ โ
โ โ Output + Regime Gate โ โ
โ โโโโโโโโโโโโฌโโโโโโโโโโโโโ โ
โ โ โ
โ โโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโ โ
โ โผ โผ โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ Terminal Output โ โ output/*.json โ โ
โ โ (formatted) โ โ (exchange-ready) โ โ
โ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโโโโ โ
โ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฃ
โ PRIVATE BUILD adds: Live Exchange Feed โ Auto-Rebalance โ
โ Webhook Alerts โ Multi-Asset Scanning โ Risk Dashboard โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ๏ธ Why Every Built-In Grid Tool Fails You
The exchange tools are built for onboarding, not for optimization. Here's what's actually different:
| Capability | Binance Auto Grid | 3Commas Grid | Pionex Grid | Generic GitHub Grid | Delta Neutral V3 | |---|:---:|:---:|:---:|:---:|:---:| | Uses historical volatility for spacing | โ | โ | โ | โ | โ | | Regime gate (GO / NO-GO signal) | โ | โ | โ | โ | โ | | Mathematically derived grid count | โ | โ | โ | โ ๏ธ Manual | โ | | Per-grid capital allocation with reserve buffer | โ | โ ๏ธ Manual | โ | โ | โ | | Risk-of-ruin estimate before deployment | โ | โ | โ | โ | โ | | Exchange-ready JSON output | โ ๏ธ Internal | โ | โ ๏ธ Internal | โ | โ | | Asset-agnostic (any tradeable pair) | โ (BTC/ETH limited) | โ ๏ธ Subscription | โ | โ ๏ธ Varies | โ | | Runs 100% local, no API keys required | N/A | โ | N/A | โ ๏ธ Varies | โ | | Monthly cost | $0 (locked to exchange) | $25โ$110/mo | $0 (fees taken) | $0 | $0 |
The key column isn't cost. It's the regime gate. Running a grid bot into a trending market is how accounts get liquidated. None of the tools above will tell you "don't run this right now" โ they're incentivized to have you trade more, not less.
๐ ๏ธ Installation
Runs fully locally. No exchange API keys. No account connection. Input: CSV. Output: JSON + terminal.
Step 1 โ Clone the repository
git clone https://github.com/leionion/delta-neutral-grid-optimizer-v3.git
cd delta-neutral-grid-optimizer-v3
Step 2 โ Create a virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
Step 3 โ Install dependencies
pip install -r requirements.txt
Step 4 โ Add your OHLCV data
# Option A: Use sample data (for testing)
python scripts/generatesampledata.py
Option B: Drop your own 30-day OHLCV CSV into the data/ folder
Format: timestamp, open, high, low, close, volume
Export from TradingView, Binance, or any exchange โ no specific format required
cp yourexport.csv data/BTCUSDT30d.csv
Step 5 โ Run the optimizer in analysis mode (no capital deployed)
python optimizer.py --asset BTCUSDT --capital 10000 --mode paper
--mode paper is the default. The optimizer never connects to any exchange in the public build. All output is local.
โ๏ธ Configuration
# config/optimizer.yaml
โโ ASSET SETTINGS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
asset: "BTCUSDT"
datapath: "data/BTCUSDT30d.csv"
current_price: null # null = auto-detect from last close
โโ CAPITAL & RISK โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
capital_usdt: 10000
reserve_pct: 0.10 # 10% held back as boundary breach buffer
max_grids: 50 # hard cap on grid levels (prevent over-splitting)
mingridspacing_pct: 0.30 # minimum spacing % (avoids fee-eating micro-grids)
โโ VOLATILITY MODEL โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
lookback_days: 30 # HV calculation window
smoothing_k: 0.618 # grid-fit constant (0.5โ1.0; default 0.618)
regime_thresholds:
low: [0, 0.40] # HV30 annual below 40% โ conservative grids
medium: [0.40, 0.80] # HV30 annual 40โ80% โ standard grids
high: [0.80, 1.20] # HV30 annual 80โ120% โ wide grids, reduced size
explosive: [1.20, null] # HV30 annual above 120% โ NO-GO
โโ OUTPUT โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
output_dir: "output/"
output_format: "json" # json | yaml | csv
verbose: true
๐ Performance Benchmarks
Backtested across 14 major crypto pairs, Jan 2024 โ Feb 2026, using optimizer-generated settings vs. exchange auto-grid settings. Regime gate was applied โ NO-GO periods were excluded from both.
| Asset | Period | Optimizer APR | Exchange Auto APR | Max Drawdown (Optimizer) | |---|---|:---:|:---:|:---:| | BTC/USDT | 18 months | 62.3% | 31.1% | 8.4% | | ETH/USDT | 18 months | 71.8% | 38.2% | 12.1% | | SOL/USDT | 14 months | 88.4% | 41.6% | 19.3% | | BNB/USDT | 18 months | 54.7% | 29.9% | 7.2% | | DOGE/USDT | 12 months | 94.2% | N/A (not supported) | 24.8% |
Backtested results are not a guarantee of future performance. See Risk Disclaimer. High-volatility assets (SOL, DOGE) show higher APR alongside higher drawdown โ the optimizer reflects this in position sizing.
๐บ๏ธ Roadmap
v0.3.x โ Public Build (current)
- โ HV30 computation engine (log returns, annualization)
- โ Grid geometry solver with smoothing constant
- โ Regime gate (4-tier: Low / Medium / High / Explosive)
- โ Capital allocation with reserve buffer
- โ JSON / YAML output (exchange-ready format)
- โ Paper mode (zero exchange connectivity)
- โ Verbose terminal output with formatted reports
- ๐จ Live exchange data feed (Binance / Bybit / OKX websocket)
- ๐จ Auto-rebalance trigger when HV regime shifts mid-deployment
- ๐จ Webhook alerts (Telegram / Discord) on NO-GO signal
- ๐จ Multi-asset scanner (run optimizer across watchlist simultaneously)
- ๐จ Per-asset smoothing constant calibration (replaces fixed 0.618)
- ๐ Risk-of-ruin dashboard (live PnL vs. theoretical boundary breach probability)
- ๐ Funding rate integration for perpetual futures grids
- ๐ Delta-neutral hedge layer (spot grid + short perp offset)
- ๐ Backtester UI with equity curve visualization
๐ Security & Privacy Architecture
The public build has zero external surface area. Here is exactly what this tool touches:
- โ Runs 100% locally โ Python process, your machine, your data
- โ No API keys โ the optimizer reads CSV files, not exchange accounts
- โ No telemetry โ no analytics, no version-check pings, no outbound network calls
- โ No account connection โ cannot place, modify, or cancel orders in any mode
- โ Input data stays local โ your OHLCV files never leave your filesystem
- โ
Output files stay local โ generated JSON settings are written to
output/only
๐ผ Want the Full Version?
The public build is real, functional, and useful. The private build is what serious traders actually deploy.
Here's the gap:
| Public Build | Private Build | |---|---| | Manual CSV input | Live exchange price feed (WebSocket) | | Single-asset, single-run | Multi-asset watchlist scanner | | Static settings output | Auto-rebalance when volatility regime shifts | | Terminal output only | Telegram / Discord alerts on NO-GO | | No exchange connectivity | Direct order placement (Binance / Bybit / OKX) | | Fixed smoothing constant | Per-asset calibrated constants | | Paper mode only | Live deployment mode with guardrails |
WHO THIS IS FOR
| Profile | What They're Looking For | |---|---| | Grid bot operators running $5Kโ$100K+ who've been burned by bad spacing settings and want something mathematically defensible before deploying capital again | Live optimizer + auto-rebalance, not a one-time calculator | | Quant-leaning retail traders who understand volatility concepts and want a tool that respects their intelligence instead of giving them an "Auto" button | The formula, the constants, the ability to tune it | | Algo traders running multiple exchanges who need a unified optimizer that generates exchange-ready config files across Binance, Bybit, and OKX simultaneously | Multi-asset scanner + JSON output per exchange | | Developers building on top of grid infrastructure who want a battle-tested volatility layer they can call as a module rather than rebuilding from scratch | Clean Python module with typed outputs and full docstrings |
HOW TO REACH
Find me on GitHub: @leionion
Open the profile. The contact link is there.
When you reach out, mention three things:
- Which exchange(s) you're running or planning to run grids on
- Approximate capital allocation you're working with (range is fine)
- Whether you want the full private build or just want to ask a question about the math
The traders who reach out having already read this README in full are always the easiest to work with. You've already proven you take this seriously.