Computers, Materials & Continua

A Novel Cryptocurrency Prediction Method Using Optimum CNN

Syed H. Hasan1, Syeda Huyam Hasan2, Mohammed Salih Ahmed3 and Syed Hamid Hasan4,*

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:
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

1  Introduction

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 [1], 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 [2].

Cryptocurrencies are implicit currencies swapped among groups or individuals. Such network-based exchange standards use cryptographic algorithms to protect transactions [3]. 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 [47]. 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 [8]. 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 [9] 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 [12]. Another website utilized for this purpose is Google Trends, which analyzes web search queries [8]. It provides data consisting of comparative search volume scores for specified search terms over a specified period [9]. 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. [15] 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. [16] 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 [17] 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. [18] 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. [3] 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. [19] 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 [20] 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. [21] 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 [22]. 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, {P0,P1,P2,.,Pm}, where Pj indicates the price at time code j, W is the length of the input window, Ve is the input vector, and Oe is the output. V and O 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 [23]. The convolutional process can be described as follows [24]:


where akm indicates the mth feature-map layers of the kth output, ajm1 indicates the (m-1)th feature-map layer of the jth output, Nk indicates the input map selection, ljkm denotes the weights of the jth input map and the kth output map, indicates the convolution operation, ykm indicates the bias, and F() indicates the rectified linear unit activation function. The pooling layer process is formulated as follows:


where down() indicates the function of the max-pooling subsampling, akm1 indicates the kth input feature map of the mth layer, and αkm 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 am indicates the final output vector of the final output, am1 indicates the input vector, Lm indicates the weights of the (m -1)th layer and the mth layer, and ym represents the bias.

5  Methodology

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 [25]. 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 [u0,u1,,um1] and the output as [um] Then, the subsequent input is [u1,u2,,um] and the output is [um+1]. The dataset was constructed in this way. The procedure for the preparation of data is described in Algorithm 1.


Figure 1: Structure of proposed cryptocurrency prediction method


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 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.


Figure 2: Price of (a) Monero, (b) Litecoin, (c) Bitcoin, and (d) Ethereum

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), t(),t(+),f(),\; and f(+) 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. 24. The prediction errors for the proposed method were very small when compared with those obtained for other methods [26-27]. The RMSE [28] value for the proposed method was less than half those of the other methods. The MAE [29] 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.



Figure 3: Comparative analysis based on various performance measures

