Show HN:我花費三個月打造了一個類似 AlphaGo 的深度強化學習 AI 交易機器人
一位開發者展示了其耗時三個月、基於深度強化學習(DRL)演算法(如 PPO 和 Dreamer)打造的 AI 交易機器人,該機器人專注於黃金(XAUUSD)交易,目標是實現可觀的年化報酬率。
Navigation Menu
Search code, repositories, users, issues, pull requests...
Provide feedback
We read every piece of feedback, and take your input very seriously.
Saved searches
Use saved searches to filter your results more quickly
To see all available qualifiers, see our documentation.
DRL Trading - AI Gold Trading Bot Deep reinforcement learning system for autonomous XAUUSD trading using: - PPO & Dreamer algorithms (PyTorch) - 140+ features: multi-timeframe, macro data, economic events - MetaTrader 5 live trading - 2M steps trained, targeting 80-120% annual returns - Multiple strategies (aggressive/swing/standard)
License
Uh oh!
There was an error while loading. Please reload this page.
zero-was-here/tradingbot
Folders and files
Latest commit
History
Repository files navigation
🤖 DRL Trading Bot - XAUUSD
An advanced AI-powered trading system using Deep Reinforcement Learning to trade gold (XAUUSD) autonomously. Built with 140+ market features, multi-timeframe analysis, and state-of-the-art RL algorithms.
📋 Table of Contents
🎯 What is This?
This is a fully autonomous trading bot that uses artificial intelligence to trade gold (XAUUSD) in the forex market. Unlike traditional bots that follow rigid rules, this system learns from historical data using Deep Reinforcement Learning (DRL) - the same technology behind AlphaGo and ChatGPT.
Why Gold (XAUUSD)?
What Makes This Different?
🚀 Key Features
🧠 Advanced AI Architecture
PPO (Proximal Policy Optimization)
Dreamer V3
📊 Comprehensive Market Intelligence (140+ Features)
Analyzes 5 timeframes simultaneously for complete market context:
Understands the broader economy:
Knows when major events happen:
🎯 Trading Strategies
Three pre-configured strategies for different risk profiles:
🔌 Live Trading Integration
📊 Performance Targets
Note: These are targets based on backtesting. Real performance depends on market conditions, slippage, and execution quality.
🔍 How It Works
1️⃣ Data Collection
The bot gathers data from multiple sources:
2️⃣ AI Decision Making
The trained model analyzes the 140+ features and decides:
3️⃣ Execution
The decision is sent to MT5 or MetaAPI:
4️⃣ Learning Process (Training)
The bot improves through simulation:
Training Time:
🛠️ Installation
Prerequisites
Step-by-Step Setup
What gets installed:
🔐 Security Setup (API Keys)
IMPORTANT: Never commit API keys to git!
Step 1: Create Environment File
Step 2: Fill in Your Credentials
Step 3: Verify .env is Ignored
The .env file is already in .gitignore - it will never be committed to git.
Get your MetaAPI credentials:
📚 Quick Start Guide
Step 1: Get the Data
Downloads: VIX, Oil, Bitcoin, EURUSD, Silver, GLD from Yahoo Finance
Creates calendar with 1,500+ major economic events (2015-2025)
Expected files:
Step 2: Train the Model
Training time:
Monitor progress:
Google Colab Setup: See COLAB_TRAINING_GUIDE.md
Step 3: Evaluate the Model
Output shows:
Step 4: Paper Trading (Test with Fake Money)
Before risking real money, test with a demo account:
What to watch:
Step 5: Live Trading (Real Money)
⚠️ Only after successful paper trading!
Best Practices:
📁 Project Structure
🔬 Algorithms Explained
PPO (Proximal Policy Optimization)
What it is: A popular RL algorithm that learns by trial and error, like teaching a dog tricks with rewards.
How it works:
Why PPO for trading:
Technical details:
Dreamer V3 (World Model RL)
What it is: An advanced algorithm that builds a mental model of how markets work, then practices trading in that simulation.
How it works:
Why Dreamer for trading:
Technical details:
When to use each:
📖 Documentation
⚙️ Configuration
Training Parameters
Edit in train/train_ultimate_150.py:
Live Trading Parameters
Edit in live_trade_mt5.py:
🧪 Testing
Quick Environment Test
Verifies the trading environment works correctly. Should print observation shape and complete without errors.
Backtest on Historical Data
Tests model performance on out-of-sample data (data it hasn't seen during training).
What to look for:
Crisis Validation
Tests how the bot performs during market crashes:
Good bot: Reduces position sizes or goes to cash during high volatility
Bad bot: Keeps trading normally and gets wrecked
📈 Expected Results
Backtesting (Historical Data)
Based on 2015-2023 XAUUSD data:
Forward Testing (Unseen Data)
Performance typically 20-30% lower than backtest:
Live Trading (Real Money)
Expected performance after accounting for slippage, spreads, execution delays:
Why the difference?
⚠️ Disclaimer
IMPORTANT - PLEASE READ
This software is provided for educational and research purposes only.
Risks:
Recommendations:
The authors and contributors are NOT responsible for any financial losses incurred through use of this software. Use at your own risk.
🤝 Contributing
Contributions are welcome! Here's how:
Reporting Bugs
Open an issue with:
Suggesting Features
Open an issue with:
Pull Requests
Code Style
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
Summary: You can use, modify, and distribute this software freely, even commercially. No warranty is provided.
🙏 Acknowledgments
This project builds on the work of many open-source contributors:
Special thanks to the quantitative trading and RL research communities for sharing knowledge and code.
📞 Support
🗺️ Roadmap
Completed ✅
In Progress 🚧
Planned 📋
Built with 🔥 by zero-was-here
If this project helps you, consider starring ⭐ the repository!
About
DRL Trading - AI Gold Trading Bot Deep reinforcement learning system for autonomous XAUUSD trading using: - PPO & Dreamer algorithms (PyTorch) - 140+ features: multi-timeframe, macro data, economic events - MetaTrader 5 live trading - 2M steps trained, targeting 80-120% annual returns - Multiple strategies (aggressive/swing/standard)
Resources
License
Security policy
Uh oh!
There was an error while loading. Please reload this page.
Stars
Watchers
Forks
Releases
Packages
0
Languages
Footer
Footer navigation
相關文章