[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-83348":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":16,"stars90d":15,"forks30d":15,"starsTrendScore":15,"compositeScore":17,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":18,"fork":18,"defaultBranch":19,"hasWiki":20,"hasPages":18,"topics":21,"createdAt":10,"pushedAt":10,"updatedAt":22,"readmeContent":23,"aiSummary":10,"trendingCount":15,"starSnapshotCount":15,"syncStatus":14,"lastSyncTime":24,"discoverSource":25},83348,"gateio-ai-grid-trading-bot","GateIO-Trading-Tool\u002Fgateio-ai-grid-trading-bot","GateIO-Trading-Tool","Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO Gate.io AI Grid Trading Bot GateIO ","",null,"TypeScript",29,112,2,0,66,6.16,false,"main",true,[],"2026-06-12 02:04:33","# Gate.io AI Grid Trading Bot\n\nA production-grade, TypeScript-based automated grid trading bot for **Gate.io Spot** markets. It deploys a grid of limit buy and sell orders within a defined price range, automatically rebalances as orders fill, and uses an **AI signal engine** to optimize grid bounds, strategy selection, and market timing.\n\n## Features\n\n- **AI-Powered Optimization** — Multi-indicator ensemble (RSI, MACD, EMA, Bollinger Bands, SMA) for range and strategy recommendations\n- **Dual Grid Strategies** — Arithmetic (equal price steps) and Geometric (equal percentage steps), plus `auto` mode where AI picks the best fit\n- **AI Auto-Range** — Optional dynamic grid bounds based on live volatility and trend analysis\n- **Paper Trading Mode** — Full simulation engine for risk-free testing\n- **Live Trading** — Direct integration with Gate.io Spot API v4 (HMAC-SHA512 auth)\n- **State Persistence** — Automatic save\u002Fresume across restarts\n- **Graceful Shutdown** — Cancels open orders and persists state on SIGINT\u002FSIGTERM\n- **Retry Logic** — Exponential backoff for API resilience\n- **Structured Logging** — Pino-based logging with configurable levels\n- **Type-Safe Config** — Zod schema validation for all environment variables\n\n## How Grid Trading Works\n\nGrid trading places buy orders below the current price and sell orders above it. When a buy fills, a sell is placed one grid level higher. When that sell fills, a new buy is placed one level lower. Each completed buy→sell cycle captures the spread between grid levels as profit.\n\n```\nPrice\n  ▲\n  │  ── SELL ── SELL ── SELL ── SELL     ← Upper bound\n  │       │       │       │\n  │  ── BUY  ── BUY  ── BUY  ── BUY      ← Lower bound\n  └──────────────────────────────────▶ Time\n```\n\n**Arithmetic Grid** — Fixed price steps. Best for stable, range-bound assets.\n\n**Geometric Grid** — Fixed percentage steps. Best for volatile assets.\n\n**AI Auto** — Analyzes volatility and trend to recommend arithmetic vs geometric and optional price bounds.\n\n## Project Structure\n\n```\ngateio-ai-grid-trading-bot\u002F\n├── src\u002F\n│   ├── ai\u002F               # Signal engine, indicators, grid advisor\n│   ├── cli\u002F              # CLI entry (start, preview, analyze, validate)\n│   ├── config\u002F           # Zod schema and env loader\n│   ├── core\u002F             # Grid engine — order lifecycle\n│   ├── exchange\u002F         # Gate.io API client + paper simulator\n│   ├── services\u002F         # Bot orchestration and state persistence\n│   ├── strategies\u002F       # Arithmetic and geometric grid strategies\n│   ├── types\u002F            # Shared TypeScript interfaces\n│   └── utils\u002F            # Logger, retry, formatting helpers\n├── tests\u002F                # Unit tests (Vitest)\n├── .env.example          # Environment variable template\n├── package.json\n└── tsconfig.json\n```\n\n## Quick Start\n\n### Prerequisites\n\n- Node.js 18 or higher\n- npm 9 or higher\n- Gate.io account with API key (for live trading only)\n\n### Setup\n\n```bash\ncd gateio-ai-grid-trading-bot\nnpm install\ncp .env.example .env\n```\n\nEdit `.env` with your configuration:\n\n```env\nGATE_API_KEY=your_api_key_here\nGATE_API_SECRET=your_api_secret_here\nSYMBOL=BTC_USDT\nGRID_STRATEGY=auto\nUPPER_PRICE=70000\nLOWER_PRICE=60000\nGRID_COUNT=20\nINVESTMENT=1000\nPAPER_TRADING=true\nAI_ENABLED=true\n```\n\n### Validate Configuration\n\n```bash\nnpm run dev -- validate\n```\n\n### Preview Grid Levels\n\n```bash\nnpm run dev -- preview\n```\n\n### AI Market Analysis (no trading)\n\n```bash\nnpm run dev -- analyze\n```\n\n### Start the Bot (Paper Trading)\n\n```bash\nnpm run dev -- start\n```\n\n### Start the Bot (Live Trading)\n\nSet `PAPER_TRADING=false` in `.env`, then:\n\n```bash\nnpm run build\nnpm start -- start\n```\n\n## Configuration Reference\n\n| Variable | Description | Default |\n|---|---|---|\n| `GATE_API_KEY` | Gate.io API key | — |\n| `GATE_API_SECRET` | Gate.io API secret | — |\n| `SYMBOL` | Trading pair (`BTC_USDT` or `BTCUSDT`) | BTC_USDT |\n| `GRID_STRATEGY` | `arithmetic`, `geometric`, or `auto` | geometric |\n| `UPPER_PRICE` | Top of grid price range | — |\n| `LOWER_PRICE` | Bottom of grid price range | — |\n| `GRID_COUNT` | Number of grid levels (min 2) | — |\n| `INVESTMENT` | Total quote asset to deploy (USDT) | — |\n| `PAPER_TRADING` | `true` for simulation, `false` for live | true |\n| `POLL_INTERVAL_MS` | Order status check interval (ms) | 5000 |\n| `AI_ENABLED` | Enable AI signal engine | true |\n| `AI_AUTO_RANGE` | AI sets grid bounds on startup | false |\n| `MIN_AI_CONFIDENCE` | Minimum confidence (0–1) for AI actions | 0.35 |\n| `CANDLE_INTERVAL` | Candle interval for AI (`1h`, etc.) | 1h |\n| `AI_REBALANCE_INTERVAL_MS` | AI re-evaluation interval (0 = startup only) | 300000 |\n| `LOG_LEVEL` | trace \u002F debug \u002F info \u002F warn \u002F error | info |\n\n## CLI Commands\n\n| Command | Description |\n|---|---|\n| `start` | Start the grid trading bot |\n| `preview` | Preview grid levels (with AI hints if enabled) |\n| `analyze` | Run AI market analysis without trading |\n| `validate` | Validate `.env` configuration |\n\n## Development\n\n```bash\nnpm test\nnpm run typecheck\nnpm run lint\nnpm run dev -- start\n```\n\n## Strategy Selection Guide\n\n| Market Condition | Recommended | Grid Count | Range |\n|---|---|---|---|\n| Sideways \u002F ranging | `auto` or geometric | 15–30 | ±5–10% from price |\n| Low volatility | arithmetic | 10–20 | Tight range |\n| High volatility | geometric | 20–50 | Wider range |\n\nEnable `AI_AUTO_RANGE=true` to let the bot tune bounds from live Gate.io candle data.\n\n## Risk Disclaimer\n\nCryptocurrency trading involves substantial risk of loss. This bot is provided as-is with no guarantees of profitability. Always test thoroughly in paper trading mode before deploying real funds. Never invest more than you can afford to lose. The authors are not responsible for any financial losses incurred through use of this software.\n\n## License\n\nMIT\n\n---\n\n\u003Cdiv align=\"center\">\n\n## 💬 Technical Support\n\n### 👉 Telegram: [@tradingtermin](https:\u002F\u002Ft.me\u002Ftradingtermin)\n\n**Need help with setup, configuration, or troubleshooting?**\n\nContact **@tradingtermin** on Telegram for:\n\n| | |\n|---|---|\n| 🔧 | Installation and configuration help |\n| 📊 | Strategy tuning and AI grid optimization |\n| 🐛 | Bug reports and feature requests |\n| 🚀 | Live trading setup on Gate.io |\n\n**[@tradingtermin](https:\u002F\u002Ft.me\u002Ftradingtermin)** · [t.me\u002Ftradingtermin](https:\u002F\u002Ft.me\u002Ftradingtermin)\n\n\u003C\u002Fdiv>\n","2026-06-11 04:11:01","CREATED_QUERY"]