Grok Trading Bot for Binance Spot/Futures
Automated trading bot for Binance featuring AI analysis, risk management, Grid/DCA strategies, Telegram integration, and secure demo mode execution by default.
Project Description
Grok Trading Bot for Binance Spot/Futures is a Python-based trading automation system designed with a strong focus on operational safety, risk control, and human supervision. The bot consumes OHLCV data from Binance via CCXT, computes technical indicators using Pandas and pandas-ta-classic, and sends market snapshots to Grok to obtain structured JSON signals containing trade direction, confidence levels, stop-loss, take-profit, and suggested leverage.
The architecture separates the main orchestrator (main_bot.py) from the grid and DCA management (grid_dca_manager.py). The risk module constructs grids of up to 5 levels, allocates the risk budget per level, calculates total exposure, and controls SL/TP, trailing stops, and position closures. The demo mode utilizes the Spot sandbox by default, whereas the real mode is tailored for USDT-M Futures and requires explicit activation via configuration.
The conversational layer integrates with the Telegram Bot API to operate the bot 24/7 in listener mode. From Telegram, users can query /status, view detailed metrics via /status_full, toggle trading using /start_trading and /stop_trading, manually close grids in demo mode, activate automatic closure upon reaching a +1 USD net profit, and submit chart images for multimodal analysis using Grok Vision. The system requires manual confirmation before execution when AUTO_EXECUTE=false and, even with automation enabled, requests confirmation via Telegram prior to opening any grids.
The project maintains audit logs in bot_log.log, records executions in trades.csv, and tracks operational states in bot_state.json. It includes an .env.example file for secure configuration without exposing secrets, alongside a .gitignore tailored to exclude credentials, logs, and runtime artifacts. The documented deployment is designed for local environments or low-cost VPS setups using a virtual environment and screen; Docker is slated as a planned future evolution.
AI serves two primary roles: during development, it assisted in the bot's incremental design, and at runtime, Grok acts as the analytical engine for technical signals and visual chart analysis. Crucial logic regarding execution, risk management, confirmations, and position closure remains implemented in deterministic code to avoid blind reliance on model outputs.
Problem Solved
The project addresses the need to execute crypto strategies with discipline, traceability, and strict risk control without relying on constant manual intervention. It centralizes technical analysis, AI-assisted signaling, human confirmation, 24/7 monitoring, Grid/DCA management, SL/TP/trailing stop closures, and status reporting via Telegram. This significantly reduces common operational errors such as trading without a stop-loss, over-leveraging positions, losing track of open exposures, or executing signals without prior validation.
Key Features
- Demo/paper trading mode by default utilizing the Binance sandbox environment.
- Support for Binance Spot in demo mode and USDT-M Futures in real production mode.
- Market analysis via Grok leveraging OHLCV snapshots and technical indicators.
- Technical indicators computation including EMA 9/21, RSI, MACD, ATR, and Bollinger Bands.
- Configurable multi-symbol rotation (e.g., BTC/USDT, ETH/USDT, SOL/USDT, and other custom pairs).
- Grid/DCA management supporting up to 5 levels with weighted risk distribution.
- Mandatory stop-loss and take-profit orders applied per trade.
- Automated trailing stop activation once a position moves into profitability.
- Configurable risk ceilings enforced per trade and across the total grid.
- Manual confirmation requirements via console or Telegram prior to grid execution.
- 24/7 listener mode with active trading toggled off by default.
- Telegram control commands: /start_trading and /stop_trading.
- Telegram reporting commands: /status and /status_full detailing account balances, real-time PnL, and open positions.
- Manual grid liquidation in demo mode via /close_grid and /close_all.
- Optional auto-close feature triggered upon reaching a target of +1 USD net profit (estimated after fees).
- State persistence for the auto-close toggle stored in bot_state.json.
- Multimodal analysis of chart images uploaded via Telegram utilizing Grok Vision.
- Re-analysis capabilities for the last submitted chart using the /analyze_chart command.
- Basic advanced backtesting engine computing equity curves, max drawdown, trade logs, and win rate.
- Structured logging implemented with Loguru inside bot_log.log.
- Trade execution history exported automatically to trades.csv.
- Secure configuration driven by environment variables and a clean .env.example template.
- Unit testing suite verifying the +1 USD net profit auto-close business logic.
Technical Details
Are you interested in this solution?
I can design and develop a similar system adapted 100% to your company's operations and size.
Request Pricing