Preprint
Article

Deep Neural Network: Predicting Future Prices of Cryptocurency Using LSTM and GRU

Altmetrics

Downloads

313

Views

209

Comments

0

This version is not peer-reviewed

Submitted:

05 October 2023

Posted:

06 October 2023

You are already at the latest version

Alerts
Abstract
Predicting the prices of cryptocurrency owing to its volatility, instability, and other factors has been challenging; investors and traders especially in Nigeria have been on a constant look for a more reliable way of knowing market trends and prices and while there has been so many research conducted using deep learning, the results for which has fall short of what investors could called a strong predictor. This research reviewed the results of many works that had been done and proposed two types of recurrent neural network (RNNs) namely Long Short-Term Memory and Gated Recurrent Unit (GRU) for predicting the future prices of two of the most common crypto assets namely Bitcoin (BTC) and Ethereum (ETH), these two were selected based on their popularity, the volume traded and their market capitalization. The experiment was conducted in a GPU Jupyter Notebook environment and the performance of our experiment was evaluated on a test set using root mean square error (RMSE) and based on its values, the LSTM presented a better performance with rsme scores of 654.66, and 80.30 respectively for BTC and ETH as compared to GRU. The paper proceeds further to compare the results of this experiment with other related works and we discovered that its performance is a great improvement.
Keywords: 
Subject: Computer Science and Mathematics  -   Artificial Intelligence and Machine Learning

1. Introduction

Cryptocurrency trading and as an exchange until recently was illegal in Nigeria however despite this many Nigerians especially youths trade BTC, and ETH in volumes. Nigeria's growing interest in cryptocurrency became noticeable in April 2022, the period in which BTC experienced its worst crash [1]. The results of a Google trend analysis carried out by coinGecko ranked Nigeria as the world's most interested country in cryptocurrency despite the market crash of 2022 [2]. A chinanalysis “2021 global crypto adoption index” report published in 2021 also listed Nigeria among the countries that are adopting cryptocurrency, especially in peer-to-peer (P2P) [3]. This increasing growth rate of cryptocurrency adoptions which is widespread among the youth in Nigeria, the demography that constitutes 60% of Nigeria’s population. The fast rise of cryptocurrency and its adoption in Nigeria is also a result of the continuous fall of the local currency ‘The Nigerian Naira against the USD and also noticeable is the unfair profiling of Nigeria youths as internet fraudsters by police and the Nigeria anti-graft agency, the economic and financial crime commissions (EFCC) thus, a larger percentage of people constituting youths prefer digital assets to save their funds rather than in traditional banks. Cryptocurrency, a decentralized digital asset is characterized by high security, anonymity, and the fact that no single individual controls its issuance and perhaps its circulations.
It leverages cryptography technology for security; counterfeiting cryptocurrencies and monitoring flows of transactions with cryptography is impossible [4]. One other noticeable fact about cryptocurrencies is their independence, they are not issued, and thus can’t be controlled, and unlike traditional currencies that are issued by central banks, cryptocurrencies are not [5]. Blockchain is also a key technology being used in cryptocurrencies, it plays an important role in how transactions are conducted anonymously This technology and the distinct characteristics of crypto, especially in the way in which transactions can’t be monitored was what attracted the attention of governments across the world while some are calling for its outright ban, quite many are calling for its regulation. In Nigeria, the outright ban until recently allayed fear of cryptocurrency serving as conduits for terrorism financing as well as laundering money [6], One other concern is the computational energy required to add digital assets such as BTC on blockchain and the power that is involved in validating its transactions in a process called mining which are conducted using specialized hardware application specific integrated circuits (ASIC) is too enormous especially now that the world is discussing climate change and what could be done to address it. There are lots of cryptocurrencies available, however, the most common and widely used is BTC. This may be because it was the first decentralized crypto asset and the first to be made available for trade in the market.
Despite the April 2022 market crash that plunged many cryptocurrency traders in the world and especially in Nigeria into huge losses, there has been a search for novel methods and ways to predict future cryptocurrency prices, and though highly volatile, artificial intelligence and machine learning can help predict prices of cryptocurrency. The volatility, complexity, and nonlinearity of these assets are what make them very challenging to adequately predict however, despite these challenges, investments in cryptocurrencies continue. To this end, it’s important to provide investors with a model that could help predict the cryptocurrency market trends; achieving, especially knowing how highly volatile the market is, government interference through policies and regulations, major events, etc. This paper aims to develop an improved cryptocurrency prediction model using a deep neural network and we aim to achieve this by;
  • Developing a BTC model prediction frameworks
  • Use deep learning’s recurrent neural network of LSTM and GRU, and
  • Evaluate prediction performance using root mean square error
  • Recommend the best-performing framework for cryptocurrency prediction
