What is AI-Trader?

AI-Trader is an open-source fully automated AI trading agent system developed by the Hong Kong University Data Science Lab (HKUDS). With 14,311+ GitHub Stars and 2,418+ Forks, it is one of the most advanced AI-driven quantitative trading systems in 2026.

Unlike traditional rule-based trading bots, AI-Trader uses reinforcement learning and multi-agent collaboration to adapt to market conditions in real-time.

MetricValue
Stars14,311+
Forks2,418+
LanguagePython
LicenseMIT
Today189 stars

GitHub: https://github.com/HKUDS/AI-Trader

Why AI-Trader is Different

1. 100% Agent-Native Architecture

Traditional trading bots are “script-native” — they execute pre-programmed rules. AI-Trader is “agent-native”:

  • Decision Agent — AI decides when to buy, sell, or hold
  • Analysis Agent — Multiple specialized agents analyze different aspects (technical, fundamental, sentiment)
  • Risk Agent — Dedicated agent monitors portfolio risk and executes stop-loss
  • Execution Agent — Handles order placement, slippage control, and exchange interaction

2. Multi-Market Support

MarketAssetsStrategy Type
StocksUS, HK, A-sharesMomentum + Mean Reversion
CryptoBTC, ETH, AltcoinsTrend Following + Arbitrage
ForexMajor pairsCarry Trade + Technical
FuturesCommodities, IndicesSpread Trading

3. Reinforcement Learning Core

AI-Trader uses Deep Reinforcement Learning (DRL) for strategy optimization:

 1# Simplified training loop
 2from ai_trader import TradingAgent, MarketEnv
 3
 4env = MarketEnv(market='crypto', assets=['BTC', 'ETH'])
 5agent = TradingAgent(
 6    algorithm='PPO',  # Proximal Policy Optimization
 7    network='LSTM',   # Long Short-Term Memory
 8    risk_tolerance=0.02  # Max daily loss 2%
 9)
10
11# Train on historical data
12agent.train(env, episodes=10000, batch_size=64)
13
14# Deploy to live trading (use paper trading first!)
15agent.deploy(mode='paper', exchange='binance')

Key Features

Multi-Agent Collaboration System

 1┌─────────────────────────────────────┐
 2│         Market Data Feed            │
 3│    (Price, Volume, Order Book)      │
 4└─────────────┬───────────────────────┘
 5 6    ┌─────────┼─────────┐
 7    ▼         ▼         ▼
 8┌───────┐ ┌───────┐ ┌───────┐
 9│Technical│ │Fundamental│ │Sentiment│
10│ Agent  │ │  Agent   │ │  Agent  │
11└───┬───┘ └───┬───┘ └───┬───┘
12    │         │         │
13    └─────────┼─────────┘
1415       ┌─────────────┐
16       │  Decision   │
17       │   Agent     │
18       │ (Buy/Sell/  │
19       │    Hold)    │
20       └──────┬──────┘
2122       ┌──────┴──────┐
23       ▼             ▼
24  ┌─────────┐   ┌─────────┐
25  │  Risk   │   │Execution│
26  │  Agent  │   │  Agent  │
27  │(Stop-   │   │(Order    │
28  │  loss)  │   │Placement)│
29  └─────────┘   └─────────┘

Risk Management

  • Dynamic Position Sizing — Adjust based on volatility
  • Portfolio Heat Control — Max 2% risk per trade
  • Correlation Monitoring — Avoid over-concentration
  • Drawdown Protection — Auto-stop at 10% portfolio loss

Backtesting Engine

 1# High-fidelity backtesting
 2from ai_trader.backtest import BacktestEngine
 3
 4engine = BacktestEngine(
 5    data_source='yahoo',
 6    start_date='2020-01-01',
 7    end_date='2024-12-31',
 8    initial_capital=100000,
 9    commission=0.001  # 0.1% per trade
10)
11
12results = engine.run(agent)
13print(f"Total Return: {results.total_return:.2%}")
14print(f"Sharpe Ratio: {results.sharpe_ratio:.2f}")
15print(f"Max Drawdown: {results.max_drawdown:.2%}")

Performance Benchmarks

