A sophisticated trading system with multiple strategies, risk management, machine learning capabilities, and state-of-the-art anomaly detection.
- Multiple Trading Strategies
- Bollinger Bands
- Mean Reversion
- MACD
- Custom strategy support
- Advanced Anomaly Detection
- Autoencoder-based detection
- DBSCAN clustering
- Isolation Forest
- One-Class SVM
- Local Outlier Factor
- Ensemble detection with dynamic weighting
- Market regime-aware signals
- Risk Management
- Position sizing
- Drawdown limits
- Leverage control
- Confidence-based filtering
- Machine Learning Integration
- Ensemble models
- Neural networks
- GPU acceleration
- Real-time Monitoring
- Web dashboard
- Performance metrics
- Trade logging
- Anomaly visualization
- Python 3.8+
- NVIDIA GPU (optional, for accelerated training)
- CUDA Toolkit 11.0+ (if using GPU)
- TA-Lib (for technical analysis)
- Clone the repository:
git clone https://github.com/yourusername/trading-system.git
cd trading-system- Create and activate virtual environment:
python -m venv venv
source venv/bin/activate # Linux/Mac
.\venv\Scripts\activate # Windows- Install dependencies:
pip install -r requirements.txt- Install GPU dependencies (optional):
pip install -r requirements-gpu.txt- Configure your settings in
config/config.yaml:
trading:
symbols: ["AAPL", "MSFT", "GOOGL"]
initial_capital: 100000.0
risk_per_trade: 0.02
max_drawdown: 0.2
max_leverage: 2.0
anomaly_detection:
methods: ["autoencoder", "isolation_forest", "one_class_svm", "lof", "dbscan"]
anomaly_threshold: 0.8
confidence_threshold: 0.7
weights:
autoencoder: 0.3
isolation_forest: 0.2
one_class_svm: 0.2
lof: 0.2
dbscan: 0.1
data:
start_date: "2020-01-01"
end_date: "2023-12-31"
interval: "1d"
model:
type: "ensemble" # or "neural_net", "xgboost", "random_forest"
use_gpu: true
batch_size: 1024
num_workers: 4- Run the training session:
python src/blueprints/training.py- Start the web dashboard:
python src/web/app.pytrading-system/
├── config/
│ └── config.yaml
├── src/
│ ├── blueprints/
│ │ └── training.py
│ ├── core/
│ │ ├── market_data/
│ │ ├── strategies/
│ │ │ ├── anomaly_detection.py
│ │ │ ├── anomaly_methods.py
│ │ │ └── ...
│ │ ├── portfolio/
│ │ └── risk/
│ ├── web/
│ │ └── app.py
│ └── utils/
├── results/
│ ├── training/
│ └── models/
├── requirements.txt
├── requirements-gpu.txt
└── setup.py
-
Data Collection
- Fetch historical market data
- Calculate technical indicators
- Prepare feature sets
-
Anomaly Detection Training
- Train autoencoder
- Train DBSCAN
- Train Isolation Forest
- Train One-Class SVM
- Train Local Outlier Factor
- Optimize ensemble weights
-
Strategy Testing
- Run backtests on multiple strategies
- Optimize strategy parameters
- Evaluate performance metrics
-
Model Training
- Prepare training data
- Train selected model type
- Validate and save results
Access the dashboard at http://localhost:8000 to:
- Monitor real-time trading
- View portfolio performance
- Analyze strategy results
- Adjust trading parameters
- Visualize anomaly detection
- Monitor market regimes
The system supports GPU acceleration for:
- XGBoost training
- Neural network training
- Data processing
- Anomaly detection (autoencoder)
To enable GPU support:
- Install NVIDIA drivers
- Install CUDA Toolkit
- Set
use_gpu: truein config
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, please open an issue in the GitHub repository.