The prediction of fluctuation in the order-driven financial market

Risk prediction is one of the important issues that draws much attention from academia and industry. And the fluctuation—absolute value of the change of price, is one of the indexes of risk. In this paper, we focus on the relationship between fluctuation and order volume. Based on the observation that the price would move when the volume of order changes, the prediction of price fluctuation can be converted into the prediction of order volume. Modelling the trader’s behaviours—order placement and order cancellation, we propose an order-based fluctuation prediction model. And our model outperforms better than baseline in OKCoin and BTC-e datasets.


Introduction
Risk prediction is one of the important issues that draws much attention from academia and industry. It is the key element for financial decision making and plays an increasing role in the financial market. The fluctuation-the absolute value of the change of price, which is one of the indexes of risk. In this paper, we focus on the fluctuation prediction.
In finance, the traditional methods applied to predict the market include fundamental analysis and technical analysis. Fundamental analysis involves assessing a firm's equity value based on the analysis of related economic and financial factors [1]. Fundamental researchers study everything that can affect the security's value, from microeconomic factors like the effectiveness of the company's management to macroeconomic factors such as the state of the economy and industry conditions. Unlike fundamental analysis, technical analysis is an analysis methodology for forecasting the direction of prices by analyzing statistical trends gathered from trading activities, such as price movements and volumes. It focuses on patterns of price movements, trading signals, and various other analytical charting tools to evaluate a security's strength or weakness.
Besides, the financial time series models expressed by financial theories have provided classic forecasting methods. For the stationary time series, Yule [2] proposed the autoregressive model(AR) which assumes that the current state is linear to the previous state. Similarly, Walker [3] proposed the moving average model(MA). The difference is that MA concerns the variance. The automatic regression moving average model(ARMA) is a mixed model combined with AR and MA, which combines the advantages of AR and MA. As for the non-stationary time series, the autoregressive conditional heteroscedasticity model(ARCH) adopted by Engle [4] is commonly used, which solves the problem brought by the hypothesis that the variance is constant. In ARCH, the unconditional variance of the model is a constant, but its conditional variance changes with time. Besides, there are many ways to improve [5][6][7], such as the generalized autoregressive conditional heteroscedasticity model(GARCH) [8], asymmetric power autoregressive conditional heteroscedasticity model(APGARCH) [9]. In recent years, with the development of artificial intelligence, many researchers have applied machine learning methods to the financial field [10-20], including genetic algorithm, convolutional neural network, and support vector machine. Hammad [21] found the artificial neural network has a strong predictive ability and high precision compared with econometric analysis methods. Besides, the researchers attempted to integrate artificial neural networks, moving average autoregressive models, maximum entropy models, particle swarm optimization algorithms, and genetic algorithms into a mixed model [22][23][24][25][26]. Hassan [27] combined the hidden Markov model, artificial neural networks, and genetic algorithms to predict the price of three stocks. Their results show that their methods have significantly improved over other models in accuracy.
However, these models ignore the relationship between order and price. There exist many studies that are concerned with this issue in theory [28][29][30][31][32][33][34][35][36]. Shi [37] found the change of price is inverse of the volume of best ask and best bid. Yura [38] found that the price change is a proportion of the change of order between ask orders and bid orders. All of these suggest that the order is key for the fluctuation prediction which can not be neglected. In this paper, we focus on the fluctuation prediction using order book data. We find that the volume of the order would change when the price has moved. Based on this observation, the prediction of price change can be converted into the prediction of order volume. Modelling the trader's behaviour-order placement and order cancellation, we conduct an order-based fluctuation prediction model. Our experimental results show that the proposed model outperforms other methods on OKCoin and BTC-e datasets.

Data
We collect order book data from the Bitcoin transaction platform. Compared with the stock market or futures market, it is easy to collect order book data from the Bitcoin market. We use the API provided by the Bitcoin platforms to collect order book data. It includes • OKCoin was the largest Bitcoin exchange platform in China which consisted of millions of users and billions of turnovers per day. We collected order book data at OKCoin from Nov. 3rd, 2016 to Jul. 28th, 2017.
• BTC-e is one of the largest Bitcoin trading platforms headquartered in Russia, whose data was collected from May 3rd, 2017 to Jul. 26th, 2017.
The data description is in Table 1.

