This project implements an end-to-end machine learning-based algorithmic trading strategy. It uses historical stock data to predict future trends and execute trades based on these predictions and technical indicators.
- Data retrieval using yfinance
- Feature engineering including SMA, trend decomposition, and other technical indicators
- Machine learning prediction using Random Forest Classifier
- Realistic trading simulation with transaction costs
- Performance visualization and metrics calculation
- Install dependencies : pip install -r requirements.txt
- Run the main script : python main.py
- The script will analyze the stock (default is GOOGL), display visualizations, and print performance metrics.
This project uses Yahoo Finance (yfinance) to retrieve historical stock data.
- Data Retrieval: Download historical stock data.
- Feature Engineering: Calculate technical indicators and decompose time series.
- Machine Learning: Train a Random Forest Classifier using walking forward validation.
- Trading Simulation: Implement a realistic trading strategy based on ML predictions and technical indicators.
- Performance Analysis: Calculate and visualize various performance metrics.
The project generates visualizations for:
- Stock price, SMAs, and trade points
- Machine learning predicted trend
- Buy/Sell signals over time
- Cumulative returns
It also calculates and prints performance metrics including total return, annualized return, Sharpe ratio, and maximum drawdown.
- Implement additional machine learning models
- Incorporate more data sources
- Optimize hyperparameters
- Implement portfolio management for multiple stocks