hyperliquid-trading-dca-bot
hyperliquid-trading-dca-bot copied to clipboard
Hyperliquid DCA trading bot Hyperliquid DCA trading bot Hyperliquid DCA trading bot Hyperliquid DCA trading bot Hyperliquid DCA trading bot Hyperliquid DCA trading bot Hyperliquid DCA trading bot Hype...
Hyperliquid DCA Bot
TypeScript Hyperliquid DCA bot built for perpetuals first, with dry-run as the default operating mode and explicit risk controls before live execution.
What It Does
- Connects to Hyperliquid for perp market data, account state, and order execution.
- Applies a configurable DCA strategy with ladder sizing, cooldowns, dip-based scaling, and entry guards.
- Enforces live-safety controls such as account-value checks, drawdown caps, daily loss limits, slippage checks, and a kill-switch.
- Persists strategy state and order history in a local SQLite database so restarts do not blindly duplicate DCA legs.
Quick Start
npm install
cp .env.example .env
npm run build
npm run test
Validate configuration:
npm run dev -- validate-config
Inspect the latest persisted status:
npm run dev -- status
Run the bot:
npm run dev
Safety Notes
LIVE_TRADING=falsekeeps the bot indry-runmode. No real orders are sent in this mode.- For live trading, use a dedicated Hyperliquid API wallet instead of a primary wallet.
- Keep
ENABLE_DEAD_MAN_SWITCH=truein live mode so the bot regularly refreshes a cancel-all timer. - Start with small sizing and verify
statusoutput before enabling live trading.
Main Modules
src/hyperliquid/: exchange client, websocket feed, and response mapperssrc/strategy/: DCA strategy and signal calculationssrc/risk/: limit checks and kill-switch handlingsrc/execution/: order planning and submissionsrc/state/: SQLite-backed persistencesrc/app/bot.ts: orchestration loop
Configuration Highlights
SYMBOL,SIDE,BASE_ORDER_USD,MAX_TOTAL_BUDGET_USD: define the DCA ladderDIP_INTERVAL_PCT,SIZE_SCALE,COOLDOWN_SECONDS: define step spacing and cadenceMAX_SPREAD_BPS,MAX_VOLATILITY_PCT,MAX_FUNDING_RATE: market-entry filtersMAX_NOTIONAL_USD,MAX_DAILY_LOSS_USD,MAX_DRAWDOWN_PCT,MIN_ACCOUNT_VALUE_USD: hard risk guards
Commands
npm run devruns the loop in TypeScriptnpm run buildcompiles todist/npm run lintruns ESLintnpm run testruns focused unit tests