Keywords

1 Introduction

The fast improvement of cryptocurrency standards during the most recent decade is one of the most disputable and questionable developments in the cutting-edge worldwide economy [1, 2]. Huge variances in the conversion scale of digital forms of money and their high instability, just as the absence of legitimate guidelines of their exchanges in many nations brought about noteworthy risks related to a venture into crypto resources [3]. This has prompted speculative research about their place and role in the foreseeable future [4]. Hence, the issue of creating fitting strategies and models for the very purpose of foreseeing costs for the cryptocurrency is important both for established researchers and for analysts, financial specialists and brokers.

A comparative analysis of the ARIMA forecasting properties with recurrent neural networks (RNNs) was conducted by Rebane and Karlsson [5] for cryptocurrencies such as Ethereum (ETH), Ripple (XRP), Litecoin (LTC), DASH, NEM (XEM), Siacoin (SC), Monero (XMR) and Stellar (STR). The results showed that ARIMA models have poorer forecasting properties than neural networks.

A study [6] reveals that macroeconomic and financial indicators have a relatively minute correlation with the composition of bitcoin prices. It is observed that variables like transaction volume affected the supply and demand of bitcoin. Thus, in our approach, we define this as a time series forecast problem which can be solved using LSTM and root means square error (RMSE) as an evaluation metric for closing prices where sequences of prices are “remembered” by the model during the process.

2 Related Work

Countless research has been conducted of the change of Bitcoin value using Time Series Analysis [7]. Research on Bitcoin value utilizing twitter sentiment information has been conducted by Lönnö and Stenqvist [8]. VADER–valence aware dictionary and sentiment reasoner which is a “consolidated vocabulary-based way to deal with measuring the person tweet assumption force and afterward assembled the scores into time-arrangement” has been considered here. Their model resulted in a precision of about 79%.

Linear SVM and Neural Network related research has been conducted by Kim [9]. The after effect of his trial deciphers that “the estimation of the upper bound and the kernel parameter has a delicate job in the presentation of Support Vector Machine's expectation.” Their research resulted in an accuracy of 64.75%.

A suitable model that can predict the market price of Bitcoin is proposed in [10] using a few statistical models. A combination of MA and AR models has resulted in the ARIMA model. It uses the result of the autocorrelation charts where it finds out the order and then fits the data integrating MA and AR observations, resulting in better accuracy than the others. With AR and MA, the Bitcoin price is predicted with accuracy of 89.24 and 87.58%, respectively, while the ARIMA model resulted in an accuracy of 90.31%.

To analyze the price dynamics of Ethereum, Bitcoin and Ripple, authors in [11] propose a long short-term memory (LSTM) recurrent neural network and an artificial neural network (ANN). It was found that LSTM tends to rely more on short-term memory, while ANN tends to rely more on long-term memory, which tells us that—“efficiency of LSTM to utilize useful information hidden in historical memory is stronger than ANN. However, given enough historical information ANN can achieve a similar accuracy, compared with LSTM.”

In Lipo Wang and Edwin Sin's paper [12], genetic algorithm, an artificial neural network ensemble approach, explores the relationship between the prices of Bitcoin on consecutive days. We infer that—“the ensemble method, GASEN, was able to perform well for the classification task with consistent accuracy of around 58% to 63%. With a simple trading strategy, the ensemble was able to obtain promising results in making profit of close to 85% in return.”

The paper by Sean McNally, Simon Caton and Jason Roche [13] aims to predict Bitcoin prices in USD using different models. They found that—“LSTM achieved the best accuracy, whereas the RNN achieved all-time low RMSE. The ARIMA prediction performed poorly in terms of accuracy and RMSE. Deep learning models like the RNN and LSTM are manifestly effective for Bitcoin prediction with the LSTM more capable for recognizing longer-term dependencies.”

3 Proposed System

We outline the problem on a one-to-one sequence problem and use a neural network with stacked long short-term memory (LSTM) cell design to predict the costs of cryptocurrencies. LSTMs have a foothold over standard feed-forward neural networks and recurrent neural networks [14, 15]. This is often attributable to their property of selectively remembering patterns for long durations of time [16]. We tend to train a model consisting of a network of LSTM cells stacked over one another and outline a pipeline for the deployment of the model. The “close” values of cryptocurrency values are taken as the sequential input for the model. Alternatively, the volume/open/high/low/market cap will be chosen subjects to the appliance of the model.

The proposed system consists of the subsequent phases:

  • Phase 1: Identify the currencies most talked about and identify their historical data containing following attributes–opening price, highest value, lowest value, closing value, volume and market cap.

  • Phase 2: Data pre-processing and EDA.

  • Phase 3: Create train-test-validation data partitions.

  • Phase 4: Build a predictive model using LSTM architectures.

  • Phase 5: Test the model and tune hyper parameters.

  • Phase 6: User integration and visualization with an interface.