This is important as it has the potential to provide traders and investors with valuable insights into the market. This could help them make better-informed decisions about when to buy, sell, or hold cryptocurrencies, thereby increasing their chances of achieving their investment goals. More importantly, we aim to get answers to our research question ‘Can artificial intelligence provide a reliable way of predicting future prices of BTC.’ The remainder of this paper is organized as follows. Section 2 presents a review of the related work and methods that have been used to predict time series and sequential data especially financial analysis data such as stock price, and recent efforts in cryptocurrencies prediction. Section 3 presents our materials and methods, our modeling techniques and implementation, section 4 presents results, and discussion and comparison of related work. Section 5 presents our conclusions.

2. Related Work

This section The use of deep learning techniques for crypto and stock price prediction has gained significant attention in recent years [7], owing to the increasing popularity and acceptance of cryptocurrencies as well as the potential financial gains that can be realized through successful trading. Numerous research has looked into the use of deep learning models for predicting cryptocurrency prices. While the focus has been on the prediction of the following day's crypto prices, complex decisions [7] for example used deep learning to build a cryptocurrency recommendation where investors could know when to buy or to sell thus maximizing profit. This could be a reflection of the deeper research into using deep learning to increase investors’ confidence in the crypto market. Several deep-learning methods have been adopted in the prediction of crypto prices for example [8] used Markov chains to predict the prices of the crypto market; The author first extracted behaviors and patterns from historical BTC, ETH, and LTC datasets and used Markov chain models up to the 10th order to predict future trends; for BTC and ETH the best-performing results was however discovered at the 7th order while the best-performing results for LTC were at 9th order. [9] In an attempt to boost investors’ confidence in the crypto market, the authors combined the use of 1-dimensional convolutional neural networks (1DCNN) and gated recurrent networks (GRU). This is a hybrid method, the 1-dimensional convolutional network encodes the historical facts and patterns about the dataset, the 1DCNN reads a time-step at a time, and the output of this 1DCNN is then passed to the GRU layer where the long-range dependencies of the data were captured. This is deeper than the method proposed in [7], and both results also proved it. One other method which proven to have been particularly useful in the prediction of time-series projects like cryptocurrency analysis is the recurrent neural network's Long short-term memory (LSTM) [10].
In a very similar method in this research work, [5] used LSTM, Bi-LSTM, and GRU networks to predict the future trends of BTC, ETH, and LTC, The results in the end suggested that Bi-LSTM is a good network for crypto predictions as it performs excellently well and better than GRU and LSTM on all the crypto assets used in the study. For BTC, ETH, and LTC, the Bi-LSTM gave a mean square error (MSE) of 1029.3617, 83.9531, and 8.02449 respectively which were lower than the two other methods used in the study. Even though Bi-LSTM showed more promising results as compared to LSTM and GRU, we believe it’s not optimized which means, the author only trains and evaluates the results straight on the test set. This would mean even the Bi-LSTM that does better may perform even much better and the LSTM and GRU may outperform the Bi-LSTM.

3. Material and Methods

