<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article  PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd"><article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article"><front><journal-meta><journal-id journal-id-type="publisher-id">JMF</journal-id><journal-title-group><journal-title>Journal of Mathematical Finance</journal-title></journal-title-group><issn pub-type="epub">2162-2434</issn><publisher><publisher-name>Scientific Research Publishing</publisher-name></publisher></journal-meta><article-meta><article-id pub-id-type="doi">10.4236/jmf.2020.101009</article-id><article-id pub-id-type="publisher-id">JMF-98201</article-id><article-categories><subj-group subj-group-type="heading"><subject>Articles</subject></subj-group><subj-group subj-group-type="Discipline-v2"><subject>Business&amp;Economics</subject><subject> Physics&amp;Mathematics</subject></subj-group></article-categories><title-group><article-title>
 
 
  Bitcoin Price Prediction Based on Deep Learning Methods
 
</article-title></title-group><contrib-group><contrib contrib-type="author" xlink:type="simple"><name name-style="western"><surname>Xiangxi</surname><given-names>Jiang</given-names></name><xref ref-type="aff" rid="aff1"><sub>1</sub></xref></contrib></contrib-group><aff id="aff1"><label>1</label><addr-line>Barstow School of Ningbo, Ningbo, China</addr-line></aff><pub-date pub-type="epub"><day>12</day><month>12</month><year>2019</year></pub-date><volume>10</volume><issue>01</issue><fpage>132</fpage><lpage>139</lpage><history><date date-type="received"><day>30,</day>	<month>August</month>	<year>2019</year></date><date date-type="rev-recd"><day>8,</day>	<month>February</month>	<year>2020</year>	</date><date date-type="accepted"><day>11,</day>	<month>February</month>	<year>2020</year></date></history><permissions><copyright-statement>&#169; Copyright  2014 by authors and Scientific Research Publishing Inc. </copyright-statement><copyright-year>2014</copyright-year><license><license-p>This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/</license-p></license></permissions><abstract><p>
 
 
  Bitcoin is a current popular cryptocurrency with a promising future. It’s like a stock market with time series, the series of indexed data points. We looked at different deep learning networks and methods of improving the accuracy, including min-max normalization, Adam optimizer and windows min-max normalization. We gathered data on the Bitcoin price per minute, and we rearranged them to reflect Bitcoin price in hours, a total of 56,832 points. We took 24 hours of data as input and output the Bitcoin price of the next hour. We compared the different models and found that the lack of memory means that Multi-Layer Perceptron (MLP) is ill-suited for the case of predicting price based on current trend. Long Short-Term Memory (LSTM) provides relatively the best prediction when past memory and Gated Recurrent Network (GRU) is included in the model.
 
