Tensorflow and Keras frameworks are adopted for the implementation.
pip install tensorflow
The historical data can be accessed by installing yfinance library (https://pypi.org/project/yfinance/).
pip install yfinance
Libraries used to create visualizations
pip install matplotlib
pip install seaborn
With the help of an LSTM network, we previously estimated a model the predictis the future price of BTC for the day after. We created the class Data that downloads the historical data available for BTC and splits the dataset and imports the estimated model mentioned before to obtain the predicted prices fot BTC. We can see below the results of running the model with new data.
After extracting the predicted prices, we passed onto defining the trading rule. Instead of looking at the actual price predicted we decided to identify as a buying opportunity (1) each time the predicted price is higher than the previous closing price. Otherwise, the trading rule will output the number zero, which indicates the investor should sell. After rulling this loop we plotted the results the investor would have had if he had followed this trading rule.
- "Python Trading Toolbox: a gentle introduction to backtesting", Stefano Basurto, https://shorturl.at/vQTV2
- https://www.investopedia.com/articles/trading/05/030205.asp
- https://realpython.com/python3-object-oriented-programming/
- "Time Series Forecasting with LSTMs and Prophet", Maximilian Strauß https://tinyurl.com/62vbrx3m
- Chapter 6, "Deep Learning with Python",Francois Chollet
- Chapter 15, "Hands-on Machine Learning with Sciki-Learn & TensorFlow", Aurélien Géron, O'Reilly 2019
- Fork this project
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request