In this section, we presented the methods used in this research work; the methods rest entirely on the two most common types of RNN which are long short-term memory (LSTM) and gated recurrent network (GRU) and other work-related which include the pre-processing phase. These methods would be evaluated including criticism of the theory where relevant to this research work. The deep learning neural networks (LSTM and GRU) were used on historical BTC and ETH data, the results were analyzed and the best-performing network was therefore presented and compared with work from other authors.
The goal of this research is to use LSTM and GRU to predict the future price and trends of cryptocurrency, particularly BTC and ETH; for evaluation purposes, we employed the following steps (a) Download historical BTC and ETH data[12] (b) Visualize ETH and BTC (c) data preprocessing (d) splitting data into train and test set (e) training LSTM and GRU model (d) evaluate model performance on the test set (f) Optimize model (g) evaluate model (h) compare the performance of the two models.

3.1. Data Processing

The dataset used for this research is historical BTC and ETH data sourced directly from Yahoo Finance [11]; for BTC and ETH, the data was from November 2014 up to September 2023 and November 2017 up to September 2023 respectively, the dataset was however split in 80/20 train-test ratio, the train data for BTC started from November 17, 2014, and up to December 4th, 2021 (80%) while the test data started from December 5th, 2021 (20%); for ETH, the training data started from November 9th, 2017 up to July 9th, 2022 while the test set began from July 10th, 2022. This research is a time-series thus when splitting the data we avoided randomizing it to ensure the sequence of the data. The dataset even though dated needed to be converted to python recognized datetime for easy visualization, thus we converted the column “date” to Python datetime, and upon examination of the dataset it was revealed that there were no missing data values, the data were therefore normalized using the min-max scalar method which allows the data to take digit between 0 and 1 and thus ensure homogeneity of our dataset which makes it easy for the model to fit properly. [12] had demonstrated the importance of scaling methods on machine learning algorithms and model performance. The data were then reshaped to take a 3-dimensional shape which is expected of time-series data. Figure 1(a) and 1(b) show the historical data for BTC and ETH, Figure 2-3 shows BTC and ETH trends, and Figure 4 plotted BTC and ETH.
Figure 5 below shows the correlation between ETH and BTC, and from it we can see that ETH and BTC are positively correlated which also implies a rise or fall in one leads to a corresponding rise or fall in the other.

3.2. Modeling

In this research LSTM and GRU methods were proposed and implemented, the results were evaluated and presented, and compared with other related work. The LSTM and GRU models were a four-layered network architecture each consisting of 60 unit neurons and 50 unit neurons respectively. To avoid the incidence of overfitting the model, a dropout regularization of 0.2 was applied to each layer of each model (LSTM, GRU). For LSTM, 80 days trading timestep was used while 60 timestep for GRU. Historical data that would be fed into the model are in sequence thus the output of one layer must be an input to the second layer and that was why during data splitting, we did not randomize it; the model must learn from the previous trading days to predict next day price. Both LSTM and GRU were developed using the TensorFlow deep learning framework with Keras backend. Before we achieve peak performance, a shallow model involving three-layered LSTM and GRU architecture with no regularization, 50 unit neurons, 60 timesteps, 32 batch size, and which were trained for 100 epochs was developed to establish baseline metrics and least performance; the evaluation of this on the test set led to a series of optimization and hyperparameter tuning of the model.
The intention was to overfit or underfit the baseline model, therefore, the results represent the least performance our model can achieve and from there, we begin to optimize for an improved performance. After a few iterations, we achieved the top best performance for LSTM at 80 timesteps, 60 units, 32 batch size, and four-layered architecture with 0.2 dropouts in each of the layers and were trained for just 10 epochs while GRU achieved peak performance at 50 unit neurons, 60 timesteps, 32 batch size, and four-layered architecture with 0.2 dropouts and trained for 25 epochs.

3.3. Metrics

The performance of our models was evaluated using root mean squared error (RMSE); RMSE calculates the distance between the predicted and actual values and the smaller these values the better the performance of our model.

