This project is a backtesting pipeline that allows users to test simple algorithmic trading strategies with ease. It contains all necessary steps for backtesting, including data fetching, feature generation, model selection, signal creation, and report generation. The project is highly modularized and compatible with sklearn and pandas, so users can modify or import strategies without overhead.
Trading signals are saved and loaded to Backtrader for backtesting, and quantStats is responsible for generating an HTML report that contains all testing metrics and graphs like the one below. There is also an automated Action workflow that generates a static webpage which contains all the reports generated.
Full report of this image can be found here .
This project used Python 3.12, with the following packages installed:
| Package | Version |
|---|---|
| yfinance | 0.2.66 |
| pandas | 2.3.3 |
| numpy | 1.26.4 |
| sklearn | 1.7.2 |
| backtrader | 1.9.78.123 |
| quantstats | 0.0.77 |
- Clone the repository to your local machine.
- Navigate to the project directory.
- Install the required packages as listed in the Environment Setup section.
- Run the main script or Jupyter notebook to start the analysis.
main.ipynb: The main Jupyter notebook containing the analysis and model implementation.
CustomCSVData.py: Custom data feed class for Backtrader.
Strategies.py: Contains the trading strategies implemented.
Report.py: Generates performance reports and visualizations.
./data/: Contains raw and processed data files.
./data/predictions/: Stores prediction results for different models.
./reports/: Contains generated strategy performance reports and prediction metrics for each ticker.