TypeScript starter for an adaptive Hyperliquid perpetual grid trading bot with:
- Dry-run mode by default
- Live execution gated behind env config
- Volatility-aware grid spacing
- Position caps, drawdown guard, leverage guard, and dead-man switch
- Historical candle backtest for parameter tuning
This bot is not guaranteed to be profitable. Grid strategies usually perform best in range-bound markets and can get hurt badly in strong trends, volatility expansions, and low-liquidity conditions. Keep LIVE_TRADING=false until you have tuned and observed behavior on your own account.
npm install
copy .env.example .env
npm run backtestTo run the live loop in dry-run mode:
npm run dev- Fill in
.env - Set
ACCOUNT_ADDRESSfor read-only account tracking, or setPRIVATE_KEYto derive it automatically - Keep
IS_TESTNET=truewhile validating behavior - Switch
LIVE_TRADING=trueonly after you are satisfied with logs and backtest behavior
HYPERLIQUID_SYMBOL: perp symbol, for exampleETHGRID_LEVELS: number of buy and sell levelsORDER_SIZE_USD: notional per grid orderGRID_SPACING_PCT_MIN/GRID_SPACING_PCT_MAX: bounds on spacingGRID_SPACING_VOL_MULT: scales spacing with volatilityMAX_POSITION_USD: cap on long or short directional exposureMAX_DRAWDOWN_PCT: halt condition based on starting equityMAX_VOLATILITY_PCT: halt condition for unstable market regimes
npm run dev
npm run backtest
npm run build
npm run typecheck- Live orders are posted as
Alolimit orders. - Managed live orders use deterministic client order IDs, so the bot can reconcile its own grid.
- The backtest is intentionally simple: it does not model fees, funding, latency, or intrabar path accurately.