Price fluctuation
The most widely accepted models state that the variation of share prices is a random process.
Investigating the time series of fluctuation on varying time scales |Δt| is useful in probing the underlying nature of the stochastic process. The fluctuation |ΔZ(t)| are defined as the difference between two successive price X(t).
The expected value of fluctuation E(|Δz(t)|) = ∑ d P(|Δz(t)| = d)d. Fig 1a shows the relationship between the expected value of fluctuation of price at time t − τ and the fluctuation at time t. In Fig 1a, we find that the expected value of fluctuation E(|Δz(t)|) increases as the fluctuation |Δz(t − τ)| increases, where it is approximately linear. It suggests that if the fluctuation at time t − τ is large, the expected fluctuation would be large next time. From this aspect, the fluctuation of price has a strong correlation. Moreover, we measure the autocorrelation of the series of price fluctuation. The autocorrelation is calculated as while h|Δz(t)|i, σ(|Δz(t)|) are the mean and the standard derivation of |Δz(t)|, respectively. In Fig 1b, we find there exists autocorrelation between the fluctuation of price when the time interval τ < 10min. Besides, the autocorrelation decreases as time interval τ increases. When the time interval τ = 1 min, the autocorrelation Cor(|Δz(t − τ)|, |Δz(t)|) � 0.5; and when τ = 10 min, the autocorrelation Cor(|Δz(t − τ)|, |Δz(t)|) � 0.2.

Experiment
In this section, we evaluate the effectiveness of our model in two dataset and compare our model with several state-of-the-art methods for fluctuation prediction. we divide the entire data into two parts. 80% of the data is used for in-sample training, which is used to determine the specifications of the model. And the other is considered as test data. For training, we use mean-square error to optimize our model. Evaluation. To test the prediction of our model, we use the mean-square error and coefficient of determination to evaluate.
• MSE(mean-square error): The mean-square error is the average squared difference between the estimated values and the actual value. It is defined as whileẑðtÞ; zðtÞ are estimated values and the actual value, respectively.
• R 2 (coefficient of determination): The coefficient of determination is the proportion of the variance in the dependent variable that is predictable from the independent variable(s). The coefficient of determination is defined as whileẑðtÞ; zðtÞ are estimated values and the actual value, respectively. And � z is the average of the actual value.
Baseline. We compare our model with several commonly used methods, which are briefly described below.
• ARMA: ARMA(Autoregressive moving average) is one of the common methods for financial time series, which is a mixture of autoregressive model and moving average model. In this paper, we use the change of price series as input data, and apply the ARMA method for fluctuation prediction. The autoregressive polynomial degree and moving average polynomial degree are set into 10.
• SVR: The SVR(support vector regression) method is widely used for the stock prediction in the previous work [39][40][41]. In this paper, we use the change of price series as input data and apply the SVR method for fluctuation prediction.
• ANN: ANN(Artificial Neural Network) is one of the commonly used machine learning methods. There is much previous work that has been reported to used ANN to predict stock price [42,43]. In this paper, we use the change of price series as input data and apply the ANN method for fluctuation prediction. The ANN model consists of three layers with 20 nodes. And two Relu are used in the first two layers.
• CNN: CNN(Convolutional Neural Network) is a class of deep neural networks, which is good at capturing the local features. Persio [44] used CNN to predict stock price. In this paper, we use the change of price series as input data and apply the CNN method for fluctuation prediction. The convolutional neural network consists of two convolutional layers. The parameters of these two convolutional layers are (kernel = 1×3, filters = 4, stride = 1, active function = ReLU) and (kernel = 1× 3, filters = 8, stride = 1, active function = ReLU). And two max-pooling layers are used after convolutional layers respectively. The bottom of the network is built by two fully connected layers.
Experiment result. Table 2 shows the experiment result in OKCoin dataset. The MSE material is 0.761, 0.780, 0.749, 0.783 for four baseline methods when time interval Δt = 10s. SVR performs the worst in MSE material. It is because the complexity of SVR is much higher than others when the train dataset is larger. Thus, the experiment result of SVR does not work well when the train time is limited. ANN and CNN perform better than SVR. And the performance of ARMA is the best in four baseline methods. However, the MSE metric in our model is 0.712. It is approximately 5% improvement compared with ARMA, which is the best method in the baseline. Similarly, our method outperforms when Δt = 20s, 40s, 80s. Table 3 shows the experiment results in the BTC-e dataset. And we find a similar experiment results in the BTCe dataset except the experiment result when τ = 80s. In summary, our method performs better than the baseline for MSE material.
As for R 2 , it is found that our method also outperforms all other baselines. When τ = 10s, the R 2 in our method is 0.219, while it is 0.174 for ARMA. The improvement is more than 25%, which is significant. It is near 10% improvement when τ = 80s.
On the other hand, we find that the experiment results on MSE increase as the time interval τ increase. Also, the experiment results on R 2 decrease when time interval τ increases. It is because that the variance increases when time interval τ increases.