</p></abstract><kwd-group><kwd>Deep Learning Model</kwd><kwd> Multi-Layer Perceptron</kwd><kwd> Gated Recurrent Network</kwd><kwd> Long Short-Term Memory</kwd><kwd> Cross-Validation</kwd><kwd> Normalization</kwd></kwd-group></article-meta></front><body><sec id="s1"><title>1. Introduction</title><p>Bitcoin is a cryptocurrency and a form of electronic cash. It is a digital currency that can be sent from user to user on the peer-to-peer Bitcoin network without intermediaries. It keeps a record of trading among peers and every record is encrypted. Each new record created contains the cryptographic hash of a previous block. Each record contains a timestamp and the data of the sender, the receiver, and the amount. Given Bitcoin is an emerged technology, few predictions is made on Bitcoin future value. Greaves and Au used linear regression, logistic regression and support vector machine to predict Bitcoin future price with low performance [<xref ref-type="bibr" rid="scirp.98201-ref1">1</xref>]. Indira et al. proposed a Multi-layer Perceptron based non-linear autoregressive with External Inputs (NARX) model to predict Bitcoin price of the next day [<xref ref-type="bibr" rid="scirp.98201-ref2">2</xref>]. Jakob Aungiers proposed a long-short term memory deep neural networks to predict S &amp; P 500 stock price [<xref ref-type="bibr" rid="scirp.98201-ref3">3</xref>]. His research sheds light on Bitcoin prediction which is similar to stock price. Madan et al. used more machine learning approaches like generalized linear models and random forest to address Bitcoin prediction problem [<xref ref-type="bibr" rid="scirp.98201-ref4">4</xref>].</p><p>Researches mentioned above focuses on predicting the Bitcoin price of the next day. However, Bitcoin is traded frequently in a much smaller interval. In this research, we try to use historical data to predict next hour’s price instead of next day’s price which may have better application in real world. First we implemented data normalization like min-max normalization and normalization with window [<xref ref-type="bibr" rid="scirp.98201-ref5">5</xref>] where the data is normalized based on the window’s initial value and the percentage of change. Multiple Layer Perceptron (MLP), Long-Short-Term-Memory (LSTM) and Gated recurrent units (GRU) models are compared on the test dataset with cross-validation.</p></sec><sec id="s2"><title>2. Dataset Exploration</title><p>Data used in this research is collected from Kaggle [<xref ref-type="bibr" rid="scirp.98201-ref6">6</xref>]. Bitcoin data from Jan 2012 to July 2018 is collected. It has a timestamp, the value at Open, High, Low, Close, the volume traded in Bitcoin and USD, the weighted price and the date. This research focuses on predicting Bitcoin price in the future hour by using the price of past 24 hours, so only the timestamp and the weighted price are used in the model.</p></sec><sec id="s3"><title>3. Pre-Processing</title><p>As shown in <xref ref-type="fig" rid="fig1">Figure 1</xref>, the dataset is by minute, and contains around 3,409,920 points. Since we predicted the price by hours, we have had 1,409,920/60 which is 56,832 datapoints. The dataset is further split into training, validating and testing sets. As shown in <xref ref-type="fig" rid="fig2">Figure 2</xref>, training data takes up to 80% of the entire dataset, and validating and testing 10% respectively. As the time series data, samples are not randomized. We used the first 24 hours’ Bitcoin price as input to predict the next hours’ Bitcoin price. Several other pre-processing methods are implemented to improve data processing and model convergency efficiency. Minibatch is used to split large data into small batches, which improves memory efficiency. Minimum-Maximum normalization and window-based normalization is used to set the whole training dataset to (−1, 1) scale. Window normalization is based on the reference of stock market. The normalization methods will take each sized window and normalize each one to reflect percentage changes from the start hour of the window [<xref ref-type="bibr" rid="scirp.98201-ref3">3</xref>].</p></sec><sec id="s4"><title>4. Models</title><p>Deep learning network is a type of computer modeling that finds the pattern within the given datasets and categorize the input accordingly. There are many</p><p>different structures for deep learning network, including Multiple Layer Perceptron (MLP) that has a linear activation function, Recurrent Neural Network (RNN) that records a separate hidden unit to influence the next calculation. Extensions of RNN include Long Short-Term Memory (LSTM) and Gated Recurrent Model (GRU).</p><p>MLP is a basic method in prediction. It reads all input with no ordering and then determine the relationship between the independent variables and the dependent variables. Hidden layers can be added between the input layer and the output layer together with the activation function, to better describe the non-linear relationship.</p><p>RNN is a group of method to calculate products from previous result of the model and new input data. In fact, it is better to MLP that it has “experience” from last calculations that will influence its calculations. The “experience” is gained from the model, is kept privately but is allowed to pass onto the next model. This private variable is called the hidden state and is passed on from the current calculation to the future calculation. It determines independently the output of the model, apart from the algorithm itself. However, RNN model depends on the continuous flow, which is sequential like the time series, in order to input data for the training. If the pattern repeats only over the long term, the previous repetition may be not influential enough to affect it at the next repetition. It also requires the data to be in order of time. Therefore determines, unlike MLP, RNN cannot be given random samples.</p><p>Long Short-Term Memory solves the issue that the diminished influence of distant events on the RNN network. It has a switch that can choose certain events to remember. It also is not long-term dependent and doesn’t require as much training. It has four layers to determine the output, then passes the hidden state with the result to the next cycle. “Forgetting gates” exists in addition to four layers to determine if the experience should not be counted. Four layers and forgetting gates can be given different information to focus on either short-term or long-term memory.</p><p>GRU or Gated Recurrent Model is considered as one of the simpler model compared to the LSTM model, combination of the “forget” step with the “input” step into one, and as a result, requires only one hidden unit.</p><p>Among the three methods, MLP is mostly credited with its simplicity and the need for less computational power. They have the same amount of information as input. However, the number of hidden layers and the hidden units are more magic numbers. Some number turns out to work well especially, while some may turn out to be just the opposite. RNN accounts on the previous model through the hidden unit. The value uses in the calculation but does not need intervention. It can be very accurate, given the fact that the model has a large training set. However, long term patterns cannot be memorized and this may result in inaccuracy, especially when rapid changes take place in recent years. LSTM can choose whether it should “forget” previous states. Therefore, it is better capable of dealing with data that has repetitive trend over a long time. GRU model is also able to choose whether it should recall previous experience, but it is capable of learning more rapidly and need a bit less resource.</p><p>Six models are compared in this research. The model setups are listed in the following <xref ref-type="table" rid="table1"><xref ref-type="table" rid="table">Table </xref>1</xref> and training results will be discussed in the next part.</p></sec><sec id="s5"><title>5. Results</title><p>As shown in <xref ref-type="fig" rid="fig3">Figure 3</xref>, in MLP and RNN frameworks, we find the similar</p><table-wrap id="table1" ><label><xref ref-type="table" rid="table1"><xref ref-type="table" rid="table">Table </xref>1</xref></label><caption><title> Font sizes of headings. <xref ref-type="table" rid="table">Table </xref>captions should always be positioned above the tables</title></caption><table><tbody><thead><tr><th align="center" valign="middle" >Model</th><th align="center" valign="middle" >Layer Information</th></tr></thead><tr><td align="center" valign="middle" >2 Layer MLP</td><td align="center" valign="middle" >[256, 256]</td></tr><tr><td align="center" valign="middle" >3 Layer MLP</td><td align="center" valign="middle" >[256, 128, 64]</td></tr><tr><td align="center" valign="middle" >2 Layer LSTM</td><td align="center" valign="middle" >[256, 256]</td></tr><tr><td align="center" valign="middle" >2 Layer LSTM + 1Fully Connected layer</td><td align="center" valign="middle" >[256, 256] + [<xref ref-type="bibr" rid="scirp.98201-ref128">128</xref>]</td></tr><tr><td align="center" valign="middle" >3 Layer LSTM</td><td align="center" valign="middle" >[256, 256, 128]</td></tr><tr><td align="center" valign="middle" >2 Layer GRU</td><td align="center" valign="middle" >[256, 256]</td></tr></tbody></table></table-wrap><p>conclusion that window-based normalization is much better than whole-dataset-based normalization. Because of time-series data feature, the RNN frameworks converge faster than MLP methods. Model performance in this research is evaluated by Root Mean Square Error (RMSE) of the predicted price and the true price of the dataset. The results are listed in the following table. As shown in <xref ref-type="table" rid="table">Table </xref>2, normalization by window method performs much better.</p><p>We visualize the predicted price in the test dataset against true values in <xref ref-type="fig" rid="fig4">Figure 4</xref> and zoom in to have a closer look at the predicted price in <xref ref-type="fig" rid="fig5">Figure 5</xref>. We can find that LSTM with normalization by window is the best combination.</p><p>A ten-fold cross-validation is conducted on all the models. As shown in <xref ref-type="fig" rid="fig6">Figure 6</xref>, we can see that the error goes down after the training set is enlarged. At the end of the time-series data, when the ﬂuctuation goes high, the error goes up a little again. Based on the cross-validation results, as summarized in <xref ref-type="table" rid="table">Table </xref>3, 2 layers of GRU is the best, and 2 layers of LSTM are very close to the performance.</p><table-wrap id="table2" ><label><xref ref-type="table" rid="table">Table </xref>2</label><caption><title> RMES of six models by different normalization methods</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >Normalized By Window</th><th align="center" valign="middle" >Normalized Whole Dataset</th></tr></thead><tr><td align="center" valign="middle" >2 Layer MLP</td><td align="center" valign="middle" >131.023</td><td align="center" valign="middle" >2541.128</td></tr><tr><td align="center" valign="middle" >3 Layer MLP</td><td align="center" valign="middle" >156.922</td><td align="center" valign="middle" >3692.356</td></tr><tr><td align="center" valign="middle" >2 Layer LSTM</td><td align="center" valign="middle" >125.387</td><td align="center" valign="middle" >8312.999</td></tr><tr><td align="center" valign="middle" >2 Layer LSTM + 1FC</td><td align="center" valign="middle" >126.016</td><td align="center" valign="middle" >9187.938</td></tr><tr><td align="center" valign="middle" >3 Layer LSTM</td><td align="center" valign="middle" >125.414</td><td align="center" valign="middle" >Not tried</td></tr><tr><td align="center" valign="middle" >2 Layer GRU</td><td align="center" valign="middle" >126.512</td><td align="center" valign="middle" >Not tried</td></tr></tbody></table></table-wrap><table-wrap id="table3" ><label><xref ref-type="table" rid="table">Table </xref>3</label><caption><title> Summarize of cross-validation results</title></caption><table><tbody><thead><tr><th align="center" valign="middle" ></th><th align="center" valign="middle" >Mean RMSE</th><th align="center" valign="middle" >Std RMSE</th></tr></thead><tr><td align="center" valign="middle" >2 Layer MLP</td><td align="center" valign="middle" >20.093</td><td align="center" valign="middle" >39.630</td></tr><tr><td align="center" valign="middle" >3 Layer MLP</td><td align="center" valign="middle" >22.736</td><td align="center" valign="middle" >45.711</td></tr><tr><td align="center" valign="middle" >2 Layer LSTM</td><td align="center" valign="middle" >19.121</td><td align="center" valign="middle" >38.214</td></tr><tr><td align="center" valign="middle" >2 Layer LSTM + 1FC</td><td align="center" valign="middle" >19.486</td><td align="center" valign="middle" >38.808</td></tr><tr><td align="center" valign="middle" >3 Layer LSTM</td><td align="center" valign="middle" >19.250</td><td align="center" valign="middle" >38.177</td></tr><tr><td align="center" valign="middle" >2 Layer GRU</td><td align="center" valign="middle" >19.020</td><td align="center" valign="middle" >38.146</td></tr></tbody></table></table-wrap></sec><sec id="s6"><title>6. Conclusion and Discussion</title><p>According to cross-validation results, 2 layers of LSTM has the best performance on the original test dataset and 2 layers of GRU is the best. All six models have close performance, so different models may be preferred in different scenarios. MLP model requires less computing power while it has slightly lower performance than RNN model. Our study combines several unique features, including the hour-based prediction, the usage of data from the past 24 hours, normalization by window and the comparison of different types of model with different amounts of layers. Based on this research, future work can be done on predicting a sequence of estimation so that it can be applied in more common Bitcoin trading scenarios.</p></sec><sec id="s7"><title>Conflicts of Interest</title><p>The author declares no conflicts of interest regarding the publication of this paper.</p></sec><sec id="s8"><title>Cite this paper</title><p>Jiang, X.X. (2020) Bitcoin Price Prediction Based on Deep Learning Methods. Journal of Mathematical Finance, 10, 132-139. https://doi.org/10.4236/jmf.2020.101009</p></sec></body><back><ref-list><title>References</title><ref id="scirp.98201-ref1"><label>1</label><mixed-citation publication-type="other" xlink:type="simple">Alex, G. and Au. B. (2015) Using the Bitcoin Transaction Graph to Predict the Price of Bitcoin.</mixed-citation></ref><ref id="scirp.98201-ref2"><label>2</label><mixed-citation publication-type="other" xlink:type="simple">Indera, N.I., Yassin, I.M., Zabidi, A. and Rizman, Z.I. (2017) Non-Linear Autoregressive with Exogeneous Input (NARX) Bitcoin Price Prediction Model Using PSO-Optimized Parameters and Moving Average Technical Indicators. Journal of Fundamental and Applied Sciences, 9, 791-808. https://doi.org/10.4314/jfas.v9i3s.61</mixed-citation></ref><ref id="scirp.98201-ref3"><label>3</label><mixed-citation publication-type="other" xlink:type="simple">Aungiers, J. (2018) Time Series Prediction Using LSTM Deep Neural Networks. https://www.altumintelligence.com/articles/a/Time-Series-Prediction-Using-LSTM-Deep-Neural-Networks</mixed-citation></ref><ref id="scirp.98201-ref4"><label>4</label><mixed-citation publication-type="other" xlink:type="simple">Isaac, M., Saluja, S. and Zhao. A. (2015) Automated Bitcoin Trading via Machine Learning Algorithms. http://cs229.stanford.edu/proj2014/Isaac%20Madan,%20Shaurya%20Saluja,%20Aojia%20Zhao,Automated%20Bitcoin%20Trading%20via%20Machine%20Learning%20Algorithms.pdf</mixed-citation></ref><ref id="scirp.98201-ref5"><label>5</label><mixed-citation publication-type="other" xlink:type="simple">Pedregosa, F., et al. (2011) Scikit-Learn: Machine Learning in Python. Journal of machine learning research, 12, 2825-2830.</mixed-citation></ref><ref id="scirp.98201-ref6"><label>6</label><mixed-citation publication-type="other" xlink:type="simple">Zielak. (2019) Bitcoin Historical Data, Bitcoin Data at 1-Min Intervals from Select Exchanges, Jan 2012 to July 2018, Version 14. https://www.kaggle.com/mczielinski/Bitcoin-historical-data</mixed-citation></ref></ref-list></back></article>