Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

lngdao/fck-quant-ea

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI Trading System

A production-ready AI-powered algorithmic trading system that combines machine learning models with MetaTrader 5 for automated trading execution.

πŸš€ Features

  • Multi-Model AI Engine: LSTM, XGBoost, LightGBM, and TCN models for market prediction
  • Real-time Trading: Direct integration with MetaTrader 5 for live trading
  • Advanced Risk Management: Position sizing, drawdown control, and exposure limits
  • Comprehensive Feature Engineering: 50+ technical indicators and market features
  • Auto-Retraining System: Automatic model updates based on performance metrics
  • Real-time Monitoring: Streamlit dashboard and Telegram alerts
  • Backtesting Framework: Walk-forward analysis and strategy optimization
  • Docker Deployment: Containerized microservices architecture

πŸ“‹ Table of Contents

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     AI Trading System                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   MT5 EA    │◄───│    Bridge    │◄───│   Signal     β”‚ β”‚
β”‚  β”‚  (MQL5)     β”‚    β”‚ (Socket/File)β”‚    β”‚  Generator   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                    β–²        β”‚
β”‚                                                    β”‚        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚    Data     │───►│   Feature    │───►│    Model     β”‚ β”‚
β”‚  β”‚   Manager   β”‚    β”‚  Engineering β”‚    β”‚   Training   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚    Risk     β”‚    β”‚  Monitoring  β”‚    β”‚   Backtest   β”‚ β”‚
β”‚  β”‚  Management β”‚    β”‚  Dashboard   β”‚    β”‚  Framework   β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ›  Installation

Prerequisites

  • Python 3.9+
  • MetaTrader 5 Terminal
  • Docker and Docker Compose (for containerized deployment)
  • PostgreSQL (optional, for production deployment)

Local Installation

  1. Clone the repository:
git clone https://github.com/yourusername/ai-trading-system.git
cd ai-trading-system
  1. Create virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
make install
# Or manually: pip install -r requirements.txt
  1. Copy environment variables:
cp .env.example .env
# Edit .env with your credentials

Docker Installation

# Build and start all services
make deploy

# Or step by step:
docker-compose build
docker-compose up -d
make init-db

βš™οΈ Configuration

Main Configuration (config/main_config.yaml)

system:
  name: "AI Trading System"
  version: "1.0.0"
  environment: "production"

data:
  mt5:
    login: ${MT5_LOGIN}
    password: ${MT5_PASSWORD}
    server: ${MT5_SERVER}
  collection:
    symbols: ["EURUSD", "GBPUSD", "USDJPY"]
    timeframe: "H1"
    history_days: 365

models:
  types: ["lstm", "xgboost", "lightgbm"]
  ensemble:
    enabled: true
    voting: "soft"
    
risk:
  max_positions: 5
  max_risk_per_trade: 0.02  # 2%
  max_daily_loss: 0.05      # 5%
  max_exposure: 0.2         # 20%

Environment Variables (.env)

# MT5 Credentials
MT5_LOGIN=your_mt5_login
MT5_PASSWORD=your_mt5_password
MT5_SERVER=your_mt5_server

# Telegram Bot
TELEGRAM_BOT_TOKEN=your_bot_token
TELEGRAM_CHAT_ID=your_chat_id

# Database
POSTGRES_USER=trading_user
POSTGRES_PASSWORD=secure_password
POSTGRES_DB=ai_trading_db

πŸ“– Usage

Training Models

# Train models for all configured symbols
python scripts/train_models.py --config config/main_config.yaml

# Train for specific symbol
python scripts/train_models.py --symbol EURUSD

# Train specific model type
python scripts/train_models.py --model-type lstm

Running the System

Option 1: Docker (Recommended)

# Start all services
make up

# View logs
make logs

# Stop services
make down

Option 2: Manual

# Terminal 1: Run main trading system
python src/main.py

# Terminal 2: Run monitoring dashboard
streamlit run src/monitoring/dashboard.py

