1 Introduction
Blockchain as a new technology has a potential to change the traditional way of communication, contracting, and financial management. The first and still most popular use of blockchain technology is its use as a digital currency, or cryptocurrency, as a part of the the Bitcoin protocol Nakamoto2008 . There the payments are processed by a peertopeer Bitcoin network where users announce new transactions and which are verified by network nodes and recorded in a blockchain  a public distributed ledger. Beyond its usage in cryptocurrencies, blockchain technology’s essential importance is to offer a new way to record and store confidential information. It has a potential to enable services that we do not even consider today, for example to offer support for liberalist’s way of decisionmaking, aid in development of a fairvalue, decentralized marketplaces and help increase financial inclusion in developing countries. Blockchain could be one of the future solutions Dirk2016 ; Future4.0 to secure liberalism and preserve the integrity of policymaking decisions as it promises faster and costefficient methods for election voting, as well as protection against manipulations and cyberattacks . Blockchain can also be used as a building block for new decentralized marketplaces that offer avoidance of overpricing and manipulation because they provide a place for negotiating contracts that are based on realistic supply and demand in the market. Blockchain could provide access to financial sector services such as loans, insurance, savings, signing contracts and sending and receiving payments to lowincome or socially excluded people in the developing countries Watanagase15 . This can be achieved solely through mobile internet access, which is more costeffective than developing traditional financial infrastructure.
Blockchain offers a unique view into today’s economic and financial systems that are global and interdependent. Researchers have used network approach to study such complex an dynamic systems to reveal important system characteristics or shed light on inherent network vulnerabilities acemoglu2013network ; huang2013cascading ; sakamoto2017systemic ; glasserman2015likely ; battiston2016complexity ; piskorec2014cohesiveness ; huang2011identifying ; vodenska2016interdependencies . This approach is especially appropriate for studying in the Bitcoin network, which connects its users on a global scale and allows them to exchange nonphysical, nonregulated, and decentralized financial assets without any economical equivalent or guarantee by a central bank or a sovereign Yermack2015 ; AssetCurrency . Although it is a relatively new system, different aspects of the Bitcoin have already been extensively analyzed, including price formation Garcia2014 ; Garcia2015 ; amjad2017trading ; DidierSpencer , price fluctuations Tian ; Kim2016 ; KondorBTC , systems dynamics BTCstructure ; KondorBTC ; ElBahrawy2017 , economic value Bolt2016 ; Hayes2015 ; Kristoufek2015 , limit order book dynamics BouchaudBTC ; Tian , privacy and security Shamir ; Mser2017 , blockchain protocol and mining process Garay2015 ; Eyal2018 and many others.
In this paper, we are interested in the following question: Is it possible to infer early warning indicators (EWIs) that are able to predict shortterm extreme volatility events on a timescale of 110 days, from daily Bitcoin transaction graphs. The transaction graphs extracted from blockchain data contain information about the money flow among different Bitcoin addresses without any pricing data. A market price is usually formed as a combination of different complex economic and financial effects btcEconomy ; Bolt2016 ; btcFormation1 ; DidierSpencer . According to a recent study Bolt2016 , the values of virtual currencies are affected by the demand for such currencies to purchase real goods and services, in addition to the speculative buying and selling dynamics on the exchanges. All Bitcoin transactions are written to the blockchain, in form of temporal transaction graphs, where nodes represent different Bitcoin addresses and edges represent the money flow based on transactions (purchases and sales of goods and services). A study by Kondor et. al. KondorBTC demonstrated that there exists a certain correlation between the Bitcoin network structure and the market effects i.e. Bitcoin price change, up to early 2014. However, the authors of KondorBTC did not test the predictive power on holdout data. This has motivated us to analyze patterns in the transaction graphs from the Bitcoin blockchain using unsupervised and supervised machine learning. Our methodology consists of two main steps: (i) constructing lowdimensional representations of the transaction graphs and (ii) learning how to combine lowdimensional representations in order to be able to predict shortterm extreme volatility events. In Section 2, we describe the blockchain data and methods that we use. Section 3 and 4 provide the evaluation of our results and discussion.
2 Data and methods
Blockchain consists out of a list of transactions, each with a certain number of inputs and outputs. Each input consists of the hash of the current transaction, hash of the previous transaction, the public key of the current input, timestamp, and other data. Similarly, each output has the hash of the current transaction, the public key of the output address, amount of bitcoins, time stamp and other data. The user transaction network can be extracted from the blockchain by exploiting the fact that initiating a transaction with multiple inputs requires signing it with the private keys of all input addresses. This implies that all of these addresses are controlled by the same entity KondorBTC ; Shamir ; Nakamoto2008 that we simply call a user. Similar as in literature KondorBTC ; Shamir , we process hundreds of gigabytes of Bitcoin blockchain data by merging all addresses that belong to the same user. After processing we get the temporal weighted directed transaction networks, where nodes represent users after the merging process. Each link represents a transaction event from source user to destination user at time with amount of bitcoins. We filter only the longterm users that were active before the January 1st 2017. Users are considered longterm users if they were involved in at least 100 individual transactions and at least 600 days passed between their first and last appearance in the dataset. This filtering gives us over 106 millions of transactions between 114 768 longterm users which corresponds to over 90% of all blockchain volume. The time evolution of the Bitcoin transaction network is encoded in the matrix , where denotes the number of temporal snapshots of a network, that is described with values. Column represents encoded temporal snapshot at day . In the case of edge encoding, the
th position of vector
encodes the number of bitcoins that were exchanged through th edge in day . In the case of node encoding, the th position of vector encodes the number of bitcoins that th node received from all other nodes in day .2.1. Lowdimensional representations of transaction graphs
We use techniques from unsupervised learning to create low dimensional representations
of the Bitcoin transaction graphs. We employ the nonnegative matrix factorization (NMF), which is particularly suited for our problem because it produces nonnegative factors which have a clear interpretation  the factors correspond to the (potentially overlapping) subnetworks of the original transaction graph. This is in contrast to some other matrix factorization methods, for example Singular Value Decomposition (SVD), which can produce factors with negative weights KondorBTC . The Bitcoin evolution matrix X can be factorized into two nonnegative matrices , where the consists out of basis vectors , each of which corresponds to the subnetworks of the transaction graph. The matrix contains low dimensional representations of transaction graphs. Note that we use different terminology depending on the context: basis vectors for linear algebra context, factors for matrix factorization context and base networks for network context. The reconstruction of the transaction network for day is the nonnegative linear combination of nonnegative basis networks:(1) 
This means that each transaction network can be decomposed as a superposition of the transaction subnetworks (see Figure 1, panel C), where each contributes with weights . We formulate the optimization problem, where we seek NMF factors that minimize the reconstruction error (see Figure 1
, panel AB). In order to handle high dimensional noisy data and outliers, we use the robust NMF
RNMF formulation: where denotes the matrix norm. This norm L1 is robust to outliers and it is defined as: where denotes the L2 norm. In order to have sparse representations, we also add the norm on the encoding matrix H to the optimization function:(2) 
This optimization problem is nonconvex and it is solved by adopting the iterative procedure to alternatively fix one of the matrices and then solve the convex problem with multiplicative update rules RNMF (see appendix).
2.2. Early warning indicator (EWI)
We denote the early warning indicator as and model it as a linear function of low dimensional representations H of a transaction graph.
As the volatility has nonnegative domain, we construct early warning indicator as a nonnegative linear superposition of nonnegative elements (features) in the encoding matrix H:
(3) 
where denotes the dimensionality of lowdimensional representation and the autoregressive order i.e. number of historical days used for prediction. In the rest of the text we refer to this supervised model (3) as Linear Nonnegative AutoRegressed NMF model (NMFNLR). Next, we need to infer the coefficients in such a way to be able to predict future volatility.
2.3. Inference step
First, we describe the partitioning of data to train and holdout parts, as well as inference settings.
We partition the dataset X with respect to temporal points into disjoint holdout segments such that each segment is days long.
Now, for each holdout segment we use the previous days for training.
For simplicity, each training segment is denoted as and its
corresponding validation segment as .
In summary, we have two different partitions of the data: (i) disjoint holdout segments and corresponding overlapping segments used for training . Each model is trained on segment and validated on segment, where we use days for holdout segments and days for training.
In training phase, for each training segment
, we perform feature extraction with the nonnegative matrix factorization
. Matrices W,H are found by solving the optimization problem in equation 2, defined in section 2.1. Recall, that columns in matrix H are lowdimensional representations (features) of daily transaction graphs. Then, coefficients are found by minimizing the square difference between EWI and volatility for next day i.e. . We inferred the nonnegative coefficientsfor regularized nonnegative linear regression by using the updates rules for sparse nonnegative coding
SNMF . Note that the inferred coefficients c for the training segment are associated with the base matrix W. If we change the base matrix W, the representation H also changes. Therefore, for each training segment the model parameters are .In validation phase, for each holdout segment , we use the corresponding model from previous adjacent training segment. First, we need to extract representations H that are associated to the learned model . Representations are found by the following convex optimization problem:
(4) 
Note, that the matrix W is fixed and therefore we only use the update rules for finding matrix H (see Appendix). Finally, we use the coefficients c to form predictions on holdout segment with equation 3. Fixing a base matrix W is necessary if we want to use the inferred coefficients.
3 Results
Our final aim is to be able to predict shortterm extreme volatility events, not the volatility value itself. At day we want to predict that the extreme event will happen in future segment of days. In a special case, when
we have a localized prediction for next day. From machine learning perspective, we want to classify future segment into class “1” or “0”, where class “1” means extreme volatility event. More formally, based on the EWI
, we make prediction for segment as:(5) 
3.1. Extreme event definition The price fluctuations are measured with the GarmannKlass GarmanKlass definition of volatility. That is calculated as , where stand for open/high/low/close daily price. If the level of volatility exceeds some threshold , we will consider it as an extreme volatility event. We use the following threshold levels , which result in 18%, 5%, 2.5% and 1.6% of events being labeled as extreme ones in period from 2012 to 2017. A time segment of length is considered extreme if it contains at least one extreme volatility event, independent on it’s localization. One can think of as a localization parameter in future horizon. The ground truth is denoted as and for segment of days in future is:
(6) 
Simply, if the daily volatility in next is always less than , we mark this segment with label “0”. Although our prediction task is classification, we have used the regression in the inference step, which is not uncommon practice in machine learning Suykens1999 . Remember that the vector denotes the snapshot of Bitcoin network dynamics at day . Due to the scalability issues we have used the node encoding, rather than edge encoding, to describe the snapshot of Bitcoin dynamics. The node encoding, on every th position in vector has the value of the total number of Bitcoins that node received from other nodes during one day . In the future work, we plan to analyze edge encoding version in more detail.
3.2. Evaluation
We use a receiver operating characteristic (ROC) curve that gives a prediction ability of a binary classifier as its discrimination threshold is varied. The ROC curve is created by plotting the true positive rate (TPR) against the false positive rate (FPR) at various threshold settings . True positive rate is a proportion of true extreme events that were correctly classified as such , while the false positive rate is proportion of our predicted extreme events that were falsely classified as such .
We compare the area under the ROC curve (AUC ROC) against a baseline for the random signal, where AUC ROC (RND) equals 0.5. Due to the fact that the extreme events are much less common than nonextreme events, we also use the area under precisionrecall curve Davis2006 (PR). Note that recall is equivalent to the true positive rate and precision is defined as the proportion of our predicted extreme events which are indeed extreme . We compare the area under the PR curve (AUC PR) against a baseline for the random signal, where AUC PR (RND) is denoted as .
Here is the fraction of events that have the positive ground truth label .
In Figure 2 we show the EWI (plot B), along with volatility (plot A), ROC and PR performance curves (plots CF). We observe that the EWI (, ) in period 20122014 can predict future extreme events (, ) with the following performance (, ) on plot C and (precision , recall) on plot D.
In the next section we analyze the sensitivity of prediction in more details.
3.3. Statistical and sensitivity analysis for EWI
In the previous section we have showed the ROC and PR curves for fixed parameters: factors, regressive days and evaluation for predicting extreme event within horizon of day. In this section, we make statistical and sensitivity analysis by providing the area under the curve statistics (AUC) over all possible parameters and comparing it to the AUC of a random classifier.
Note that prediction of extreme events within different localization horizons differs in prediction difficulty. E.g. prediction of extreme event happening at horizon days in future is more localized prediction than predicting the extreme event happening at next days in future. Furthermore, as we are dealing with different ratios of extreme events (imbalance dataset) only PR curves are used for sensitivity analysis for different horizons
. This is due to the fact that ROC curves are not sensitive as PR curves for skew imbalance (
) in datasets Davis2006 . Sensitivity analysis for different levels of thresholds, autoregressive order parameters and number of NMF factors are all taken into consideration.In Figure 3 panel A, we see the AUC PR performance for the the early warning indicator derived from a blockchain volume time series volume i.e. a total number of bitcoins in transaction networks at day . In Figure 3 panel B, we use lowdimensional features obtained from a singular value decomposition, along with linear regression as the second baseline for the EWI. This baseline is very similar to the Kondor et. al. study KondorBTC .In the case of both baselines, we observe that the AUC PR performance of the EWI increases as the localization length of the extreme event increases. This is in correspondence with our assumption that the predictability changes for different values of .
In the Figure 3 panel C, we can see the performance of the random baseline, which increases with the localization length
. As the prediction segments become larger so does the probability of the occurrence of the extreme event by chance. In Table
1 we show the numerical values for different baselines and different values of parameter . We observe that the proposed inferred signal (NMF+NLR) has the highest prediction performance. In Table 1, part A, we also show the difference between the AUC performance of EWI and AUC performance of a random baseline (RND). We observe that on average it is easier to predict less extreme event  smaller values of parameter . In a case when the prediction is only based on the features from a current day (, see Table 1, part B) the predictions of extreme events (, and ) significantly drops with respect to case. This shows that the historical autoregressed terms () are important for predictions. In general, sensitivity analysis shows that results are also relatively stable for different parameters of (Table 1, part C). However, more indepth analysis of the embedding dimensionality was out of the scope of the current work and is left for future work.Indicator ()  

AUC PR (VOL)  0.167  0.057  0.043  0.027  
A  AUC PR (RND)  0.186  0.053  0.025  0.016 
AUC PR (SVD+LR)[=10,]  0.201  0.092  0.062  0.052  
AUC PR (NMF+NLR)[=10,]  0.344  0.204  0.181  0.195  
B  AUC PR (NMF+NLR)[=10,]  AUC PR (RND)  0.172  0.064  0.033  0.021 
AUC PR (NMF+NLR)[=10,]  AUC PR (RND)  0.164  0.129  0.130  0.127  
C  AUC PR (NMF+NLR)[=5,]  AUC PR (RND)  0.149  0.137  0.176  0.171 
AUC PR (NMF+NLR)[=20,]  AUC PR (RND)  0.194  0.143  0.165  0.150 
4 Discussion and conclusion
In this paper we analyze the performance of early warning indicators for extreme future volatility in two different time periods: (i) 20122014, and (ii) 20122017. We observe that the performance during the first (shorter) period up to 2014 is better compared to the performance over the entire period analyzed. On one hand, the ROC AUC and the PR AUC are 0.73 and 0.51 respectively for the period between 20122014, while, on the other, for the entire period (20122017), the ROC AUC and the PR AUC are 0.65 and 0.2 respectively (See Fig. 2. CF). To better understand the differences in model performance between these two periods, we study the changes in the ratio of (i) total market exchange volume in Bitcoin and (ii) the Bitcoin volume in the transaction graphs that we analyze . includes all Bitcoin exchange transactions on the following exchanges: Bitfinex, Bitflyer, Bistamp, BtcChina, Coinbase, LakeBtc, MtGx, OkCoin, and others). We find that the ratio increases tenfold after 2014, from a maximum value of 3 during the period 20122014 to over 30 in 2017. This implies that there is a significant overwhelming interest in Bitcoin as a speculative investment asset, compared to its use as payment mechanism for purchasing and selling goods and services, represented by the number of transactions on the transaction graphs that we have analyzed. Hence, due to this dynamics, there is a significant deficiency in information obtained from the transaction graphs relative to the information contained in speculative trading or using Bitcoin as shortterm investment asset. This trend is due to the slow maturing of Bitcoin as a payment method and the skepticism of its wide adoption due to lack of regulation and fear of significant loss in value due to electronic theft of Bitcoins or extreme volatility. Our hypothesis is that the transaction graphs or the relational aspect of Bitcoin will inform more about future volatility and can become an important early warning signal for ensuing volatility once Bitcoin becomes more mature payment method in trades of gods and services, which is an interesting topic for future research.
Acknowledgement and contribution
Thanks to students Grüner Maximilian, Weingart Nino, Riesenkampf Heiki
for help in processing blockchain data.
The work of N.A.F. has been funded by the EU Horizon 2020 SoBigData project under grant agreement No. 654024.
All authors contributed to the writing and editing of the manuscript.
N.A.F. performed computational modeling and experiments.
D.T. performed computational modeling and design of research.
M.P. and Z.C. were involved in data processing and analysis.
I.V. was involved in financial analysis and interpretation of results.
Appendix
In order to solve the following nonconvex optimization problem where denotes the matrix norm. First we randomly initialize the matrices H,W then iteratively fix one of the matrices (W,H) and perform the update step on another matrix. The procedure is repeated until the convergence. We use the following updatesRNMF : , , where are diagonal matrices defined as: ,
Bibliography
 (1) Nakamoto, S. Bitcoin: A peertopeer electronic cash system (2008). URL http://bitcoin.org/bitcoin.pdf.
 (2) Kleineberg, K.K. & Helbing, D., A ”Social Bitcoin” could sustain a democratic digital world. The European Physical Journal Special Topics, Volume 225, 2016, 32313241.
 (3) Dapp, Marcus M. & Klauser, S. & Ballandies, M., Finance 4.0 Concept (Technical Report). https://doi.org/10.3929/ethzb000286469 (2018).
 (4) Watanagase, T. et. al. Session 3: Financial Inclusion and Financial Education. In Financial System Stability, Regulation, and Financial Inclusion, 2015, 6994 (Springer).
 (5) Acemoglu, D., Ozdaglar, A. & TahbazSalehi, A. The network origins of large economic downturns. Tech. Rep., National Bureau of Economic Research (2013).
 (6) Huang, X., Vodenska, I., Havlin, S. & Stanley, H. E. Cascading failures in bipartite graphs: model for systemic risk propagation. Scientific reports 3, 1219 (2013).
 (7) Sakamoto, Y. & Vodenska, I. Systemic risk and structural changes in a bipartite bank network: a new perspective on the japanese banking crisis of the 1990s. Journal of Complex Networks 5, 315–333 (2017).
 (8) Glasserman, P. & Young, H. P. How likely is contagion in financial networks? Journal of Banking & Finance 50, 383–399 (2015).
 (9) Battiston, S. et al. Complexity theory and financial regulation. Science 351, 818–819 (2016).
 (10) Piškorec, M. et al. Cohesiveness in financial news and its relation to market volatility. Scientific reports 4, 5038 (2014).
 (11) Huang, X., Vodenska, I., Wang, F., Havlin, S. & Stanley, H. E. Identifying influential directors in the United States corporate governance network. Physical Review E 84, 046101 (2011).
 (12) Vodenska, I., Aoyama, H., Fujiwara, Y., Iyetomi, H. & Arai, Y. Interdependencies and causalities in coupled financial networks. PloS one 11, e0150994 (2016).
 (13) Yermack, D. Is bitcoin a real currency? an economic appraisal. In Handbook of Digital Currency, 31–43 (Elsevier, 2015).
 (14) Glaser, F., Zimmermann, K., Haferkorn, M., Weber, M. C. & Siering, M. Bitcoin  asset or currency? revealing users’ hidden intentions (april 15, 2014). ecis 2014 (tel aviv). Available at SSRN: https://ssrn.com/abstract=2425247 .
 (15) Garcia, D., Tessone, C. J., Mavrodiev, P. & Perony, N. The digital traces of bubbles: feedback cycles between socioeconomic signals in the bitcoin economy. Journal of The Royal Society Interface 11, 20140623–20140623 (2014).
 (16) Garcia, D. & Schweitzer, F. Social signals and algorithmic trading of bitcoin. Royal Society Open Science 2, 150288 (2015).
 (17) Amjad, M. & Shah, D. Trading bitcoin and online time series prediction. In NIPS 2016 Time Series Workshop, 1–15 (2017).
 (18) Wheatley, S., Sornette, D., Huber, T., Reppen, M. & Gantner, R. N. Are bitcoin bubbles predictable? combining a generalized metcalfe’s law and the lppls model (2018). arXiv:1803.05663.
 (19) Guo, T. & Bifet A. & AntulovFantulin, N. Bitcoin Volatility Forecasting with a Glimpse into Buy and Sell Orders (2018). In 2018 IEEE International Conference on Data Mining (ICDM), Singapore
 (20) Kim, Y. B. et al. Predicting fluctuations in cryptocurrency transactions based on user comments and replies. PLOS ONE 11, e0161197 (2016).
 (21) Kondor, D., Csabai, I., Szule, J., Posfai, M. & Vattay, G. Inferring the interplay between network structure and market effects in bitcoin. New Journal of Physics 16, 125003 (2014).
 (22) Kondor, D., Posfai, M., Csabai, I. & Vattay, G. Do the rich get richer? an empirical analysis of the bitcoin transaction network. PLOS ONE 9, 1–10 (2014).
 (23) ElBahrawy, A., Alessandretti, L., Kandler, A., PastorSatorras, R. & Baronchelli, A. Evolutionary dynamics of the cryptocurrency market. Royal Society Open Science 4, 170623 (2017).
 (24) Bolt, W. On the value of virtual currencies. SSRN Electronic Journal (2016). Available at SSRN: https://ssrn.com/abstract=2842557.
 (25) Hayes, A. Cryptocurrency value formation: An empirical analysis leading to a cost of production model for valuing bitcoin. SSRN Electronic Journal (2015). Available at SSRN: https://ssrn.com/abstract=2648366.
 (26) Kristoufek, L. What are the main drivers of the bitcoin price? evidence from wavelet coherence analysis. PLOS ONE 10, e0123923 (2015).
 (27) Donier, J. & Bouchaud, J.P. Why do markets crash? bitcoin data offers unprecedented insights. PLOS ONE 10, 1–11 (2015).
 (28) Ron, D. & Shamir, A. Quantitative analysis of the full bitcoin transaction graph. In Financial Cryptography and Data Security, 6–24 (Springer Berlin Heidelberg, 2013).
 (29) Möser, M. & Böhme, R. The price of anonymity: empirical evidence from a market for bitcoin anonymization. Journal of Cybersecurity 3, 127–135 (2017).
 (30) Garay, J., Kiayias, A. & Leonardos, N. The bitcoin backbone protocol: Analysis and applications. In Advances in Cryptology  EUROCRYPT 2015, 281–310 (Springer Berlin Heidelberg, 2015).
 (31) Eyal, I. & Sirer, E. G. Majority is not enough. Communications of the ACM 61, 95–102 (2018).
 (32) Ciaian, P., Rajcaniova, M. & d’Artis Kancs. The economics of bitcoin price formation (2014). arXiv:1405.4498.
 (33) Bouoiyour, J. & Selmi, R. The bitcoin price formation: Beyond the fundamental sources (2017). arXiv:1707.01284.
 (34) Kong, D., Ding, C. & Huang, H. Robust nonnegative matrix factorization using l21norm. In Proceedings of the 20th ACM International Conference on Information and Knowledge Management, CIKM ’11, 673–682 (ACM, New York, NY, USA, 2011).

(35)
Ding, C. H. Q., Zhou, D.,
He, X. & Zha, H.
R1pca: rotational invariant l1norm principal component analysis for robust subspace factorization.
In Cohen, W. W. & Moore, A. (eds.) ICML, vol. 148 of ACM International Conference Proceeding Series, 281–288 (ACM, 2006).  (36) Keshavan, R. H., Montanari, A. & Oh, S. Matrix completion from a few entries. IEEE Trans. Inf. Theor. 56, 2980–2998 (2010).
 (37) Meilijson, I. The garmanklass volatility estimator revisited. REVSTAT – Statistical Journal Volume 9, Number 3, November 2011, 199–212 .

(38)
Suykens, J. & Vandewalle, J.
Least squares support vector machine classifiers.
Neural Processing Letters 9, 293–300 (1999).  (39) Davis, J. & Goadrich, M. The relationship between precisionrecall and roc curves. In Proceedings of the 23rd International Conference on Machine Learning, ICML ’06, 233–240 (ACM, New York, NY, USA, 2006).

(40)
Hoyer, P.
Nonnegative sparse coding.
In Proceedings of the 12th IEEE Workshop on Neural Networks for Signal Processing, 2002, pp. 557565(IEEE).
Comments
There are no comments yet.