Fluctuation prediction model
In this section, we will introduce our model, including the motivation, the framework of our model, the influence of order, the influence of the fluctuation at last moment and parameters update.

Basic definition
There are some basis terms which need to be introduced.
• Limit Order. Limit order definition: https://www.investopedia.com/terms/l/limitorder.asp. A limit order is a type of order to purchase or sell a security at a specified price or better. For buying limit orders, the order will be executed only at the limit price or a lower one, while for selling limit orders, the order will be executed only at the limit price or a higher one. Note: the order mentioned in this paper is the limit order.
asp. An order book is an electronic list of buying and selling orders for a specific security or financial instrument organized at a price level. An order book lists the number of shares being bid or offered at each price point.

PLOS ONE
The prediction of fluctuation in the order-driven financial market midprice z(t) is calculated as zðtÞ ¼ aðtÞþbðtÞ 2 . And the spread s(t) = a(t) − b(t), which represents the gap between best ask and best bid.
The blue orders and red orders represent bid order and ask order, respectively. And n a x ðtÞ and n b x ðtÞ represent the volume of ask order and bid order at time t, respectively. The relative position x ¼ d jz x À zðtÞj � z e is the distances from price z x to the midprice z(t), where z x is the price of order and � z is the price unit. Thus, the value n a x ðtÞ is the total volume of ask order from zðtÞ þ x � � z to zðtÞ þ ðx þ 1Þ � � z. The value n b x ðtÞ is the total volume of ask order from zðtÞ À x � � p to zðtÞ À ðx þ 1Þ � � z. Fig 4 shows the relationship between the fluctuation |Δz(t)| at t and the fluctuation |Δz(t − τ)| at t − τ. The red line is the expected value of prediction fluctuation |Δz(t)| without considering the the volume of order. And the blue line and black line are the expected value of prediction fluctuation when n 0 < 250 and n 0 > 800 (n 0 is the sum of order volume at best bid and best ask). The expected value of prediction fluctuation E(|Δz(t)|) is obviously different when the fluctuation at last moment |Δz(t − τ)| is the same. When n 0 < 250, the fluctuation prediction is bigger than that n 0 > 800. The redline is situated between the two. For example, when Δz(t − τ) = 3, the expected value of fluctuation at next time E(|Δz(t)|) = 1.3 for n 0 > 800 (C point) and E(|Δz(t)|) = 2.4 for n 0 < 250 (A point). It seems that the smaller the order volume n 0 is, the larger the fluctuation is. The fluctuation is related to the order volume n 0 .

Motivation
Moreover, we consider the prediction value and the fluctuation |Δz(t − τ)|. When the order information is given, the prediction value of fluctuation is Only considering the price information, the prediction value is Thus, this predition value f 1 is the average value of f 2 for different order volume. Obviously, the prediction value f 2 would be more precision when the order information is given. Thus, the order information is conducive to fluctuation prediction.
To summarize, the order information is important and helpful for fluctuation prediction.

