AI Trading Simulator: Paper Trade Crypto With Smart LLM Decisions

10月26日 Published inCryptocurrency Tools

AI Trading Simulator is an LLM-powered crypto paper trading platform. Users define trading strategies via custom prompts; the system then aggregates live market data, evaluates 15+ technical indicators, and executes trades automatically—all without risking real capital. The platform includes a robust authentication layer featuring Linux DO OAuth support and isolated data environments for every account.

The AI core utilizes a five-stage response parser designed to interpret everything from structured JSON to messy Markdown and plain-text reasoning. Trades are triggered every three minutes, supporting both long and short positions with up to 20x leverage. To ensure reliability, failed AI calls trigger an automatic retry loop (up to three attempts). Comprehensive risk controls—including stop-loss, take-profit, position sizing, and drawdown alerts—run continuously in the background. Performance is tracked via Sharpe, Sortino, and Calmar ratios, supported by a backtesting engine for historical validation.

The tech stack consists of Python/Flask and SQLite. The AI interface is compatible with any OpenAI-standard endpoint (OpenAI, DeepSeek, Claude, Kimi). The application can be deployed quickly via Docker and is accessible at trade.easy2ai.com. This is an educational tool for experimentation; AI-generated outputs do not constitute investment advice, and users assume all risk for real-world financial decisions.

The project is built upon the chadyi/AITradeGame codebase, adding a dedicated user system, Linux DO OAuth integration, and an intelligent response parser.

User System

  • Comprehensive Authentication: Secure registration, login, session management, and password hashing.
  • Linux DO OAuth: One-click sign-in using existing Linux DO credentials.
  • Data Isolation: Individual models and trade histories remain strictly separated by account.
  • Route Protection: Unauthorized access is blocked via specialized decorators.
  • Public Dashboard: Visitors can view live prices and the global leaderboard without logging in.

Trading Engine

  • Custom Prompts: Each bot operates on a unique, user-defined strategy.
  • Multi-Dimensional Logic: The AI analyzes over 15 indicators, including SMA, EMA, MACD, RSI, Bollinger Bands, ATR, ADX, CCI, and Williams %R.
  • Five-Layer Parser: Handles JSON, Markdown, chain-of-thought, and plain text outputs across different LLMs.
  • Auditable Reasoning: A dedicated reasoning field logs the AI’s logic for every execution.
  • Automated Loop: Trades are processed every three minutes.
  • Leverage Options: 1x to 20x leverage for both long and short positions.
  • Retry Logic: Automatic recovery for up to three failed AI calls.

Live Market Dashboard

  • Price Ticker: Real-time updates and 24h price changes for BTC, ETH, SOL, BNB, DOGE, and XRP.
  • Equity Visualization: ECharts-powered charts plotting the top six models against a BTC benchmark.
  • Trade Feed: A dedicated panel scrolling the 100 most recent platform trades.
  • Model Cards: Performance summaries for the six leading models.
  • Auto-Refresh: Global data synchronization every five seconds.

Analytics and Risk Management

  • Technical Indicators: Full support for SMA, EMA, MACD, RSI, Bollinger Bands, ATR, ADX, CCI, Williams %R, and others.
  • Risk Mitigation: Integrated stop-loss/take-profit orders, live risk scoring, position limits, and max drawdown monitoring.
  • Candlestick Charts: Historical OHLCV data for all six supported assets.
  • Performance Ratios: Real-time calculation of Sharpe, Sortino, and Calmar ratios.
  • Global Leaderboard: Sort models by total return, Sharpe ratio, win rate, or drawdown.
  • Backtesting: Historical simulation via POST /api/backtest providing return, win rate, and risk metrics.
  • Monthly Insights: Breakdown of profits by month and asset contribution.

Tech Stack

Category Technology
Backend Python 3.9+, Flask 3.0
Frontend Vanilla JavaScript, ECharts 5.4.3
Database SQLite
AI Interface OpenAI-compatible (OpenAI, DeepSeek, Claude, Kimi)
OAuth Linux DO Connect OAuth 2.0
Real-time WebSocket (Flask-SocketIO)
Rate Limiting Flask-Limiter
Deployment Docker, Docker Compose, Gunicorn

Deployment

Option 1: Local Setup

  1. Clone the repository: git clone https://github.com/yourusername/AITradeGame.git && cd AITradeGame
  2. Install dependencies: pip install -r requirements.txt
  3. Configure environment: cp .env.example .env and update the SECRET_KEY.
  4. Launch: python app.py
  5. Access the app at http://localhost:35008

Option 2: Docker (Recommended)

  1. Clone the repository and enter the directory.
  2. Copy .env.example to .env and configure SECRET_KEY, LINUX_DO_CLIENT_ID, etc.
  3. Launch containers: docker-compose up -d
  4. Monitor logs: docker-compose logs -f
  5. Access the app at http://localhost:35008
  6. Stop service: docker-compose down

Quick Start Guide

Account Creation

  • Standard: Navigate to "Login / Register," select the Register tab, and enter a username (min. 3 characters) and password (min. 6 characters).
  • OAuth: Select "Sign in with Linux DO." The system automatically creates an account upon first authorization.

Model Creation Click "Add Model" and configure:

  • Core Settings: Name, API key, API base URL (e.g., https://api.deepseek.com), model ID (e.g., deepseek-chat), and initial capital.
  • Strategy Prompt: (Optional) Define specific trading rules. Example:

    "Focus on steady gains. Buy only when RSI < 30 and sell when RSI > 70. Maintain risk per trade below 1% using 3x leverage. Prioritize strict stop-loss discipline." If left empty, the platform applies a default professional trading prompt.

Monitoring The system executes trades every three minutes based on AI analysis and live data. Users can monitor portfolio health, review trade logs, inspect AI reasoning, and compare performance on the leaderboard.

Configuration

Environment Variables (.env)

  • Security: SECRET_KEY (Generate via python -c "import secrets; print(secrets.token_hex(32))")
  • Server: HOST, PORT, DEBUG
  • Database: DATABASE_PATH
  • OAuth: LINUX_DO_CLIENT_ID, LINUX_DO_CLIENT_SECRET, LINUX_DO_REDIRECT_URI
  • Trading: AUTO_TRADING=True, TRADING_INTERVAL=180

Core Parameters (config.py)

  • Assets: ['BTC', 'ETH', 'SOL', 'BNB', 'XRP', 'DOGE']
  • Risk Limits: MAX_RISK_PER_TRADE=0.05, MAX_POSITION_RATIO=0.30, MAX_LEVERAGE=20, MAX_DRAWDOWN_WARNING=0.15

API Endpoints

Authentication (Login Required for some)

  • POST /api/auth/register, POST /api/auth/login, POST /api/auth/logout, GET /api/auth/me

Model Management (Login Required)

  • GET /api/models, POST /api/models, DELETE /api/models/<id>

Trading & Analytics (Login Required)

  • GET /api/models/<id>/portfolio, GET /api/models/<id>/trades, GET /api/models/<id>/performance, POST /api/backtest

Public Data

  • GET /api/market/prices, GET /api/leaderboard, GET /api/dashboard/performance-chart

Advanced Features

  • Custom Personalities: Set models to aggressive, conservative, or balanced profiles.
  • Granular Backtesting: Test strategies against specific date ranges to generate comprehensive win/loss reports.
  • Risk Metrics: Track drawdown and volatility-adjusted returns (Sharpe/Sortino) to refine strategy efficiency.