An intelligent FOREX trading bot powered by machine learning and ChatGPT strategic analysis.
- 🤖 Local ML Trading Signals: Random Forest classifier for real-time BUY/SELL/HOLD predictions
- 🧠 ChatGPT Strategic Analysis: Daily market regime detection and performance insights
- 📊 Real-time Dashboard: Web interface with TradingView-style charts
- 📱 Telegram Bot: Mobile notifications and trade approvals
- 🔬 Backtesting Engine: Validate strategies on historical data
- 📈 Paper Trading: Safe testing with OANDA practice account
- ☁️ AWS Deployment: Scalable cloud infrastructure
Three-Tier Hybrid Approach:
- Local ML (Fast Layer): Random Forest for real-time signals (every 5 min)
- ChatGPT (Smart Layer): Strategic analysis 1-3x per day
- Human Oversight (Safety Layer): Manual approval via Telegram
For detailed system architecture, see docs/ARCHITECTURE.md.
For architectural decisions and rationale, see docs/DECISIONS.md.
- Backend: Python 3.11+, FastAPI, Celery, SQLAlchemy
- ML/AI: scikit-learn, TA-Lib, OpenAI API (GPT-4o)
- Frontend: React, TypeScript, TradingView Lightweight Charts
- Database: PostgreSQL + TimescaleDB (time-series optimized)
- Cache: Redis
- Infrastructure: AWS (EC2, RDS, S3), Terraform
- Trading: OANDA v20 API
- Python 3.11+
- Poetry (dependency management)
- Docker & Docker Compose
- OANDA practice account
- OpenAI API key
- Clone the repository:
git clone <your-repo-url>
cd forex-ai-trading-bot- Copy environment template:
cp .env.example .env- Edit
.envand add your API keys:
- OANDA_API_KEY
- OPENAI_API_KEY
- TELEGRAM_BOT_TOKEN (optional)
- Start local development environment:
cd infrastructure/docker
docker-compose up -d- Install Python dependencies:
cd backend
poetry install
poetry shell- Run database migrations:
alembic upgrade head- Download historical data:
python scripts/download_historical_data.py- Start the services:
# Terminal 1: API server
uvicorn backend.api.main:app --reload
# Terminal 2: Celery worker
celery -A backend.strategy_engine.celery_app worker --loglevel=info
# Terminal 3: Celery beat (scheduler)
celery -A backend.strategy_engine.celery_app beat --loglevel=infoforex-ai-trading-bot/
├── backend/
│ ├── shared/ # Shared utilities (config, database, logger)
│ ├── data_ingestion/ # OANDA API client, data streaming
│ ├── strategy_engine/ # ML models, signals, LLM integration
│ ├── execution/ # Order execution, position management
│ ├── api/ # FastAPI REST API and WebSocket
│ ├── telegram_bot/ # Telegram bot for notifications
│ └── backtesting/ # Backtesting engine
├── frontend/ # React dashboard
├── infrastructure/ # Docker, Terraform
├── docs/ # Documentation
│ ├── ARCHITECTURE.md # System design and component details
│ ├── DECISIONS.md # Architecture Decision Records (ADRs)
│ └── (future) SPEC.md # Technical specifications
├── scripts/ # Utility scripts
└── notebooks/ # Jupyter notebooks for analysis
Key configuration in .env:
TRADING_PAIRS: Comma-separated list (default: EUR/USD,GBP/USD,USD/JPY)PAPER_TRADING: Alwaystruefor safetyML_CONFIDENCE_THRESHOLD: Minimum confidence for trades (default: 0.65)LLM_MAX_CALLS_PER_DAY: ChatGPT API call limit (default: 10)
Trend-Following with ML Confirmation:
- Entry when EMA(12) > EMA(26), RSI 40-70, MACD bullish, ML confidence > 0.65
- Exit: Stop Loss at 1.5×ATR, Take Profit at 2.5×ATR
- Risk: 1% per trade, max 3 concurrent positions
ChatGPT Strategic Overlay:
- Morning: Market regime analysis (trending vs ranging)
- Evening: Performance review
- On news events: Sentiment analysis
- Weekly: Correlation analysis
pytest
pytest --cov=backend tests/black backend/
isort backend/
flake8 backend/# Create migration
alembic revision --autogenerate -m "description"
# Apply migrations
alembic upgrade headSee PLAN.md for detailed deployment guide.
AWS Free Tier (Year 1):
- EC2 t2.micro/t3.micro
- RDS db.t2.micro/t3.micro
- S3, CloudWatch (free tier)
- Cost: $0-5/month + $20 ChatGPT Plus
- CloudWatch: System metrics, logs, alarms
- Dashboard: Real-time P&L, positions, signals
- Telegram: Trade notifications, daily summaries
- Paper trading only (initially)
- Daily loss circuit breaker (3% of capital)
- Position limits (max 3 concurrent)
- ChatGPT never directly executes trades
- All trades logged and auditable
- Phase 1: Foundation (Data pipeline, API)
- Phase 2: ML & ChatGPT Integration
- Phase 3: Execution & Backtesting
- Phase 4: User Interfaces (Dashboard, Telegram)
- Phase 5: AWS Deployment
- Phase 6: Optimizations (LSTM, more strategies)
MIT License - See LICENSE file
- PLAN.md: 15-week implementation roadmap
- docs/ARCHITECTURE.md: Detailed system architecture and component design
- docs/DECISIONS.md: Architecture Decision Records (ADRs) explaining key technical choices
For questions or issues, please open a GitHub issue or refer to the documentation above.