A modular, machine learning-driven trading platform for equities and crypto. Features robust data collection, strategy backtesting, risk management, live/paper trading, and ML integration for predictive signals. Includes an interactive dashboard and reproducible experiment workflow.
- Unified data collection (Yahoo, Alpha Vantage, Finnhub, Binance)
- ML model training, evaluation, and integration
- Multiple trading strategies (rule-based & ML-based)
- Risk management: stop loss, take profit, position sizing, drawdown
- Backtesting engine with performance metrics
- Interactive dashboard for live/historical results
- Configurable via YAML files
src/ # Core modules (backtester, risk manager, strategies, ML, API)
scripts/ # Utility scripts (ML training, examples)
config/ # Config files (template, live)
models/ # Saved ML models
data/ # Raw, processed, and backtest results
dashboard/ # Dashboard app
web/ # Web API and live bot
notebooks/ # Jupyter notebooks for exploration
tests/ # Unit tests
logs/ # Log files
README.md # Project documentation
requirements.txt # Python dependencies
setup.sh # Setup script
The bot uses machine learning (ML) to predict trading signals based on historical market data and technical indicators. The workflow includes:
- Feature Engineering: Technical indicators (like RSI, MACD, Bollinger Bands, etc.) are extracted from price data to create features for the ML model. See
src/ml/feature_engineering.py. - Model Training: The ML model (default: Random Forest) is trained using historical data to learn patterns and predict future price movements or signals. Run
scripts/train_ml_model.pyto train the model. - Model Evaluation: After training, the model's accuracy and other metrics are evaluated using
evaluate_ml_model.py. - ML Prediction: The trained model is used to make predictions on new data in real time (
src/ml/ml_predictor.py). - ML Strategy Integration: ML predictions are used as trading signals in the bot (
src/ml/ml_strategy.py), either alongside or instead of traditional strategies.
Random Forest is an ensemble ML algorithm that builds many decision trees and combines their outputs. Each tree makes a prediction, and the forest averages or votes on the result. It is robust to overfitting and works well with tabular data like technical indicators. In this project, Random Forest is trained to predict buy/sell/hold signals based on features from historical price data.
- Traditional Strategies: Use fixed rules (e.g., moving average crossovers, RSI thresholds) to generate trading signals.
- ML Strategies: Use the trained ML model to predict signals based on learned patterns in the data.
- The bot can run both types of strategies, compare their performance, or combine their signals for smarter trading.
- You can backtest both approaches using the backtesting engine to see which performs better under different market conditions.
This modular approach lets you experiment with rule-based and machine learning-driven trading, and provides tools for training, evaluation, and live trading.
- Install dependencies
pip install -r requirements.txt
- Configure API keys & settings
- Copy
config/config_template.yamltoconfig/config.yaml - Fill in your API keys and parameters
- Copy
- Train ML models
python scripts/train_ml_model.py
- Evaluate ML models
python evaluate_ml_model.py
- Run backtests
python scripts/backtest.py
- Start dashboard
python dashboard/app.py
- Start live/paper trading
python web/intelligent_bot_fixed.py
- Feature Engineering:
src/ml/feature_engineering.py - Model Training:
scripts/train_ml_model.py - Model Evaluation:
evaluate_ml_model.py - ML Prediction:
src/ml/ml_predictor.py - ML Strategy Integration:
src/ml/ml_strategy.py
- Data sources: Yahoo, Alpha Vantage, Finnhub, Binance
- ML model: Random Forest (default, extensible)
- Metrics: Accuracy, Precision, Recall, F1
- Evaluation: Per-stock, per-strategy, reproducible scripts
- Reporting: Automated metrics table, experiment summary
- Stop Loss, Take Profit, Position Sizing, Max Drawdown
- Configurable via YAML
- Moving Average Crossover
- RSI Mean Reversion
- Momentum
- Bollinger Bands
- ML-based (customizable)
Interactive dashboard for monitoring live and historical performance.
Access at http://localhost:8050 after running:
python dashboard/app.pyRun all tests:
python -m pytest tests/This software is for educational and research purposes only. Algorithmic trading involves substantial risk of loss. Never risk money you cannot afford to lose. The authors are not responsible for any financial losses incurred using this software.
This project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
For questions or support, please open an issue on GitHub.