7  Conclusions

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.


 1.  C. Gurdgiev and D. O'Loughlin, “Herding and anchoring in cryptocurrency markets: Investor reaction to fear and uncertainty,” Journal of Behavioral and Experimental Finance, vol. 25, no. 100271, pp. 100271–100281, 2020.

 2.  M. R. Islam, I. F. Al-Shaikhli, R. B. Nor and V. Varadarajan, “Technical approach in text mining for stock market prediction: A systematic review,” Indonesian Journal of Electrical Engineering and Computer Science, vol. 10, no. 2, pp. 770–777, 2018.

 3.  M. M. Patel, S. Tanwar, R. Gupta and N. Kumar, “A deep learning-based cryptocurrency price prediction scheme for financial institutions,” Journal of Information Security and Applications, vol. 55, no. 102583, pp. 102583–102595, 2020.

 4.  A. Inamdar, A. Bhagtani, S. Bhatt and P. M. Shetty, “Predicting cryptocurrency value using sentiment analysis,” in Proc. 2019 Int. Conf. on Intelligent Computing and Control Systems (ICCSMadurai, India, pp. 932–934, 2019.

 5.  T. R. Li, A. S. Chamrajnagar, X. R. Fong, N. R. Rizik and F. Fu, “Sentiment-based prediction of alternative cryptocurrency price fluctuations using gradient boosting tree model,” Frontiers in Physics, vol. 7, no. 98, pp. 1–8, 2019.

 6.  M. Saad, J. Choi, D. Nyang, J. Kim and A. Mohaisen, “Toward characterizing blockchain-based cryptocurrencies for highly accurate predictions,” IEEE Systems Journal, vol. 14, no. 1, pp. 321–332, 2020.

 7.  S. N. Kiriwendala, “Cryptocurrency price prediction system using twitter sentiment analysis,” B.E. thesis, Informatics Institute of Technology, Sri Lanka, 2019.

 8.  J. Abraham, D. Higdon, J. Nelson and J. Ibarra, “Cryptocurrency price prediction using tweet volumes and sentiment analysis,” SMU Data Science Review, vol. 1, no. 3, article 1, pp. 1–22, 2018.

 9.  O. Kraaijeveld and J. De Smedt, “The predictive power of public twitter sentiment for forecasting cryptocurrency prices,” Journal of International Financial Markets, Institutions and Money, vol. 65, no. 101188, pp. 1–22, 2020.

10. S. Pathak and A. Kakkar, “Cryptocurrency price prediction based on historical data and social media sentiment analysis,” in Innovations in Computer Science and Engineering, vol. 103. Singapore: Springer, pp. 47–55, 2020.

11. L. Nizzoli, S. Tardelli, M. Avvenuti, S. Cresci, M. Tesconi et al., “Charting the landscape of online cryptocurrency manipulation,” IEEE Access, vol. 8, pp. 113230–113245, 2020.

12. F. H. Jahjah and M. Rajab, “Impact of twitter sentiment related to bitcoin on stock price returns,” Journal of Engineering, vol. 26, no. 6, pp. 60–71, 2020.

13. S. Bhatia, “A comparative study of opinion summarization techniques,” IEEE Transactions on Computational Social Systems, vol. 8, no. 1, pp. 110–117, 2020.

14. S. Basheer, S. Surbhi and S. B. Sakri, “Computational modeling of dementia prediction using deep neural network: Analysis on OASIS dataset,” IEEE Access, vol. 9, pp. 42449–42462, 2021.

15. S. M. Raju and A. M. Tarif, “Real-time prediction of BITCOIN price using machine learning techniques and public sentiment analysis,” arXiv preprint arXiv:2006.14473, 2020.

16. T. Mehta, G. Kolase, V. Tekade, R. Sathe and A. Dhawale, “Price forecast and study of financial markets based on news, social feed sentiment analysis using machine learning and market data,” International Journal of Research in Engineering Science and Management, vol. 3, no. 5, pp. 258–261, 2020.

17. Z. H. Kilimci, “Sentiment analysis based direction prediction in bitcoin using deep learning algorithms and word embedding models,” International Journal of Intelligent Systems and Applications in Engineering, vol. 8, no. 2, pp. 60–65, 2020.

18. F. Valencia, A. Gómez-Espinosa and B. Valdés-Aguirre, “Price movement prediction of cryptocurrencies using sentiment analysis and machine learning,” Entropy, vol. 21, no. 6, pp. 589, 2019.

19. M. Yasir, M. Attique, K. Latif, G. M. Chaudhary, S. Afzal et al., “Deep-learning-assisted business intelligence model for cryptocurrency forecasting using social media sentiment,” Journal of Enterprise Information Management, vol. 34, no. 3, pp. 1–16, 2021.

20. K. Wołk, “Advanced social media sentiment analysis for short-term cryptocurrency price prediction,” Expert Systems, vol. 37, no. 2, pp. e12493, 2020.

21. I. E. Livieris, E. Pintelas, S. Stavroyiannis and P. Pintelas, “Ensemble deep learning models for forecasting cryptocurrency time-series,” Algorithms, vol. 13, no. 5, no. 121, pp. 1–19, 2020.

22. E. Mahendra, H. Madan, S. Gupta and S. V. Singh, “Bitcoin price prediction using deep learning and real time deployment,” in 2nd Int. Conf. on Advances in Computing, Communication Control and Networking, Greater Noida, India, pp. 264–268, 2020.

23. Y. Ju, G. Sun, Q. Chen, M. Zhang, H. Zhu and M. U. Rehman, “A model combining convolutional neural network and LightGBM algorithm for ultra-short-term wind power forecasting,” IEEE Access, vol. 7, pp. 28309–28318, 2019.

24. H. Zang, L. Liu, L. Sun, L. Cheng, Z. Wei et al., “Short-term global horizontal irradiance forecasting based on a hybrid CNN-lSTM model with spatiotemporal correlations. Renewable Energy, vol. 160, pp. 26–41, 2020.

25. W. G. Christie and R. D. Huang, “Following the pied piper: Do individual returns herd around the market?,” Financial Analysts Journal, vol. 51, no. 4, pp. 31–37, 1995.

26. I. E. Livieris, N. Niki, S. Stavroyiannis and P. Pintelas, “An advanced CNN-lSTM model for cryptocurrency forecasting,” Electronics, vol. 10, no. 3, pp. 287–303, 2021.

27. S. Cavalli and M. Amoretti, “CNN-Based multivariate data analysis for bitcoin trend prediction,” Applied Soft Computing, vol. 101, pp. 107065–107076, 2021.

28. M. Alojail and S. Bhatia. “A novel technique for behavioral analytics using ensemble learning algorithms in E-commerce,” IEEE Access, vol. 8, pp. 150072–150080, 2020.

29. P. Chaudhary and R. Agrawal, “Emerging threats to security and privacy in brain computer interface,” International Journal of Advanced Studies of Scientific Research, vol. 3, no. 12, pp. 340–344, 2018.

30. O. B. Sezer, M. U. Gudelek and A. M. Ozbayoglu, “Financial time series forecasting with deep learning: A systematic literature review: 2005–2019,” Applied Soft Computing, vol. 90, pp. 106181–106192, 2020.

images 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.