4. Results and Discussion

The research was conducted on core i7 HP Pavilion installed with 8GB RAM, 2GB Nvidia dedicated graphics card, CUDA 10.1, and Cudnn7.6 on Ubuntu system distribution. The research was conducted inside Jupyter Notebook with Python 3.6, and Tensorflow with keras backend; our proposed deep neural models were based on recurrent neural network’s LSTM and GRU model architecture for prediction of bitcoin (BTC) and Ethereum (ETH), the model was trained and evaluated using historical cryptocurrency datasets for BTC and ETH and were sourced directly from finance; the results of our experiments are listed in Table 1 and using RMSE, the model with the lowest errors is considered to be the best we then compared our results with other related work as shown in Table 2.
The comparison of our predicted results against the train, and the test for BTC’s LSTM and GRU are shown in Figure 6 and Figure 7 and the predicted results against the train, and test for ETH’s LSTM and GRU are shown in Figure 8 and Figure 9. The figures show the close movement of our predictions and the actual.
Table 2 above shows that the LSTM model outperformed the GRU for the prediction of future prices of Bitcoin (BTC) and also has the best performance for predicting prices of Ethereum (ETH) with the lowest rmse score computed; this can also be seen in Figure 6 which shows how closely the movement of our predicted BTC is to the training and test set as compared to GRU’s figure 7.
This also informed us that LSTM is better for predicting the future prices and trends of BTC and ETH than GRU. The results of our study as shown in Table 2 have been compared with related works, with a root mean square value of 654.6610 our model outperformed the best-performing Bi-LSTM model of similar research conducted by [5]. The comparisons of various studies based on RMSE scores are presented in Table 3. Our LSTM and GRU models did incredibly well than others in the literature.

5. Conclusion

For this research, we considered two (2) deep learning techniques; LSTM and GRU, these were used to build cryptocurrency price predictions for BTC and ETH, these two digital assets were selected due to their popularity, especially among Nigerian youths, and their market capitalization and volume traded. The data were sourced directly from finance and split into training and test sets, the evaluation of these models was conducted on the test set, and performances were computed using the root mean square.
The results of our research informed that the LSTM is a better model for the prediction of cryptocurrencies and even though Bi-LSTM wasn’t considered in this research however when compared with similar literature, our model outperformed similar authors' Bi-LSTM most performing models. while cryptocurrency had been known to be volatile and depend on several other factors including the sharp entrance of multinational companies into the market which may readily influence the markets, deep neural networks have proven to be a good method and in particular LSTM is a more better network for predicting prices and trends of cryptocurrency than GRU and Bi-LSTM.