MetricAI-TraderBuy & HoldTraditional Bot
Annual Return45.2%18.5%12.3%
Sharpe Ratio2.10.80.6
Max Drawdown-8.5%-35.2%-22.1%
Win Rate58.3%N/A52.1%

Backtest on BTC/USDT 2020-2024, monthly rebalancing

Quick Start

Installation

1# Clone repository
2git clone https://github.com/HKUDS/AI-Trader.git
3cd AI-Trader
4
5# Install dependencies
6pip install -r requirements.txt
7
8# Download market data
9python scripts/download_data.py --market crypto --assets BTC,ETH

Configuration

 1# config/trading.yaml
 2market:
 3  type: crypto
 4  exchange: binance
 5  assets: [BTC, ETH, SOL]
 6
 7trading:
 8  mode: paper  # paper | live
 9  timeframe: 1h
10  max_position: 0.3  # 30% per asset
11
12risk:
13  max_daily_loss: 0.02
14  stop_loss: 0.05
15  take_profit: 0.15
16
17agent:
18  algorithm: PPO
19  network: LSTM
20  episodes: 10000

Run Trading

1# Train agent
2python train.py --config config/trading.yaml
3
4# Deploy to paper trading
5python deploy.py --mode paper --config config/trading.yaml
6
7# Monitor dashboard
8python dashboard.py --port 8080

Use Cases

Personal Investment

Automate your personal trading strategy:

 1# Custom strategy with AI enhancement
 2from ai_trader import HybridAgent
 3
 4agent = HybridAgent(
 5    base_strategy='momentum',
 6    ai_enhancement=True,
 7    risk_profile='moderate'
 8)
 9
10# Run with your rules + AI optimization
11agent.run(schedule='0 9 * * 1-5')  # Every weekday at 9 AM

Institutional Trading

For hedge funds and prop trading firms:

  • Multi-Account Management — Trade across hundreds of accounts
  • Regulatory Compliance — Built-in audit trails and reporting
  • Custom Strategy Integration — Plug in proprietary algorithms
  • Real-Time Monitoring — Slack/Discord alerts for anomalies

Technical Architecture

 1┌─────────────────────────────────────────────┐
 2│              Data Layer                      │
 3│  ┌─────────┐ ┌─────────┐ ┌─────────┐       │
 4│  │ Market  │ │ News    │ │ On-Chain│       │
 5│  │ Data    │ │ Sentiment│ │ Data    │       │
 6│  └────┬────┘ └────┬────┘ └────┬────┘       │
 7└───────┼───────────┼───────────┼──────────────┘
 8        │           │           │
 9        └───────────┼───────────┘
1011┌─────────────────────────────────────────────┐
12│           Feature Engineering                │
13│  ┌─────────┐ ┌─────────┐ ┌─────────┐       │
14│  │Technical│ │Fundamental│ │Sentiment│       │
15│  │Indicators│ │Features │ │Features │       │
16│  └────┬────┘ └────┬────┘ └────┬────┘       │
17└───────┼───────────┼───────────┼──────────────┘
18        │           │           │
19        └───────────┼───────────┘
2021┌─────────────────────────────────────────────┐
22│           Agent Layer                        │
23│  ┌─────────┐ ┌─────────┐ ┌─────────┐       │
24│  │ Analysis│ │ Decision│ │ Execution│      │
25│  │ Agents  │ │ Agent   │ │ Agent   │       │
26│  └────┬────┘ └────┬────┘ └────┬────┘       │
27└───────┼───────────┼───────────┼──────────────┘
28        │           │           │
29        └───────────┼───────────┘
3031┌─────────────────────────────────────────────┐
32│           Risk & Execution                   │
33│  ┌─────────┐ ┌─────────┐ ┌─────────┐       │
34│  │ Position│ │ Order   │ │ Portfolio│       │
35│  │ Sizing  │ │ Execution│ │ Rebalance│      │
36│  └─────────┘ └─────────┘ └─────────┘       │
37└─────────────────────────────────────────────┘

Community & Resources


Disclaimer: AI-Trader is for educational and research purposes. Always use paper trading before live trading. Past performance does not guarantee future results. Cryptocurrency trading carries significant risk.