AI-powered gold (XAUUSD) trading strategy analyzer and automated trading system.
- 📥 Real Market Data - Fetch XAUUSD data from Yahoo Finance
- 📊 5 Pre-built Strategies - EMA Crossover, RSI Reversal, MACD, Support/Resistance, VWAP
- 🔬 Backtesting Engine - Test strategies against historical data
- 🏆 Strategy Comparison - Find the most profitable strategy
- 💾 SQLite Database - Store strategies and results
- 📈 Visual Analysis - Equity curves, trade distribution, monthly returns
- 🤖 Paper Trading Ready - Binance Spot Testnet connector for fake-money testing
- 🛡️ Risk Manager - Position sizing, max daily trades, max positions, max daily loss
- 🔐 Secure Secrets - API keys loaded from
.env, not hardcoded in code
pip install -r requirements.txtcp .env.example .env
# edit .env with Binance Spot Testnet keys from https://testnet.binance.vision/
# keep BINANCE_TESTNET=trueYou can use the analyzer without API keys. Keys are only needed for demo_trade.py.
cd trading-bot
python run.pypython3 dashboard.py --openThis creates a graphical HTML chart at analysis/live_signal_dashboard.html using Yahoo Finance data.
[1] 📥 Fetch Gold Data
[2] 📊 List Available Strategies
[3] 🔬 Backtest Single Strategy
[4] 🏆 Compare All Strategies
[5] 📈 View Analysis Reports
[6] 🗄️ View Database
[7] 🤖 Run Live Bot (Simulation)
[0] 🚪 Exit
trading-bot/
├── 📁 config/ # Configuration settings
├── 📁 data/ # Historical market data
├── 📁 strategies/ # Trading strategy definitions
├── 📁 backtesting/ # Backtesting engine
├── 📁 database/ # SQLite database
├── 📁 bot/ # Trading execution
├── 📁 analysis/ # Performance reports
├── run.py # Main program
└── requirements.txt # Python dependencies
| # | Strategy | Timeframe | SL | TP | Best For |
|---|---|---|---|---|---|
| 1 | EMA Crossover Gold Scalping | 5m | 10 | 15 | London/NY overlap |
| 2 | RSI Mean Reversion Gold | 15m | 15 | 30 | Trend reversal |
| 3 | MACD Trend Following Gold | 1h | 50 | 100 | Swing trading |
| 4 | Support/Resistance Breakout | 5m | 12 | 24 | NY session |
| 5 | VWAP Scalping Gold | 1m | 5 | 8 | Fast scalping |
- Data Collection - Fetches real XAUUSD data from Yahoo Finance
- Strategy Definition - Each strategy has entry/exit rules + risk management
- Backtesting - Tests strategy against historical data with spread simulation
- Analysis - Generates equity curves, win rates, profit factors
- Live Trading - Run the bot (simulation first!)
Edit config/settings.py to customize:
TRADING_MODE = 'simulation' # or 'live'
INITIAL_CAPITAL = 10000.0
ASSET = 'XAUUSD'
DEFAULT_STRATEGY = 'ema_crossover_gold'If you do not like using the terminal, open the local browser dashboard:
cd trading-bot
python3 web_dashboard.pyOr double-click this Mac file:
Open Gold Dashboard.commandThe dashboard opens at http://localhost:8765 and shows price, candles, indicators, BUY/SELL/WAIT signal, reasons, and a built-in fake-money paper trading account. You can click Paper BUY, Paper SELL, Trade Bot Signal, Close Position, and Reset Paper Account.
OANDA practice is the recommended broker/demo route on Mac because it uses an API instead of MetaTrader/Windows.
- Create an OANDA practice/demo account.
- Create an API token.
- Copy
.env.exampleto.env. - Add:
OANDA_ENV=practice
OANDA_API_TOKEN=your_oanda_practice_token_here
OANDA_ACCOUNT_ID=your_oanda_practice_account_id_here
OANDA_INSTRUMENT=XAU_USD
OANDA_DEFAULT_UNITS=1Then run:
python3 web_dashboard.pyIf OANDA is configured, the dashboard uses OANDA practice data and demo order buttons. If not, it falls back to Yahoo Finance signal-only mode.
cd trading-bot
python demo_trade.pyThe demo uses Binance Spot Testnet by default. Binance is mainly for crypto, not XAUUSD gold. Do not put real keys in source code; use .env.
Before any real-money trading, the bot should pass this checklist:
- Backtest on multiple market regimes, not only a few days.
- Run Binance Testnet / paper trading for weeks.
- Keep max risk per trade around 0.5–1%.
- Add logs and alerts for every order.
- Only consider live mode after consistent out-of-sample results.
- Always test in simulation and paper/testnet mode first
- Never trade with money you can't afford to lose
- Past performance does not guarantee future results
- Always use proper risk management
Samuel + AI Assistant 🤖
Version: 1.0.0 Date: 2026-04-24