# Terminal 3: Run auto-retrain system
python scripts/run_auto_retrain.py

Backtesting

# Run backtest
python scripts/run_backtest.py \
  --start-date 2023-01-01 \
  --end-date 2023-12-31 \
  --symbol EURUSD

# Walk-forward analysis
python scripts/run_walk_forward.py \
  --window-size 180 \
  --step-size 30

πŸ”§ Components

Data Manager

Handles data collection from MT5 and external sources:

from src.data import DataManager

manager = DataManager(config)
data = manager.load_data(
    symbol='EURUSD',
    source='mt5',
    start_date=datetime(2023, 1, 1),
    end_date=datetime(2023, 12, 31)
)

Feature Engineering

Creates 50+ technical indicators and market features:

from src.features import TradingFeatureEngineer

engineer = TradingFeatureEngineer(config)
features = engineer.create_features(data)

Signal Generator

Generates trading signals using trained models:

from src.signals import SignalGenerator

generator = SignalGenerator(config)
generator.load_model('models/trained/EURUSD_lstm.pkl', 'lstm')
signal = generator.generate_signal('EURUSD', 'lstm')

Risk Manager

Manages position sizing and risk limits:

from src.risk import RiskManager

risk_manager = RiskManager(config)
position_size = risk_manager.calculate_position_size(
    symbol='EURUSD',
    account_info=account_info,
    symbol_info=symbol_info,
    stop_loss_pips=50
)

πŸ“Š Monitoring

Streamlit Dashboard

Access the monitoring dashboard at http://localhost:8501

Features:

  • Real-time performance metrics
  • Active trades monitoring
  • Signal history
  • Risk metrics visualization
  • System logs

Telegram Alerts

Configure Telegram bot to receive:

  • Trade signals
  • Trade executions
  • Risk warnings
  • System errors
  • Daily performance summaries

πŸ§ͺ Testing

# Run all tests
make test

# Run unit tests only
python tests/run_tests.py --type unit

# Run integration tests
python tests/run_tests.py --type integration

# Run with coverage
pytest tests/ --cov=src --cov-report=html

πŸš€ Deployment

Production Deployment

  1. Environment Setup:
# Copy and configure environment
cp .env.example .env
# Edit .env with production credentials
  1. Deploy with Docker:
# Deploy all services
./scripts/deploy.sh

# Or use make
make deploy
  1. Health Check:
# Check system health
python scripts/health_check.py

# Or use make
make health-check

Backup and Restore

# Create backup
make backup

# Restore from backup
make restore BACKUP_FILE=backup_20240115_120000.tar.gz

πŸ“š API Reference

Signal Format

{
  "symbol": "EURUSD",
  "signal": "BUY",
  "confidence": 0.85,
  "timestamp": "2024-01-15T10:30:00",
  "price": 1.0850,
  "features": {
    "rsi": 35.2,
    "macd": 0.0012,
    "volume_ratio": 1.2
  }
}

Bridge Protocol

Socket Bridge

  • Host: 0.0.0.0
  • Port: 5555
  • Protocol: JSON over TCP

File Bridge

  • Signal file: /shared/signals.json
  • Command file: /shared/commands.json

🀝 Contributing

  1. Fork the repository
  2. Create feature branch (git checkout -b feature/AmazingFeature)
  3. Commit changes (git commit -m 'Add AmazingFeature')
  4. Push to branch (git push origin feature/AmazingFeature)
  5. Open Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Disclaimer

This software is for educational and research purposes only. Trading carries substantial risk and you should not trade with money you cannot afford to lose. Past performance is not indicative of future results.

πŸ™ Acknowledgments

  • MetaTrader 5 for trading platform integration
  • TensorFlow/Keras for deep learning models
  • XGBoost and LightGBM teams
  • Streamlit for dashboard framework

πŸ€– Generated with Claude Code

Co-Authored-By: Claude noreply@anthropic.com

About

Just a mess, i'm out

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors