Using Networks and Partial Differential Equations to Predict Bitcoin Price
UUsing Networks and Partial Differential Equations toPredict Bitcoin Price
Yufang Wang a , Haiyan Wang b, ∗ a School of Statistics, Tianjin University of Finance and Economics, Tianjin 300222,China; b School of Mathematical and Natural Sciences, Arizona State University, AZ 85069,USA;
Abstract
Over the past decade, the blockchain technology and its Bitcoin cryptocur-rency have received considerable attention. Bitcoin has experienced signifi-cant price swings in daily and long-term valuations. In this paper, we proposea partial differential equation (PDE) model on the bitcoin transaction net-work for predicting bitcoin price. Through analysis of bitcoin subgraphs orchainlets, the PDE model captures the influence of transaction patterns onbitcoin price over time and combines the effect of all chainlet clusters. Inaddition, Google Trends Index is incorporated to the PDE model to reflectthe effect of bitcoin market sentiment. The experiment shows that the aver-age accuracy of daily bitcoin price prediction is 0.82 for 362 consecutive daysin 2017. The results demonstrate the PDE model is capable of predictingbitcoin price. The paper is the first attempt to apply a PDE model to thebitcoin transaction network for predicting bitcoin price.
Keywords: bitcoin price prediction, bitcoin transaction network, partialdifferential equations, chainlet, spectral clustering, Google Trends Index
1. Introduction
Bitcoin is currently the world’s leading cryptocurrency and the blockchainis the technology that underpins it. The concept of bitcoin was first suggestedin 2008 by Satoshi Nakamoto, and it became fully operational in January ∗ Corresponding author
Email address: [email protected] (Haiyan Wang)
Preprint submitted to Elsevier January 10, 2020 a r X i v : . [ q -f i n . P R ] J a n
009 [1]. By May 2018, the market capitalization of Bitcoin had arrivedat nearly $115 billion dollars. In contrast to the traditional financial as-set, whose records of everyday monetary transactions are considered highlysensitive and are kept private, Bitcoin has no financial intermediaries and acomplete list of its transactions is publicly available in a public ledger. Thispublicly distributed ledger creates opportunities for people to observe all thefinancial interactions on the blockchain network, and analyze how the assetscirculate in time.Bitcoin value (i.e., the price of a bitcoin) often undergoes large swingsover short periods. For instance, at the beginning of 2013, the price startedat nearly $13 per bitcoin and then rocketed to $230 on 9 April, yieldingalmost 1700% profits in less than four months; In 2017, the value of a singlebitcoin increased 2000%, going from $863 on January 9, 2017, to a high of$17,550 on December 11, 2017.Given the high volatility and the difference from traditional currencies,the price of bitcoin is extremely difficult to predict. A few studies have beenconducted on prediction or estimation for bitcoin prices. Regression modelsare the method mostly used for bitcoin price prediction by considering somepotential price-affecting factors. For instance, Ciaian et al. [2] predict bitcoinprice with a linear regression model by considering some factors in marco-finance and attractiveness for investors. Jang et al. [3] introduce blockchaininformation (such as hash rate and block generation rate) to increase theprediction accuracy by a Bayesian neural network. Researchers also applymachine learning techniques to make bitcoin price predictions [5, 6, 7, 8].Atsalakis et al. [8] use “a hybrid neuro-fuzzy controller, namely PATSOS, toforecast the direction in the change of the daily price of bitcoin.” Cretarolaet al. [9] propose an ordinary difference equation to describe the behavior ofbitcoin price by considering investors’ attention for bitcoin. As the publiclyavailable ledger of the Bitcoin network can be represented by a directedgraph, some work exists to make bitcoin prediction through network analysis[6, 10]. Kurbucz et al. [6] predict the price of bitcoin by the most frequentedges of its transaction network. This study shows the utility of global graphfeatures can be used to predict bitcoin price.It is generally accepted that bitcoin price is significantly affected by at-tention to or sentiment about the Bitcoin system itself [11, 12, 13]. Thefrequency of searches for the term “bitcoin” in Google Trends has provedto be a good measure of interest [9, 11, 14]. Cretarola et al. [9] regard theGoogle Trends index as a proxy for the attention measure and thus pro-2ose a bivariate model in continuous time to describe the behavior of bitcoinprice. Kristoufek et al. [11] demonstrate quantitatively that not only are theGoogle Trends Index and the prices connected but a pronounced asymmetryalso exists between the effect of increased interest in the currency while it isabove or below its trend value.Recently, Akcora et al. [10] studied the influence of local topologicalstructures on bitcoin price dynamics. They combined “chainlets” of the Bit-coin transaction networks with statistical models to predict bitcoin price.Essentially, chainlets are special forms of network motifs or subgraphs in theaddress-transaction bitcoin graph. Chainlets describe transactions occurringin a blockchain and each chainlet represents a trading decision or transactionpattern. In [10] Akcora et al. find that certain types of chainlets exhibitan important role in bitcoin price prediction. It has been found that bitcoinprice is mainly and strongly linked with transaction activities [13, 15]. Anal-ysis of motifs of the bitcoin transaction networks has been found to be anindispensable tool to unveil hidden mechanisms of Bitcoin networks for thebitcoin price dynamics.In this paper, we aim to propose a partial differential equation (PDE)model to predict bitcoin price. As indicated in [10], the predictive utility ofdifferent types of transactions for the bitcoin price dynamics may be differ-ent. As a result, we apply spectral analysis to aggregate bitcoin transactionsubgraphs (chainlets) into clusters with similar types of transaction patterns.We embed the clusters of chainlets into a Euclidean space and develop a PDEmodel to incorporate the bitcoin market sentiment with the Google TrendsIndex. The framework of PDE models developed by the authors for infor-mation diffusion in online social networks in [16, 17, 18] is adapted to theBitcoin transaction network for characterizing the effect of the chainlet clus-ters. The PDE model enables us to describe the influence of the clusterson the price over time. The experiment shows that the average accuracy ofdaily bitcoin price prediction is 0.82 for 362 consecutive days in 2017. Theresults demonstrate the PDE model is capable of predicting bitcoin price.The paper is the first attempt to apply a PDE model on bitcoin transactionnetwork for predicting bitcoin price.In summary, the new contributions of this paper are as follows: (i) it is thefirst attempt to establish a PDE model on the bitcoin transaction networkfor the bitcoin price dynamics; (ii) spectral analysis of the bitcoin transactionnetwork is applied to obtain chainlet clusters to represent different transac-tion patterns and predictive utilities; (iii) within the framework of the PDE3rediction model, we integrate Google Trends and chainlets to account forthe effect of chainlet clusters; (iv) the average prediction accuracy of thismodel is 0.82 for 362 consecutive days in 2017.The remainder of the paper is organized as follows: some basic conceptsare introduced in Section 2. The PDE based prediction model is proposedin Section 3. The prediction process is described in Section 4. Section 5concludes the paper with discussions.
2. Bitcoin and chainlet
A blockchain is a distributed ledger that records transactions in blockswithout requiring a trusted central authority. Each block contains a set oftransactions and it has a hash link to its previous block, thus creating achain of chronologically ordered blocks. When transactions happen at thesame time, they will be recorded in the same block.Bitcoin addresses are used for receiving bitcoins. A transaction representsthe flow of bitcoins from input address to output addresses over time. Atransaction is multi-input, multi-output, which means that a transactionmay have more than one input address and more than one output address.Users take part in the bitcoin economy through addresses and a user canhave two or more addresses at the same time.The transaction-address graphs [10, 19] is a directed graph, which is vi-tal important for knowing bitcoins’ flowing state. In this graph, the set { Address, T ransaction } consists of the vertexes and an edge represents thebitcoin’s transfer between and address node and a transaction node as infigure 1. As transactions are the only means to manage bitcoins, so bitcoinscan be divided or aggregated only by being spent. For instance, a transac-tion involves multiple addresses and every user can have different addresses,so the user can use a transaction to split, merge or move bitcoins betweenits own addresses. Therefore, each transaction with its input and outputaddresses represents a decision, encoded by a subgraph in the transaction-address graph.The subgraph, composed of a transaction with its input and output ad-dresses, is called , or simply may be called chainlet , which is a novelgraph data model, proposed in 2018 [10] for studying bitcoin price dynamics.A chainlet with x inputs and y outputs is often noted as C x −→ y . Chainletshave distinct shapes that reflect their role in the network. They are thebuilding block in blockchain analysis; they represent different transaction4 igure 1: (A) A transaction-address graph; (B)
Split ( C −→ ), Transition ( C −→ ) andMerge ( C −→ ) Chainlets. The three types, Merge, Transtion and Split are determinedaccording to the relative number of input addresses and output addresses, and correspondto the state that the former is greater than, equal to, or less than the latter respectively.Addresses and transactions are shown with circles and rectangles, respectively. An arrowindicates a transfer of bitcoins. patterns, and reflect different decisions. In this paper, we analyze bitcoinchainlets and predict bitcoin price dynamics.
3. PDE model based on chainlets and Google Trends
In this section, we establish a PDE model for bitcoin price prediction.This PDE model is based on chainlets and the Google Trends Index for thebitcoin price. Different types of chainlet clusters represent different transac-tion patterns and transaction decisions; thus, they provide different predic-tive utility for bitcoin price. The PDE model proposed below captures theinfluence of the chainlet clusters and combines the effects of all the clustersfor predicting bitcoin price.
In this paper we use chainlets as the building block for bitcoin priceprediction which represents a type of immutable decision. To make a betterprediction, we use spectral clustering to aggregate chainlets into clusters withsimilar type of transactions. 5 hainlet Network
A transaction with inputs and outputs composes achainlet. Just as in [10], we denote C x −→ y as a chainlet if this chainlet has x inputs and y outputs. Different chainlets have different values of x and y ( x and y are positive integers). Though the Bitcoin protocol limits the numberof input and output addresses for a transaction, the number of inputs andoutputs can still reach thousands. As a result, millions of different chainletsoccur (e.g. C −→ and C −→ ). However, an analysis of the entirebitcoin history shows that 97.57% of the chainlets have fewer than 20 inoutsand outputs [10]. This means that in bitcoin blocks, a sufficiently largenumber of chainlets satisfy 1 ≤ x < , ≤ y < G ( V, E ) with 400 nodes, whereeach node in V is a kind of chainlet or chainlet set and the graph node set { C x −→ y , ≤ x ≤ , ≤ y ≤ } is defined as C x −→ y = C x −→ y , if x <
20 and y < { C x −→ j , ≤ j < + ∞} , if x <
20 and y = 20; { C i −→ y , ≤ i < + ∞} , if x = 20 and y < { C i −→ i , ≤ i < + ∞ , ≤ j < + ∞} , if x = 20 and y = 20 . An edge i and j in E and its weight are determined by the Pearson Cor-relation Coefficient of relative historical daily transaction volume, with acorrelation cut threshold of θ . Chainlets Clustering
Different transactions (transaction with distinctinputs and outputs) contribute differently for the bitcoin price formation.Four hundred distinct chainlets exist in the chainlet network G and eachchainlet represents a type of transaction form. However, intuitively, it is notnecessary to distinguish all chainlets. For example, the transaction patterns C −→ and C −→ have no meaningful difference. Therefore, we cluster chain-lets by spectral clustering, which divides the graph by using the eigenvectorsof Laplacian matrix [20]. Thus, each chainlet cluster represents certain simi-lar types of transaction pattern, which may have different predictive utilitiesfor the bitcoin price. Our PDE model proposed in the next subsection iscapable of capturing the influence of these chainlet clusters and integratingthe effects of all clusters for bitcoin price prediction.In this paper, we apply the daily transaction volumes of the 400 kinds ofchainlets from December 1, 2016 to December 30, 2016 (denoted here it asData-set 1) to build the chainlet network G with a Pearson Correlation cutthreshold θ = 0 .
6. In fact, we can use data in other time periods to build6etwork as well, as long as the time interval of Data-set 1 is earlier than theperiod for which we want to make prediction for bitcoin price. For example, ifwe want to predict the bitcoin price in February, 2017, we can first build thenetwork based on the data in January, 2017. We obtain 10 chainlet clustersby applying spectral clustering method to the above chainlet network G . Ourprediction period is from January 1, 2017, to December 31, 2017 (denotedit as Data-set 2). Figure 2 shows the average transaction volumes of all thechainlet clusters for this period.Bitcoin price is mainly and strongly linked with transaction activities,especially transaction volumes [13, 15]. Figure 2 shows that the chainletclusters we obtain have different levels of transaction volumes. Figure 2: (a)Average transaction volumes for 5 of the 10 chainlet clusters; (b) The 10chainlet clusters obtained by the spectral clustering method. Each color represents acluster. The time period is from January 1, 2017 to December 31, 2017.
In this section, we develop a PDE model to model the influence of chainletclusters with different transaction patterns and combine their effects on thebitcoin price, for the purpose of predicting the bitcoin price.We apply the authors’ framework of PDE models for information diffusionin online social networks [16, 17, 18] to the Bitcoin transaction network forcharacterizing the influence of the chainlet clusters on bitcoin price.To apply a PDE model to the interaction of the chainlet clusters, onemust embed the chainlet clusters U , U , . . . , U n ( n is the number of chainletclusters) into a Euclidean space and arrange them in a meaningful order. Inthis paper, the chainlet clusters are mapped onto a line such that connectedclusters stay as close as possible. Specifically, we now treat each chainletcluster as a node in a new graph G new where the strength of edges is the7 igure 3: Embedding of chainlet clusters into the x -axis. summation of all weights between two clusters. The Fiedler vector (theeigenvector corresponding to the second smallest eigenvalue) of the Laplacianmatrix of the new graph G new can map these chainlet clusters onto a line,showing the order as U i , U i , . . . , U i n [16]. On this line, connected nodesstay as close as possible, ensuring that the continuous model can capture theinfluence of the chainlet clusters.Having embedded chainlet clusters to the Euclidean space, let u ( x, t ) rep-resent the effect of chainlet cluster x on the bitcoin price. The formulation ofthe spatio-temporal model for the bitcoin network follows the balance law:the rate at which a given quantity changes in a given domain must equal therate at which it flows across its boundary plus the rate at which it is cre-ated, or destroyed, within the domain. The PDE model can be conceptuallydivided into two processes: an internal process within each chainlet clusterand external process among chainlet clusters. Similar derivation for the PDEmodel has been used in our previous work for PDE models for informationdiffusion in online social networks in [16, 17, 18]. Our proposed PDE-basedmodel is ∂u ( x, t ) ∂t = ∂∂x (cid:0) d ( x ) ∂u ( x, t ) ∂x (cid:1) + r ( t ) u ( x, t ) h ( x ) , (1)where r ( t ) u ( x, t ) h ( x ) describes the rate of change of bitcoin price within thecluster x ; r ( t ) represents the rate of change with respect to t ; h ( x ) describesthe spatial heterogeneity of different chainlet clusters or transaction patterns. ∂∂x (cid:16) d ( x ) ∂u ( x,t ) ∂x (cid:17) reflects the rate of change of the bitcoin price among chainletclusters, d ( x ) describes the interaction of chainlet clusters. Because u ( x, t )represent the influence of chainlet cluster x on the bitcoin price, we havepredicted bitcoin price = (cid:90) u ( x, t ) dx (2)Investor sentiment about bitcoin, which can be represented by the GoogleTrends Index, is a key factor for determining bitcoin price. It is plausible to8ssume that u ( x, t ) ≡ b m ( x, t ) + α ( x ) , (3)where m ( x, t ) is the predictive utility of the Google Trends Index of chianletcluster x ; b is a scale factor to bitcoin price. α ( x ) describes the heterogeneityof different chainlet clusters on bitcoin price. In this way, chainlet clusterswith larger trading volumes do not necessarily have more influence on thebitcoin price.We derive a PDE model with respect to m ( x, t ). Note both h ( x ) and α ( x )represent the spatial heterogeneity of different chainlet clusters and thereforewe can assume that h ( x ) = kα ( x ) with a constant k . Substituting (3) for (1)and (2) and assuming d ( x ) ≡ d > d is a constant, the prediction model ofbitcoin price is ∂m ( x,t ) ∂t = d ∂ m∂x + kα ( x ) r ( t ) (cid:16) m ( x, t ) + b α ( x ) (cid:17) + db α (cid:48)(cid:48) ( x ) ,m ( x,
1) = φ ( x ) , L < x < L , ∂m∂x ( L , t ) = ∂m∂x ( L , t ) = 0 , t > , Predicted bitcoin price at time t = (cid:82) L L (cid:16) b m ( x, t ) + α ( x ) (cid:17) dx, (4)where • α ( x ) satisfies α ( x i ) = α i , i = 1 , , . . . , m , where α i is the heterogeneityof the cluster at location x i and n is the number of clusters; and r ( t )satisfies exponential decay with time; In this work, r ( t ) is assumedthe form of r ( t ) = b + e − ( t − b ) ; we construct α ( x ) by the cubic splineinterpolation [4] with the condition of ∂α∂x ( L ) = ∂α∂x ( L ) = 0. Therefore,the second derivative α (cid:48)(cid:48) ( x ) exists and is continuous. • Neumann boundary condition ∂m∂x ( L , t ) = ∂m∂x ( L , t ) = 0 , t > x = L , L ; Initial function m ( x,
1) = φ ( x ) describesthe influence of every chainlet cluster and it is constructed from thehistorical data by cubic spline interpolation. • Parameters d, b , b , b , α i , i = 1 , , . . . , n are determined by the knownhistorical data of m ( x i , t j ); 9 The historical predictive utility of the Google Trends Index on bitcoinprice m ( x i , t j ) , i = 1 , , . . . , n ; j = 1 , , . . . , N can be obtained by computing m ( x i , t j ) = (Google Trends Index on “Bitcoin” at time t i ) ∗ P , where P = bitcoin transaction volume of chianlet cluster x j at time t i total bitcoin transaction volume of all chianlet clusters at t i
4. Prediction of bitcoin price
As mentioned in the introduction, bitcoin price is related to the transac-tion volumes and the investors’ attention that can be measured by Google[12]. The daily bitcoin transaction volumes of all transactions and thedaily bitcoin price (here it refers to the intraday open price, denominatedin USD in our work) are downloaded from https://github.com/cakcora/coinworks. from January 1, 2017 to December 31, 2017. These data setsare extracted from the original bitcoin data, which are all publicly avail-able at the Bitcoin Core page ( https://bitcoin.org/en/download. ). TheGoogle Trends Index on “bitcoin” captures the attention of retail/uniformedinvestors [14]. These data can be obtained from https://trends.google.it/trends/?geo=IT with a keyword “bitcoin” .
To predict the bitcoin price at time t N +1 , the prediction process consists indetermination of parameters in (4) using known historical data { m ( x i , t j ) , i =1 , , . . . , n ; j = 1 , , . . . , N } , and solving the PDE-model (4) to make a one-step prediction for m ( x, t N +1 ) , x ∈ [ L , L ]. Thus, the predicted bitcoin priceat time t N +1 is given by P rice ( t N +1 ) = (cid:90) L n L (cid:16) hm ( x, t N +1 ) + α ( x ) (cid:17) dx, (5)Specifically, we combine a tensor train (TT) global optimization approach[22] and NelderMead simplex local optimization method [23] to train the PDE10arameters. After each determination of the model parameters, we applythe fourth-order Runge-Kutta algorithm to compute the PDE for one-stepforward in time dimension numerically.In this work, we obtain 10 chainlet clusters, therefore, n = 10 , L = x =1 , L = x = 10. We use 3 day historical data of m ( x i , t j ) to predict thethe bitcoin price of the 4th day. We make a prediction for the whole year of2017 and the prediction results cover 362 days from January 4, 2017. Therelative accuracy (RA), defined asRA = 1 − | P real − P predict | P real is used to measure the prediction accuracy, where P real is the real bitcoinprice at every data collection time point and P predict is the predicted bitcoinprice. Figure 4: The relative accuracy for bitcoin price prediction from January 4, 2017 toDecember 31, 2017. Here the relative accuracy (RA) is the conventional definition asRA = 1 − | P real − P predict | P real , where P real is the real bitcoin price at every data collection timepoint and P predict is the predicted Bitcoin price through (4). In our prediction time period, though the observed real price range islarge from $ 775.98 to $19498.68, the predicted values based on our proposedprediction model well capture the trend of the real bitcoin price, as in figure4(a). As expected, the prediction performance of the proposed model dete-riorates as the observed real data series is skyrocketing, as in November and11otal days 362 Average Relative Accuracy (RA)=0.82days of RA > > > > > > Table 1: The statistics of days for the prediction results of bitcoin price from January 4,2017 to December 31, 2017. 362 and 134 mean that during the prediction period of 362days, there are 134 days whose relative accuracy of the predictions are above 0.9.
December of 2017 in figure 4(a). However, through statistical analysis of theprediction results, of the 61 days in the last two months of 2017, on 25 daysand 37 days relative accuracies were more than 0.8 and 0.7, respectively.The overall average prediction accuracy of 362 consecutive days in 2017can reach 0.82. All the prediction results are shown in figure 4(b). Of the362 consecutive days in 2017, 82%, 65% and 37% percent of the days achievean accuracy of above 0.7, 0.8 and 0.9, respectively. These statistics for theprediction results are summarized in table 1.
5. Discussions
In this paper, a PDE model is developed for bitcoin price predictionbased on daily bitcoin transaction volumes and Google Trends Index. Theaverage prediction accuracy (measured by relative accuracy) of our model is0.82 for 362 consecutive days in 2017. Because of different datasets, it maybe not comparable with other works. Nevertheless, Kurbucz [6] achieves anaccuracy of approximately 60.05% during daily price movement classificationsbetween November 25, 2016 and February 5, 2018. Jiang et al. [3] obtains anacceptable prediction accuracy through selecting different relevant featuresof blockchain information and comparing the Bayesian neural network withbenchmark models on modeling.Our work differs from the previous prediction models with chainlets. Ak-cora et al. [10] introduces “chainlet” on Blockchain for bitcoin price predic-tion, but they focus only on the effects of certain types of chainlets on bitcoinprice. Our proposed PDE model emphasizes the combined effects from all thedifferent types of chainlet clusters. Further, the continuous model describesthe influence of these chainlet clusters over time.In addition, our PDE model differs from our previous PDE models [16,17, 18] on social networks for predicting information diffusion, air pollution of1289 cities in China and influenza prevalence. In this paper, our PDE modelis developed to capture the combined effect of chainlets from the Bitcointransaction network and their influence on bitcoin price. In particular, theGoogle Trends Index is incorporated in the model to reflect the effect ofmarket sentimental. Unlike the base linear or logistic models in [16, 17, 18],the PDE model in this paper has additional terms to describe the spatialheterogeneity of chainlet clusters. As a result, chainlet clusters with largertrading volumes do not necessarily have more influence on the bitcoin price.In fact, the prediction of bitcoin price is based on the combined influence ofall chainlet clusters.
Acknowledgements
YW was partially supported by the Humanities and Social Sciences Re-search of the Ministry of Education of China (18YJCZH184), the NationalSocial Science Fund of China (19CGL002), the Natural Science Founda-tion of Tianjin (19JCQNJC14800), China Postdoctoral Science Foundation(2018M640232).