|Computers, Materials & Continua |
A Novel Cryptocurrency Prediction Method Using Optimum CNN
1Iowa State University, Ames, USA
2University of Texas at Arlington, USA
3Department of Computer Engineering, College of Computer Science and Information Technology, Imam Abdulrahman Bin Faisal University, Dammam, Saudi Arabia
4Department of Information Systems, Faculty of Computing and Information Technology, King Abdulaziz University, Jeddah, Saudi Arabia
*Corresponding Author: Syed Hamid Hasan. Email: firstname.lastname@example.org
Received: 09 June 2021; Accepted: 30 July 2021
Abstract: In recent years, cryptocurrency has become gradually more significant in economic regions worldwide. In cryptocurrencies, records are stored using a cryptographic algorithm. The main aim of this research was to develop an optimal solution for predicting the price of cryptocurrencies based on user opinions from social media. Twitter is used as a marketing tool for cryptoanalysis owing to the unrestricted conversations on cryptocurrencies that take place on social media channels. Therefore, this work focuses on extracting Tweets and gathering data from different sources to classify them into positive, negative, and neutral categories, and further examining the correlations between cryptocurrency movements and Tweet sentiments. This paper proposes an optimized method using a deep learning algorithm and convolution neural network for cryptocurrency prediction; this method is used to predict the prices of four cryptocurrencies, namely, Litecoin, Monero, Bitcoin, and Ethereum. The results of analyses demonstrate that the proposed method forecasts prices with a high accuracy of about 98.75%. The method is validated by comparison with existing methods using visualization tools.
Keywords: Cryptocurrency; litecoin; monero; bitcoin; ethereum; twitter; optimal CNN; price prediction; sentiment analysis
Accurate prediction of the price of any currency is a difficult task. Various machine learning algorithms are used to predict prices in the stock market; these also make prediction easier for highly unstable cryptocurrencies. Bitcoin, which was invented by a group of people called “Satoshi Nakamoto” in the year 2009 , is a well-known cryptocurrency that is used to make online payments and also for investment purposes. Bitcoin is generated, traded, distributed, and stored using a decentralized registering method and identified as a blockchain in contrast to flat currency. The Bitcoin price depends on large numbers of variables, including opinion, news, and buzz from around the globe .
Cryptocurrencies are implicit currencies swapped among groups or individuals. Such network-based exchange standards use cryptographic algorithms to protect transactions . Most cryptocurrencies depend on blockchain technology and have properties including transparency, immutability, and decentralization. Although Bitcoin remains a popular cryptocurrency, thousands of other cryptocurrencies have been developed. There are subdivisions of crypto assets that consist of crypto coins including Etherrem, Ripple, and Litecoin; stable coins including MakerDao and Tether; and tokens [4–7]. Bitcoin has attributes that are not shared by conventional currency transaction modes, because the fluctuations of the Bitcoin price depend on people's acuity and opinions as well as institutional rules. The instability of the crypto value results in dangerous currency decisions . Social media can be used to identify users’ thoughts regarding products, occurrences, demands, and supplies. Twitter, a famous social media platform, allows more than 100 million active users to describe their thoughts  and provides information that affects market dynamics. Therefore, sentiment analysis is essential to recognize and understand users’ requests, both positive and negative [10,11].
Twitter is widely used and provides different views from users worldwide. Twitter is used as a marketing tool for cryptoanalysis owing to the unrestricted conversations about cryptocurrencies that take place on social media channels . Another website utilized for this purpose is Google Trends, which analyzes web search queries . It provides data consisting of comparative search volume scores for specified search terms over a specified period . Sentiment analysis is a process based on machine learning techniques and natural language processing [13-14]. The present work considers the four top cryptocurrencies and uses a convolutional neural network (CNN) model to forecast investor sentiments. We gather daily data on the four cryptocurrencies from Jan 2015 to Feb 2020. The Twitter dataset is used for sentiment analysis. The outcome of our proposed method is compared with those of other methods that are commonly used to forecast prices. The main contributions of the paper are as follows.
• Proposal of a CNN-based model for the prediction of prices of four cryptocurrencies.
• Prediction of cryptocurrency prices using the CNN-based model on the Twitter dataset.
• Evaluation of the proposed method using metrics including mean absolute error (MAE), mean squared error (MSE), and root mean squared error (RMSE) for Litecoin, Bitcoin, Monero, and Ethereum, and comparison with traditional algorithms.
This paper is organized as follows. A summary of previous work is provided in Section 2. Section 3 discusses the problem formulation and system design. Section 4 describes the proposed methodology. Section 5 presents the experimental evaluations. Section 6 concludes the paper.
2 Summary of Related Work
Bitcoin is a new cryptocurrency, and various methods have been proposed to predict its prices. Raju et al.  explored the potential of machine learning algorithms including recurrent neural networks (RNN) together with long short-term memory cells (LSTM) to predict more accurately the direction of Bitcoin price movements in USD, as well as sentiment analysis. Data were extracted from Reddit and Twitter, and the correlations of the movements of Bitcoin prices with these data and their underlying sentiments were examined. Mehta et al.  discussed several features that affect cryptocurrencies, and implemented price prediction and financial market analysis with the help of a machine learning algorithm. The XG-Boost algorithm aims to enhance prediction accuracy; this method also economically predicts the growth of the Bitcoin trend.
Kilimci  predicted Bitcoin price directions in USD by examining user opinions from the English Twitter database. CNN, RNN, and LSTM, as well as word embeddings schemes including GloVe, Fast Text, and Word2Vec, were used for prediction. This approach was shown to achieve better accuracy than previous methods. Valencia et al.  proposed the use of normal machine learning equipment and accessible social media data for prediction of the movements of Ripple, Bitcoin, Litecoin, and Ethereum cryptocurrency prices. Their approach used support vector machines (SVM), neural networks (NN), and random forest (RF) methods, with elements of market data as well as Twitter data as inputs.
Patel et al.  proposed an LSTM and gated recurrent unit (GRU)-based hybrid cryptocurrency prediction method with an emphasis on two cryptocurrencies, Monero and Litecoin. It could predict exact prices with high accuracy, exposing the method applied to several cryptocurrencies’ predictions of prices. However, this method is less suitable for more complex requirements including sentiment data analysis. Yasir et al.  presented a business intelligence scheme for the five top-performing cryptocurrencies, using deep learning, support vector regression, and linear regression to predict their prices. The prices were found to be responsive to public attitudes on social media. Independent investors vigilantly build their investment selection in the cryptocurrency market and ignore communal “flocks” on social media.
Wolk  proposed sentiment analysis for prediction for prices of Bitcoin and other cryptocurrencies over various time intervals. Currency fluctuations were based on people's observations and views but not on institutional currency guidelines. This method employed Google Trends as well as Twitter to forecast short-term prices, using a distinctive multimodal scheme to examine the impact of social media on cryptocurrency prices. Livieris et al.  introduced an ensemble approach that used deep learning schemes as element learners, integrating LSTM, convolutional layers, and bi-directional LSTM. The ensemble schemes were used to predict cryptocurrency prices in the subsequent hours; these prices were designated high or low with respect to the current price. The paper discussed fluctuations in Bitcoin price and the application of several state-of-the-art machine learning and deep learning algorithms for prediction. The nonlinear nature of the prices was determined by various evaluation metrics, and deep learning methods were found to achieve better results than machine learning techniques . Tab. 1 provides a summary of existing work from the literature.
3 Problem Formulation and Objective Function
Past cryptocurrency data take the form of prices reported daily. The prices are taken at independent time codes, where indicates the price at time code j, is the length of the input window, is the input vector, and is the output. and are represented as follows:
The major objective of this work was to predict the value of Pj+l based on an input vector consisting of previous values. The data were gathered from cryptocurrency prediction tables on a daily basis and subjected to pre-processing. Min-max normalization was used to transform the values in the range [0,1]. The data were then divided into two sets, to be used as the testing and training datasets. The proposed method was trained using a deep CNN. In the proposed scheme, the latest input window length is used to predict the price for the next day. This price is then used to predict the subsequent price. This process is iterated over several periods of time, similar to the length of the window used for the prediction. The test database was used to assess the performance of the price prediction method.
4 Convolutional Neural Network
CNN is a feed-forward NN that consists of a convolutional layer, pooling layer, and fully connected layers . The convolutional process can be described as follows :
where indicates the mth feature-map layers of the kth output, indicates the (m-1)th feature-map layer of the jth output, indicates the input map selection, denotes the weights of the jth input map and the kth output map, indicates the convolution operation, indicates the bias, and indicates the rectified linear unit activation function. The pooling layer process is formulated as follows:
where indicates the function of the max-pooling subsampling, indicates the kth input feature map of the mth layer, and represents the bias. Finally, the feature maps are obtained by the computation of numerous convolutional layers combined with the pooling layer to form the input to the fully connected layer. Finally, the last output vector is computed as follows:
where indicates the final output vector of the final output, indicates the input vector, indicates the weights of the (m -1)th layer and the mth layer, and represents the bias.
A total of 10260 Tweets were extracted using the Twitter API. This is the first step in which the required databases consist of four top cryptocurrencies. In the next step, sentiment analysis was performed on the extracted Tweets. Then, the prices of the top four cryptocurrencies were predicted. The dataset contained the close, high, open, and low prices and the volume of every currency. First, we employed CNN without considering social media sentiments. In the next step, the social media content was integrated with several events, and prices were predicted for the four chosen cryptocurrencies, Bitcoin, Ethereum, Monero, and Litecoin. The sentiment analysis used the Alex Davies word list . This list of about 6000 words was classified into three groups: positive, negative, and neutral. A parsing scheme was used to remove emoticons, punctuation marks, and URLs. We also used an alternate list of 5000 words to enhance the training process. Every day, Tweets were labeled as positive, negative, or neutral. The positive and negative ones were then used to compute the average everyday expression of sentiments.
5.1 Preparation of Data
CNN are planned in a manner that they are responsible to design the sequence data. The CNN structure consists of a combination of present inputs, which are discovered from the past inputs, and outputs. In the input layer for our method, the input dataset includes open, close, low, and high prices and volume values. Sentiment is also used as an input. The computations are performed in the convolutional layers. These layers complete the convolutions and transmit the results to subsequent layers for additional processing. The pooling layers are situated between convolutional layers and are used to decrease the complexity of the computations. The fully connected layer contains several neurons linked with the previous layers. In this work, a ratio of 70: 30 was used for the testing/training split, that is, 30% of the data were utilized for testing and the remaining 70% were used for training purposes. The framework for the proposed methodology is shown in Fig. 1. The primary stage involves organizing the data to form an appropriate input. The data are classified into numerous input–output pairs. The input is the set of previous values that are mapped with the output value. An input–output pair is generated by taking the input as and the output as [um] Then, the subsequent input is and the output is . The dataset was constructed in this way. The procedure for the preparation of data is described in Algorithm 1.
5.2 Prediction of Cryptocurrency Prices
The next step involves training the model with the data. The model is trained for 100 iterations. Once the training process has been completed, predictions are made. For the predictions, the last m observations are used as the input, where m is the input sequence length for the scheme. The subsequent input contains the last m-1 values as well as the predicted value. These steps are performed l times, where l represents the size of the prediction window. These procedures are described in Algorithm 2.
6 Results and Discussion
This section explains the data attributes used for the cryptocurrency prediction. The metrics used to evaluate the performance of the proposed method are presented here, performances together with the training of hyperparameters.
6.1 Database Explanation
The data used in this study were gathered from Investing.com for cryptocurrencies Litecoin, Bitcoin, Ethereum, and Monero. These data included five features, the close, high, open, and low prices and the volume for each currency, as reported on a daily basis. The specifications of the individual datasets were as follows. Litecoin: September 23, 2016 to February 22, 2020 (1281 data points); Bitcoin: Jan 22, 2015 to February 12, 2020 (2164 data points); Ethereum: Jan 12, 2015 to February 27, 2020 (1753 data points); Monero: May 31, 2015 to February 26, 2020 (1853 data points). Fig. 2 depicts the graphs of prices vs. time.
6.2 Performance Metrics
The proposed method was assessed with respect to several performance metrics, including MSE, MAE, and RMSE, as given by the equations below:
In Eqs. (6)--(8), M represents the total number of observations.
In Eqs. (9)--(12), signify the true positive, true negative, false positive, and false negative rates, respectively.
6.3 Comparative Analysis
Price prediction was performed for various window lengths: 1 day, 3 days, and 7 days. Prices were predicted for the top four cryptocurrencies using these three scenarios. All four cryptocurrencies were trained for the appropriate data period, and the trained scheme was used for prediction of the subsequent day's price. The performance of the proposed method was compared with that of various other methods; comparisons of the errors obtained with the different methods are shown in Tabs. 2–4. The prediction errors for the proposed method were very small when compared with those obtained for other methods [26-27]. The RMSE  value for the proposed method was less than half those of the other methods. The MAE  error value was one-third of those of the other methods. Notably, the proposed method had a very low error value compared with those of the other methods for the predictions for all three window sizes. The differences in error compared with the other methods were high for the 1-day price prediction, indicating that the proposed method was very efficient for prediction of the next day's prices. However, the method was not very efficient in the prediction of prices for the next 7 days. This demonstrates that the method is more suitable for short-term rather than long-term predictions.
A comparative analysis with respect to various simulation measures including accuracy, sensitivity, specificity, and precision was performed for the proposed approach and two different techniques (RNN and LSTM). The results were evaluated based on the respective parameters; the accuracy, specificity, sensitivity, and precision values for the proposed method were 98.75%, 92.45%, 95%, and 96.25%, respectively, as shown in Fig. 3. Based on the results of this analysis, the proposed method outperformed the other two approaches.
Cryptocurrency price variations depend heavily on social media sentiments, and analysis depends on web search tools. Twitter sentiment analysis considers future cryptocurrency prices as positive because people generally Tweet in a positive manner on cryptocurrencies whenever their prices fall. Therefore, the prediction of cryptocurrency prices is a challenging task owing to their unstable behavior in the present market. This paper proposed an optimized method using CNN and achieved highly accurate results by tuning the parameters. As NN perform better than the state-of-the-art machine learning techniques in the prediction of time-series data, CNN was used for prediction. The parameters of the NN were employed to examine the prices of the cryptocurrency. This CNN-based cryptocurrency price prediction scheme was used to predict prices of four cryptocurrencies, namely, Litecoin, Monero, Bitcoin, and Ethereum. The results demonstrate that the proposed method outperforms other approaches [27-30], based on prediction errors. This work did not explore the different variants of CNN; these could be considered in future work. More complex models incorporating sentiment analysis should also be introduced in the future to enhance the cryptocurrency prediction results.
Funding Statement: The authors received no specific funding for this study.
Conflicts of Interest: The authors declare that they have no conflicts of interest to report regarding the present study.
|This work is licensed under a Creative Commons Attribution 4.0 International License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.|