References

  1. S. Singh, “An overview of cryptocurrency regulations in Nigeria,” Cointelegraph, n.d.
  2. N. Julia, “Top 15 countries most curious about cryptocurrency,” Coingecko, , 2023. Available:https://www.coingecko.com/research/publications/top-15-countries-most-curious-about-cryptocurrency. 19 July.
  3. C. Team, “The 2023 global crypto adoption index,” Chinalysis, 23. Available:https://blog.chainalysis.com/reports/2021-global-crypto-adoption-index/. 20 September.
  4. C. Rose, “, “The evolution of digital currencies: Bitcoin, a cryptocurrency causing a monetary revolution,” Int. Bus. Econ. Res. J. (IBER) 2015, 14, 617–622. [CrossRef]
  5. P. Seabe, C. P. Seabe, C. Moustsinga, E. Pindza, “Forecasting Cryptocurrency Prices Using LSTM, GRU, and Bi-Directional LSTM: A Deep Learning Approach,” Fractal Fract. 23. 20 July. [CrossRef]
  6. Majeed, “Why we banned cryptocurrency transactions” CBN, 21. 20 February.
  7. J. Park, Y. J. Park, Y. Seo, “A Deep Learning-Based Action Recommendation Model for Cryptocurrency Profit Maximization,” , 2022. 11 November. [CrossRef]
  8. K.K, Nascimento, D. Santos, F.S. Dos, J.S. Jale, T.A. Ferreira, “Extracting rules via Markov chains for cryptocurrencies returns forecasting – computational economics,” SpringerLink, 22. 20 February. [CrossRef]
  9. C.Y. Kang, C.P. C.Y. Kang, C.P. Lee, K.M. Lim, “Cryptocurrency Price Prediction with Convolutional Neural Network Network and Stacked Gated Recurrent Unit,” pp. 149, 23. 20 July. [CrossRef]
  10. A.L. Lima, “Bitcoin price prediction using recurrent neural networks and LSTM,” Analytics Vidhya, 21. Available: https://www.analyticsvidhya.com/blog/2021/05/bitcoin-price-prediction-using-recurrent-neural-networks-and-lstm/. 20 July.
  11. Yahoo Finance historical data. 2023. Available: https://finance.yahoo.com/quote/BTC-USD/.
  12. M.M. Ahsan, M.P. Mahmud, P.K. Saha, K.D. Gupta, Z. Siddique, “Effect of data scaling methods on machine learning algorithms and model performance,” pp. 52 September 2021. [CrossRef]
  13. S. Hansun, A. S. Hansun, A. Wicaksana, A. Khaliq, “Multivariate cryptocurrency prediction: Comparative analysis of three recurrent neural networks approaches,” J. Big Data. Pp. 1-15, 22. 20 September. [CrossRef]
Figure 1(a). Sample historical BTC training dataset.
Figure 1(a). Sample historical BTC training dataset.
Preprints 87019 g001
Figure 1(b). Sample historical ETH training dataset.
Figure 1(b). Sample historical ETH training dataset.
Preprints 87019 g002
Figure 2. Historical Bitcoin (BTC) sample data.
Figure 2. Historical Bitcoin (BTC) sample data.
Preprints 87019 g003
Figure 3. Historical Ethereum (ETH) sample data
Figure 3. Historical Ethereum (ETH) sample data
Preprints 87019 g004
Figure 4. Historical ETH and BTC) trends.
Figure 4. Historical ETH and BTC) trends.
Preprints 87019 g005
Figure 5. Correlation map for BTC, ETH.
Figure 5. Correlation map for BTC, ETH.
Preprints 87019 g006
Figure 6. BTC Predicted results using the LSTM model.
Figure 6. BTC Predicted results using the LSTM model.
Preprints 87019 g007
Figure 7. BTC Predicted results using the GRU model.
Figure 7. BTC Predicted results using the GRU model.
Preprints 87019 g008
Figure 8. ETH predicted results using LSTM.
Figure 8. ETH predicted results using LSTM.
Preprints 87019 g009
Figure 9. ETH predicted results using GRU.
Figure 9. ETH predicted results using GRU.
Preprints 87019 g010
Table 1. The description of the historical dataset.
Table 1. The description of the historical dataset.
Parameters Description
Date Trading Day
Open Daily Opening Price
High Daily high price
Low Daily close price
Table 2. Model Performance.
Table 2. Model Performance.
Cryptocurrency Model RMSE
BTC LSTM 654.6610
GRU 1082.3969
ETH LSTM 80.3055
GRU 93.3957
Table 3. Model Performance.
Table 3. Model Performance.
Related Work Cryptocurency Models RMSE
Our Work BTC-USD LSTM 654.6610
GRU 1082.3969
ETH-USD LSTM 80.3055
[5] BTC-USD LSTM 1031.34
Bi-LSTM
GRU
1029.36
1274.71
[13] ETH-USD LSTM 150.09
Bi-LSTM 147.85
GRU 151.62
[13] BTC-USD LSTM 2518.02
Bi-LSTM
GRU
2222.74
1777.31
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
Prerpints.org logo

Preprints.org is a free preprint server supported by MDPI in Basel, Switzerland.

Subscribe

© 2024 MDPI (Basel, Switzerland) unless otherwise stated