Live trading optimizations (cumulative: $2,807 net, 81.8% WR, Sharpe 3.97): - #28B: Smart breakeven locks profit at entry + 0.5x ATR instead of fixed $2 - #31B: H1 Price vs EMA20 filter — BUY only when H1 bullish, SELL only when bearish Backtests #26-#32 (7 scripts testing sell improvement, regime-aware entry, confluence scoring, dynamic RR, multi-TF H1, and ML exit optimizer). Winners: #28B (+$229), #31B (+$343). Failed: #26, #27, #29, #30, #32. Also includes: web dashboard redesign, Docker setup, startup scripts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
11 KiB
XAUBot AI - Docker Integration Summary
✅ Completed Tasks
1. Created Dockerfile for Next.js Dashboard
- Multi-stage build for optimization
- Standalone output for minimal image size
- Production-ready configuration
- Non-root user for security
Location: web-dashboard/Dockerfile
2. Created Dockerfile for Python Trading API
- Python 3.11-slim base image
- FastAPI server with health checks
- Proper dependency management
- Volume mounts for data/logs/models
Location: Dockerfile (root directory)
3. Updated Docker Compose Configuration
- 4 services: postgres, trading-api, dashboard, pgadmin
- Proper service dependencies and health checks
- Custom bridge network for inter-service communication
- Environment variable support via .env file
- Volume persistence for database and pgadmin
Location: docker-compose.yml
4. Created Environment Configuration
- Template with all required variables
- Clear documentation for each setting
- Default values for non-sensitive configs
Location: .env.docker.example
5. Created Docker Ignore Files
- Excludes unnecessary files from images
- Reduces build context size
- Improves build performance
Locations:
web-dashboard/.dockerignore.dockerignore(root)
6. Created Helper Scripts
Windows Batch Scripts:
docker-start.bat- Start all servicesdocker-stop.bat- Stop services with optionsdocker-logs.bat- View service logs
Linux/Mac Shell Scripts:
docker-start.sh- Start all servicesdocker-stop.sh- Stop services with optionsdocker-logs.sh- View service logs
7. Updated Next.js Configuration
- Enabled standalone output for Docker
- Optimized for production builds
Location: web-dashboard/next.config.ts
8. Created Comprehensive Documentation
- Complete Docker setup guide
- Architecture diagram
- Service management commands
- Troubleshooting section
- Security best practices
- Performance tuning tips
Location: DOCKER.md
9. Updated Main README
- Added Docker deployment section as recommended method
- Clear quick start instructions
- Links to full documentation
Location: README.md
🏗️ Architecture
┌──────────────────────────────────────────────────────┐
│ Docker Network │
│ (trading_bot_network) │
├──────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────┐ ┌──────────────────┐ │
│ │ Dashboard │────────▶│ Trading API │ │
│ │ (Next.js) │ HTTP │ (FastAPI) │ │
│ │ Port: 3000 │ │ Port: 8000 │ │
│ └─────────────────┘ └────────┬─────────┘ │
│ │ │
│ │ PostgreSQL │
│ │ Protocol │
│ │ │
│ ┌────────▼─────────┐ │
│ │ PostgreSQL │ │
│ │ Database │ │
│ │ Port: 5432 │ │
│ └──────────────────┘ │
│ │
│ ┌─────────────────┐ (Optional - Admin Profile) │
│ │ pgAdmin │ │
│ │ Port: 5050 │ │
│ └─────────────────┘ │
└──────────────────────────────────────────────────────┘
↕ Exposed Ports
localhost:3000 (Dashboard)
localhost:8000 (API)
localhost:5432 (Database)
localhost:5050 (pgAdmin)
🚀 Quick Start Guide
1. Initial Setup (One-time)
# Navigate to project
cd "Smart Automatic Trading BOT + AI"
# Create environment file
copy .env.docker.example .env
# Edit .env with your MT5 credentials
notepad .env
Required credentials in .env:
MT5_LOGIN=your_login
MT5_PASSWORD=your_password
MT5_SERVER=your_server
MT5_PATH=/path/to/mt5/terminal
2. Start Services (Windows)
Option A: Using helper script (Recommended)
REM Start core services
docker-start.bat
REM Or start with pgAdmin
docker-start.bat --admin
Option B: Manual docker-compose
REM Build and start
docker-compose up -d
REM With pgAdmin
docker-compose --profile admin up -d
3. Access the Dashboard
Open your browser and go to:
- Dashboard: http://localhost:3000
You'll see:
- Real-time price updates
- Account balance and equity
- Trading signals (SMC + ML)
- Market regime
- Open positions
- Risk status
- Activity logs
4. Check Other Services
- API Docs: http://localhost:8000/docs
- API Health: http://localhost:8000/api/health
- API Status: http://localhost:8000/api/status
- pgAdmin: http://localhost:5050 (if started with --admin)
📋 Common Commands
View Logs
REM All services
docker-logs.bat
REM Specific service
docker-logs.bat trading-api
docker-logs.bat dashboard
docker-logs.bat postgres
Check Status
docker-compose ps
Restart Services
REM Restart all
docker-compose restart
REM Restart specific
docker-compose restart trading-api
docker-compose restart dashboard
Stop Services
REM Stop (keeps data)
docker-stop.bat
REM Stop and remove containers (keeps data)
docker-stop.bat --remove
REM Stop and remove everything including data (⚠️ DANGER!)
docker-stop.bat --clean
Update Code and Rebuild
REM Pull latest code
git pull
REM Rebuild and restart
docker-compose build
docker-compose up -d
🔧 Configuration
Port Configuration
Default ports can be changed in .env:
API_PORT=8000 # Trading API
DASHBOARD_PORT=3000 # Web Dashboard
DB_PORT=5432 # PostgreSQL
PGADMIN_PORT=5050 # pgAdmin
Environment Variables
All configuration is in .env:
| Category | Variables |
|---|---|
| MT5 | MT5_LOGIN, MT5_PASSWORD, MT5_SERVER, MT5_PATH |
| Trading | SYMBOL, CAPITAL |
| Database | DB_USER, DB_PASSWORD, DB_NAME |
| Telegram | TELEGRAM_BOT_TOKEN, TELEGRAM_CHAT_ID |
| Ports | API_PORT, DASHBOARD_PORT, DB_PORT, PGADMIN_PORT |
🐛 Troubleshooting
Dashboard Shows "Connection Error"
Check if API is running:
curl http://localhost:8000/api/health
View API logs:
docker-logs.bat trading-api
Port Already in Use
Find what's using the port:
netstat -ano | findstr :3000
netstat -ano | findstr :8000
Change port in .env:
DASHBOARD_PORT=3001
API_PORT=8001
Restart services:
docker-compose down
docker-compose up -d
Can't Connect to MT5
- Check credentials in
.env - Ensure MT5 terminal is accessible
- View API logs for connection errors:
docker-logs.bat trading-api
Database Connection Issues
Check database health:
docker-compose ps postgres
Test connection:
docker exec -it trading_bot_db pg_isready -U trading_bot
View database logs:
docker-logs.bat postgres
📊 Monitoring
View Real-time Logs
REM Follow all logs
docker-compose logs -f
REM Follow specific service
docker-compose logs -f trading-api
Check Resource Usage
docker stats
Service Health
REM All services
docker-compose ps
REM Detailed info
docker inspect trading_bot_api
docker inspect trading_bot_dashboard
🔐 Security Notes
- Never commit .env file - It contains sensitive credentials
- Change default passwords - Especially for database and pgAdmin
- Use strong passwords - For all services
- Limit port exposure - Only expose ports you need
- Keep Docker updated - Regular security updates
📁 File Structure
xaubot-ai/
├── Dockerfile # Python API Docker image
├── docker-compose.yml # Service orchestration
├── .env # Environment variables (DO NOT COMMIT)
├── .env.docker.example # Environment template
├── .dockerignore # Files to exclude from build
├── docker-start.bat # Windows start script
├── docker-stop.bat # Windows stop script
├── docker-logs.bat # Windows logs script
├── docker-start.sh # Linux/Mac start script
├── docker-stop.sh # Linux/Mac stop script
├── docker-logs.sh # Linux/Mac logs script
├── DOCKER.md # Full Docker documentation
└── web-dashboard/
├── Dockerfile # Next.js dashboard image
├── .dockerignore # Dashboard build exclusions
└── next.config.ts # Next.js config (standalone output)
🎯 Benefits of Docker Setup
✅ Easy Setup - One command to start everything ✅ Consistent Environment - Same setup on any machine ✅ Isolated Services - No conflicts with other software ✅ Easy Updates - Rebuild and restart to update ✅ Production Ready - Same setup for dev and production ✅ Automatic Restarts - Services auto-restart on crash ✅ Health Monitoring - Built-in health checks ✅ Volume Persistence - Data survives container restarts
📚 Additional Resources
- Full Documentation: DOCKER.md
- Styling Guide: web-dashboard/STYLING-GUIDE.md
- Docker Docs: https://docs.docker.com
- Docker Compose: https://docs.docker.com/compose
🆘 Support
If you encounter issues:
- Check the logs:
docker-logs.bat - Verify services:
docker-compose ps - Review troubleshooting section in DOCKER.md
- Check service health:
curl http://localhost:8000/api/health
Setup completed: Feb 6, 2026 Ready to deploy! 🚀