Implemented a predictive model for market prices leveraging deep learning techniques. Utilized recurrent neural networks to forecast trends and improve accuracy.
MIT License
This repository uses recurrent neural networks to predict the price of any stock, currency or cryptocurrency ( any market that yahoo_fin library supports ) using keras library.
to use this repository, install required packages
using the following command:
pip3 install -r requirements.txt
Dataset is downloaded automatically using yahoo_fin package and stored in data
folder. click here for more information about different tickers.
from keras.layers import GRU, LSTM, CuDNNLSTM
from price_prediction import PricePrediction
ticker = "BTC-USD"
# init class, choose as much parameters as you want, check its docstring
p = PricePrediction("BTC-USD", epochs=1000, cell=LSTM, n_layers=3, units=256, loss="mae", optimizer="adam")
# train the model if not trained yet
p.train()
# predict the next price for BTC
print(f"The next predicted price for {ticker} is {p.predict()}$")
# decision to make ( sell/buy )
buy_sell = p.predict(classify=True)
print(f"you should {'sell' if buy_sell == 0 else 'buy'}.")
# print some metrics
print("Mean Absolute Error:", p.get_MAE())
print("Mean Squared Error:", p.get_MSE())
print(f"Accuracy: {p.get_accuracy()*100:.3f}%")
# plot actual prices vs predicted prices
p.plot_test_set()
The next predicted price for BTC-USD is 8011.0634765625$
you should buy.
Mean Absolute Error: 145.36850360261292
Mean Squared Error: 40611.868264624296
Accuracy: 63.655%
Training logs are stored in logs
folder that can be opened using tensorboard, as well as model weights in results
folder.
n_layers
, RNN cell
, number of units
, etc.)batch_size
, optimizer
, etc. )ticker
parameter