Production-grade TypeScript spot trading bot for Bitget with an AI signal engine and pluggable strategies: ensemble (recommended), grid, momentum, RSI, and DCA. Includes paper trading, risk controls, persisted state, and a CLI for live runs, single ticks, backtests, and grid planning.
- AI ensemble — fuses SMA trend, RSI, MACD, EMA, and Bollinger %B into a scored signal with configurable confidence threshold
- Grid trading — arithmetic or geometric price ladders between
LOWER_PRICEandUPPER_PRICE - Momentum — short/long SMA crossover signals
- RSI — oversold/overbought mean-reversion entries
- DCA — time-based recurring buys
- Risk manager — daily loss cap, max position size, max open orders, min notional
- Paper mode — safe local simulation (default) with synthetic candles and fill simulation
- Bitget REST v2 — signed requests for live spot orders when
PAPER_TRADING=false
- Node.js 20+
- npm 9+
- Bitget API key, secret, and passphrase (live trading only)
cd Bitget-AI-Strategy-Trading-Bot
npm install
cp .env.example .env
# Edit .env — keep PAPER_TRADING=true until you are ready for live trading
npm run build
npm testnpm run tick # single strategy evaluation + optional paper order
npm run backtest # 120-step paper simulation
npm run plan # preview grid levels
npm start # continuous loop (Ctrl+C to stop)Set in .env:
PAPER_TRADING=false
BITGET_API_KEY=your_key
BITGET_API_SECRET=your_secret
BITGET_PASSPHRASE=your_passphraseThen:
npm run build
npm startCopy .env.example to .env. Key variables:
| Variable | Description | Default |
|---|---|---|
SYMBOL |
Trading pair | BTCUSDT |
STRATEGY |
ensemble, grid, momentum, rsi, dca |
ensemble |
LOWER_PRICE / UPPER_PRICE |
Grid / ensemble bounds | 60000 / 70000 |
GRID_COUNT |
Number of grid rungs | 10 |
GRID_MODE |
arithmetic or geometric |
geometric |
ORDER_SIZE_USDT |
Per-trade notional (USDT) | 50 |
AI_WEIGHT … RSI_WEIGHT |
Ensemble weights | 0.4 / 0.2 / 0.2 / 0.2 |
MAX_DAILY_LOSS_USDT |
Stop trading after daily loss | 100 |
PAPER_TRADING |
true = simulation |
true |
See .env.example for the full list.
src/
ai/ # Technical indicators + AI signal engine
cli/ # Commander CLI (start, tick, backtest, plan, status)
config/ # Zod schema + env loader
engine/ # Trading loop orchestration
exchange/ # Bitget REST client + paper simulator
services/ # Risk manager + state persistence
strategies/ # Grid, momentum, RSI, DCA, ensemble
types/ # Shared domain types
utils/ # Logger, retry, helpers
tests/ # Vitest unit & integration tests
| Command | Description |
|---|---|
npm start |
Run bot loop |
npm run tick |
One evaluation cycle |
npm run backtest |
Paper backtest (--steps 200) |
npm run plan |
Print grid levels |
npm run status |
Show data/bot-state.json |
npm test |
Run test suite |
npm run lint |
ESLint |
npm run typecheck |
TypeScript check |
Combines AI technical scoring with grid, momentum, and RSI sub-signals using configurable weights. Trades only when aggregated strength exceeds MIN_AI_CONFIDENCE.
Places logic on price crossing grid rungs between configured bounds. Best in ranging markets.
Trades SMA crossovers (bullish = buy, bearish = sell).
Buys when RSI ≤ RSI_OVERSOLD, sells when RSI ≥ RSI_OVERBOUGHT.
Schedules buys every DCA_INTERVAL_MS for DCA_AMOUNT_USDT.
Cryptocurrency trading involves substantial risk. This software is provided for educational purposes. Past backtest results do not guarantee future performance. Always test in paper mode and never risk capital you cannot afford to lose.
MIT
Need help deploying, configuring API keys, or debugging strategies?
Telegram: @tradingtermin
Contact: @tradingtermin on Telegram — technical support for this project.