Framework of model
In our model, the prediction of fluctuation aims to minimum the average squared difference between the prediction value and the actual value. Considering the order information, the loss function of fluctuation prediction L can be formation as: while |Δz 0 (t)| is the value that our model predicts. The history information H(t − τ) = {Δz(t − τ), n(t − τ)}, which represents the history data of order book and price. The value DMAX is the maximum value of price fluctuation, which is hyperparameters in our model. From Eq (7), it is significantly that the key for this problem is to calculate P(|Δz 0 (t)| = d|H(t − τ)). The value P(|Δz 0 (t)| = d|H(t − τ)) is the probability of the change of price, which can be converted to the probability of the change of order. From the price perspective, the price changes from zðt À tÞ ¼ aðtÀ tÞþbðtÀ tÞ 2 to zðtÞ ¼ aðtÞþbðtÞ 2 (Fig 3). And the best bid(ask) price changes from a(t)). From the order perspective, the order with the price z x 2 [b(t − τ), b(t)] disappear when the best bid change from b(t − τ) to b(t). Thus, the change in price is actually equivalent to the change in the order volume. Based on this observation, the prediction of fluctuation can be converted into the prediction of the order volume. The conditional probability P(|Δz 0 (t)| = d|H(t − τ)) is calculated as PðaðtÞ À aðt À tÞ ¼ i; bðtÞ À bðt À tÞ ¼ jjHðt À tÞÞ To simplify our model, we assume that the changes of order at different positions are independent. Thus, Thus, how to predict the volume of order at next time is key for the prediction of fluctuation.
Influence of orders. The change of an order volume is resulted from two operation: order placement and order cancellation.
• Order placement. The order placement at time t denotes as Dn OP i ðtÞ. The previous study shows that the order placement is related the order price.
• Order cancellation. The order cancelled at time t denotes as Dn OC i ðtÞ. We assume that every unit order is cancelled with the same probability q i . Based on this assumption, the process of cancellation is similar to the box picking problem: there are n i c ball in the box at time t − τ, while c is the minimum unit of order. And the balls are picked with the same probability q i independently. Therefore the probability PðDn OC i ðt À tÞ ¼ mjHðt À tÞÞ can be calculated as The approximation in Eq (10) is because lim n!1;p!0 C k n p k ð1 À pÞ nÀ k � ðnpÞ k k! e À np . When m = n i (t − τ), the conditional probability PðDn OC i ðt À tÞ ¼ mjHðt À tÞÞ � e À n i ðtÀ tÞ 1À q i c ð Þ .
Based on the analysis above, the probability P(n i (t) = 0|H(t − τ)) can be calculated as: Eq (11) show the relationship between the probability P(n i (t) = 0|H(t − τ)) and the order volume n i (t − τ). Thus, we set the formation of the probability P(n i (t) = 0|H(t − τ)) as To verify whether our model is correct, we calculate the conditional probability P(n(t) = 0| H(t − τ)) for different order volume n(t − τ) in Bitcoin transaction platform. We find the conditional probability P(n(t) = 0|H(t − τ)) decreases as the volume of order n(t − τ) increases in Fig 5. It is found that PðnðtÞ ¼ 0jHðt À tÞÞ ¼ w i ð1Þe w i ð2ÞnðtÀ tÞ þ w i ð3Þ fit the data well, which means that our model capture the relationship between P(n i (t) = 0|H(t − τ)) and n i (t − τ).
Influence of the fluctuation at last moment. In addition, we need to determine the the relationship between rate of cancellation q i and the fluctuation |Δz(t)|. Fig 5b shows the relationship between |Δn| and |Δz|. It is found that the change of order volume |Δn| increases as the fluctuation |Δz| increases, implying that q i is related to Δz(t). To simplify our model, we set q i � k|Δz(t)|. However, |Δz(t)| is unknown when we predict the fluctuation at time t − τ. So we replace |Δz(t)| with the average fluctuation before ∑ j |Δz(t − j)|. Thus, Eq (12) can be rewrite as Parameters update. In our model the parameters w i (1), w i (2), w i (3), w i (4), w i (5) are need to form the train data. Using the stochastic gradient descent method, the parameter w i (2)is But we find that the distribution of n i (t − τ) is fat-tail, which means that the maximum value of n i (t) is many times of the minimum value of n i (t). In the Bitcoin transaction platform, we find that the maximum value of n i (t) is more than 100 times the average value of n i (t). The extreme value of order volume would result in the parameter w i (2) fluctuate violently.

Discussion
In this paper, there are five fluctuation prediction methods. The baseline models are the endto-end models, which ignore the relationship between fluctuation and order. Comparing with the baseline models, we convert the prediction of price fluctuation into the prediction of order volume. Our model explicitly builds the relationship between the fluctuation and the order book. It uses more prior knowledge about order books and price. This may be the reason why our model performs better than the four baseline models.
High-frequency trading is the operation of seeking profits in the short-term market changes, which is usually carried out by computer programs. Dozens of orders can be placed in a second, and these orders will have an impact on the price. The study of the impact of order volume changes on short-term price, allows us to monitor high-frequency trading behaviour. However, the prediction of price direction is not within the scope of our study, because the price rise and fall direction of the actual market is not random distribution. The accuracy of predicting price trends (rise or fall) is out of this research scope. In the future, the prediction of price trends will be future work. Our method is not only suitable for the bitcoin market, but also for the order-driven market, for example the stock market which has a lot of high-frequency transactions.

Conclusion
In this paper, we focus on the fluctuation prediction. We find that the price would move when the volume of order changes. Based on this observation, the prediction of price fluctuation can be converted into the order volume prediction. Modeling the trader's behaviors-order placement and order cancellation, we conduct an order book based fluctuation prediction model. The developed model performs better on the OKCoin and BTC-e datasets. But there is a limitation on our model-the time lag that our model can predict is small. We try to solve this problem in the future work.