The Strategy Tester allows you to test and optimize trading strategies (Expert Advisors) before using them for live trading. One can test his strategies or algorithms in historical data of any stock or crypto using this project.
- backtrader - It is an open-source framework that allows for strategy testing on historical data.
- DateTime - This module supplies classes for manipulating dates and times.
- matplotlib - It is a comprehensive library for creating static, animated, and interactive visualizations in Python.
1.tester.py - This is the main method of the project where strategy is being executed.
2.strategies.py - Here I have created a strategy to implement as an example. The idea I have used is:
- If not in position then, if two consicutive dip happens from a given date, buy a fixed about of stock.
- Hold it for 5 days and sell it.
I have tested this with 4 datasets, 2 of them are from stock market and two of them are from crypto market. Adding them here. Other stocks historical data also can be downloaded from yahoo finance.
- AAPL.csv - APPLE.
- ADANIGREEN.csv - Adani Green Energy Limited.
- DOGE.csv - DOGE coin.
- YFI.csv - YEARNFINANCE coin.