Figure 1 describes the proposed system for predicting cryptocurrency prices using LSTM.

Fig. 1
figure 1

Flow of control for proposed system

4 Data Pre-Processing

Many machine learning algorithms endeavor to discover trends in the information by looking at the highlights of data points [17, 18]. In any case, there is an issue when the highlights are on radically various scales. To solve this, we use scalar. The main objective of scalar is to make each data point have a similar scale so each component is equally significant.

We will be using the min–max scalar is one of the most well-known approaches to standardize information. For each element, the base estimation of that element gets changed into a 0, the most extreme value gets changed into a 1, and all other weighted points get changed into a decimal somewhere in the range of 0 and 1.

$$ {\text{The formula for min}} - {\text{max scalar is}}:m = \left( {x{-}x_{{{\text{min}}}} } \right)/\left( {x_{{{\text{max}}}} - x_{{{\text{min}}}} } \right) $$

Min–max scalar is sensitive to the presence of outliers. We use this trait in order to not lose information about our data, i.e., the data’s volatility.

5 Model Architecture

The model basically recreates a network to work like the neurons in our brain. The network is trained to give predictions based on being trained on existing data. Deep neural networks have been used in accounting of economic markets. In our study, we use an overarching profound learning model to break down and anticipate cryptocurrency value elements through long short-term memory. The LSTM incorporates three layers, each having ten nodes. Each LSTM cell state contains three gates—forget gate, input gate and an output gate. LSTM controls the removal or addition of data through the gates to accomplish the function of either ignoring or committing memory (Fig. 2).

Fig. 2
figure 2

Single LSTM cell architecture

Figure 3 Mathematical Shown above is the complete architecture of RNN developed during this project. We have used LSTM cells with Adam optimizer and MSE to calculate error. It contains 4 layers. The first layer is the input layer. It acts as the entry point of the cryptocurrency data into the RNN. The second and third layers are LSTM layers. Its input space dimensionality is 1 and 256, respectively, while the output space dimensionality is 256 for both. They use hyperbolic tangent (tanh) as the activation function and sigmoid as the activation function for the recurrent step. The fourth and final layer is a dense layer. It computes the dot product of its input matrix and weight matrix, and then adds to it the bias, producing the prediction value (Fig. 4).

Fig. 3
figure 3

Mathematical model of LSTM

Fig. 4
figure 4

Architecture of the RNN

The following graphs show mean squared error vs epoch number plots obtained after training the model for Bitcoin, Ethereum, Litecoin and Ripple time series data, dating back to 2017 (Figs. 5, 6, 7, 8).

Fig. 5
figure 5

MSE graph for bitcoin (BTC)

Fig. 6
figure 6

MSE graph for ethereum (ETH)

Fig. 7
figure 7

MSE graph for litecoin (LTC)

Fig. 8
figure 8

MSE graph for ripple (XRP)

6 Results

After training the 4 datasets using the proposed model, the following results were observed. In terms of mean squared error (MSE), the LSTM model shows superior performance when compared with an ANN model in general while predicting cryptocurrency values. The MSE values obtained after training datasets for Bitcoin (BTC), Ethereum (ETH), Litecoin (LTC) and Ripple (XRP) are 1.4925 e−04, 6.0898 e−05, 5.0990 e−05, 2.4237 e−04, respectively.

The comparison of results existing between support vector regression (SVR), neural network (NN), decision tree regression (DTR) [19], and our proposed LSTM model has been tabulated below (Table 1):

Table 1 Comparison of results of existing and proposed LSTM model

The following graphs showcase the predicting capabilities of the proposed model (Figs. 9, 10,11, 12).

Fig. 9
figure 9

Prediction graph for bitcoin (BTC)

Fig. 10
figure 10

Prediction graph for ethereum (ETH)

Fig. 11
figure 11

Prediction graph for litecoin (LTC)

Fig. 12
figure 12

Prediction graph for ripple (XRP)

7 Conclusion and Future Work

Cryptocurrency price forecasting is an important component of automation in forex and algorithmic trading [20]. A model that predicts prices with minimal error can be integrated with software’s and used in accordance with trading strategies [21]. Moreover, this forecasting model that uses LSTM can also be applied to other features like close prices, market capitalization, etc.

This model can be deployed as a service on the cloud or even as a rest API that is scalable according to usage and market fluctuation. The existence of this model deems useful for multiple economic frameworks by increasing explain ability and reducing risk in cryptocurrency domain.