Open access peer-reviewed chapter

On Simulation of Various Effects in Consolidated Order Book

Written By

Alexander Glekin, Alexander Lykov and Kirill Vaninsky

Submitted: 30 April 2018 Reviewed: 14 May 2018 Published: 05 November 2018

DOI: 10.5772/intechopen.78670

From the Edited Volume

Trade and Global Market

Edited by Vito Bobek

Chapter metrics overview

1,074 Chapter Downloads

View Full Metrics

Abstract

This chapter is devoted to numerical computer simulation of the market mechanism, the consolidated order book (COB). The chapter consists of two parts. The first part is devoted to empirical analysis of consolidated order book (COB) for the index Russian trading system (RTS) futures. In the second part, we consider Poissonian multi-agent model of the COB. By varying parameters of different groups of agents submitting orders to the book, we are able to model various real-life phenomena. In particular, we model the spread, the profile of the book and large price changes. Two different mechanisms of large price changes are considered in detail. One such mechanism is due to a disbalance of liquidity in the COB, and another one is arising from the disbalance of sell and buy orders in the order flow.

Keywords

  • market mechanism
  • multi-agent model
  • price change

1. Introduction

Price changes and its causes have been a classical topic of economic research for a long-time. The answer to traditional question “why prices change” in the theory of effective market is that the market absorbs new information, which forces market participants to reconsider the price of securities, currencies, futures, and so on.

For a novice in the field, we say that the order matching mechanism of an exchange is called consolidated order book (COB) or simply the book. At the level of micro-structure an investigation of a price change became possible only after historical data about all orders and events in the book became publicly available. In this work, we do not consider the causes that determine the rate of submitting limit and market orders to the book by market participants. Instead, the main emphases are made on a study of various book statistics and a price changing mechanisms. In this work, we assume that all rates are constant in time, that is, we stay in the realm of “zero” intelligence traders [1].

It turns out that there are two basic mechanisms of the price change. In one case, it is a disbalance between demand through the flow of market orders and supply of limit orders in the book. Nevertheless, the simple rule is telling us what is happening if the demand exceeds supply and it does not necessarily lead to a price change. Another cause of the price change is a disbalance of liquidity in the order book. In reality two of these mechanisms contribute in a certain combination.

Our work consists of two parts. The first part is devoted to studying of empirical statistics of the book and the order flow for futures on the Russian trading system (RTS) index. Similar investigation was previously performed on stocks traded on French and USA equity exchanges [2, 3]. The Russian trading system (RTS) is a stock market established in 1995 in Moscow, consolidating various regional trading floors into one exchange. Originally RTS was modeled on NASDAQ’s trading and settlement framework. The RTS Index, RTSI, the official exchange indicator, was first calculated on September 1, 1995, and it is similar to the Dow Jones Index. Nowadays, the value of contracts traded in RTS Index futures and options exceeded tens of billion dollars. The number of open positions (open interest) exceeds 250,000 contracts. The excellent liquidity allows us to compute various statistics of the order book from historical data provided by RTS.

The second part of this work contains simulations performed with the use of Poissonian multi-agent model of the order book. For the first time, Poissonian models were considered by Farmer et al. in [4, 5, 6]. We formulate our model using multi-agent framework [7, 8]. We present results of numerical simulations, which are similar to real statistics of the RTS index futures. We have to mention that some of these simulations already appeared in [9]. The limiting case of the model corresponding to the book of fixed density one was rigorously considered by us in [10] and [11].

For the convenience of the reader, we start our presentation in Section 2 with a detailed description of the order book. Empirical statistics of the book for the RTS index futures are described in Section 3. Section 4 introduces our Poissonian model. Section 5, the final section of the paper, describes results of numerical simulations of the Poissonian model [12].

Advertisement

2. The order book

In this work, we consider an exchange with continuous double auction as the order matching mechanism. Market participants submit to the exchange orders of two types, namely limit orders and market orders.

The limit orders are specified by three parameters, the price level, the volume, and the direction (buy or sell). The price is the worst price at which the order can be executed. The volume of an order is a number of contracts, which constitute the order.

The consolidated order book is shown in Figure 1. The mid-column is a price ladder for a security. The step of a price change is five. Each limit order is placed in the order book at the level specified by its price. The minimal price of sell orders is called an ask price, and the maximal price of buy orders is called a bid price. The first column represents a price level counted from the best “ask” price. Namely, the price level for “buy” orders are counted from the best price offer (ask price) at the moment

lp=paskps,p<pask;E1

where pask is the smallest price to sell and s=5 is the size of the price ladder step. The second “bid” column represents a total volume of orders that can be bought at the specific price.

Figure 1.

Consolidated order book.

On the right from the middle column, the situation is identical but reversed. The last the fifth column is a price level counted from the best “ask.” Again, the price level for “sell” orders is counted from the best price offer (bid price):

lp=ppbids,p>pbid;E2

where pbid is the biggest price to buy. The fourth column is the total volume of orders at the specific price level.

Limit order stays in the book until they get executed or just canceled. Execution of orders in each queue is determined by the rule, that is, first-in,-first-out (FIFO).

The state of the book is given by a vector X=Xi, where Xi is aggregated volume of orders at level i. The component Xi is positive if these are buy orders and negative if these are sell orders. Note that:

i=prices,iask=pasks,ibid=pbids.E3

We define instant liquidity to sell as:

sl=i=iaskiask+lXi,s=s;E4

And instant liquidity to buy as:

dl=i=ibidibidlXi,d=d.E5

Market orders are the orders, which have no specific price and the only volume is specified. Such orders are executed at the best available price at the moment they are submitted. If, for example, in the book shown in Figure 1 submitted a market order to buy of the size 70, then the part of it (68 orders) is executed at the price 150,005, and the remaining two orders are executed at the price 150,010.

Advertisement

3. The empirical statistics of the RTS futures order book

3.1. The rate of submitting or canceling orders

The empirical rate of submitted limit orders ÎLl can be measured from historical data. We used the futures contract on index RTS and represented the rate of submitting limit orders in Figure 2 on the logarithmic scale. The vertical axis represents the number of contracts per second on both buy and sell side, and the horizontal axis represents the price level. Starting from level 10, the order submitting rate follows the power law ÎLllμ, l>10. For RTS futures μ2.5.

Figure 2.

The rate ÎLl.

Similarly, the empirical rate of canceling limit orders ÎCl on the logarithmic scale is presented in Figure 3. For level 10 and higher, the rate of canceling orders follows the power law ÎCllμ with μ2.5.

Figure 3.

The rate ÎCl.

Moreover, ÎCl=ÎLl, for l>10. At the same time, ÎCl<ÎLl for l<10 as shown in Figure 4.

Figure 4.

The smoothed curves for rates ÎCl and ÎLl.

3.2. The order volume

The empirical distribution of market orders volumes p̂Mν is shown in Figure 5. The empirical frequency is depicted on the vertical axis and the volume on the horizontal axis. This distribution can be approximated by the power law p̂Mννγ,γ2.5.

Figure 5.

The empirical distribution p̂Mν of volume of market orders.

The distribution of limit order volume p̂Lν is more complicated and given in Figure 6. The volume of orders has a tendency to be multiple of 10. If one excludes orders with the volume multiple of 10 then p̂Lννγ,γ2.8. For orders multiple of 10, the distribution is the same with γ2.5. For orders multiple of 100, the law is also the same but γ2.0.

Figure 6.

The empirical distribution p̂Lν of volume of limit orders.

3.3. The book profile

The book profile was determined by averaging the volume at particular level counted from the mid price

m=iask+ibid2.E6

The averaged book profile for the first 20 levels is given in Figure 7. The averaged book profile for the first 1000 levels is given in Figure 8.

Figure 7.

The book for the first 20 levels.

Figure 8.

The book for the first 1000 levels.

One can look at the time dynamics of the total order volume at first 100 levels on the sell and buy side. These are exactly the quantities ŝ100 and d̂100 defined above. The volume is measured for each second. The results are presented in Figure 9.

Figure 9.

The time dynamics of the aggregated volumes ŝ100 and d̂100.

3.4. The time between orders

The empirical distribution of time between market orders can measured (in seconds) and is given in Figure 10.

Figure 10.

The empirical distribution of time between market orders.

The empirical distribution of time between limit orders can also be measured (in seconds) and is presented in Figure 11.

Figure 11.

The empirical distribution of time between limit orders.

Advertisement

4. The Poissonian multi: agent model

4.1. Market participants

In accordance with a mechanism of the double auction, there are six types of events that can occur in the order book:

  • Liquidity provider submits buy limit order.

  • Liquidity provider submits sell limit order.

  • Liquidity taker submits market buy order.

  • Liquidity taker submits market sell order.

  • Liquidity taker cancels buy limit order.

  • Liquidity taker cancels sell limit order.

These events can be produced by six agents or market participants. One group is agents providing liquidity to the book, and another group is agents taking liquidity from the book.

One group is liquidity providers, which differ from each other by a direction of limit orders. Providers of sell liquidity submit sell limit orders to the book and providers of buy liquidity submit buy limit orders to the book.

Another group is liquidity takers. Liquidity takers submit market orders to the book and also differ from each other by a direction. For example, liquidity takers of buy orders send market sell orders to the book. Similarly, liquidity takers of sell orders send buy market orders. Another type of liquidity takers cancel active buy or sell limit orders.

Everywhere below we assume that the events in our model form a Poissonian flow. Namely, the time τ between two consecutive events is exponentially distributed with the distribution Probτt=expIt, where the parameter I>0 is called the rate.

Parameters for providers and takers of buy liquidity we denote with the lower subscript bid and parameters of takers and providers of sell liquidity are denoted with the subscript ask. The superscript specifies a type of order and stands for the following:

  • L limit order,

  • M market order, and

  • C cancelation of an active limit order in the book.

Every group of market participants acts with the Poisson rate Isidetype where the subscript stands for the direction and the superscript for the type of action. The total rate of all events in the exchange is defined by the formula:

I=IaskL+IbidL+IaskC+IbidC+IaskM+IbidM;E7

where.

IbidL the rate of submitting limit buy orders;

IaskL the rate of submitting limit sell orders;

IaskM the rate of submitting market buy orders;

IbidM the rate of submitting market sell orders;

IaskC the rate of submitting cancelation request for limit sell orders; and.

IbidC the rate of submitting cancelation request for limit buy orders.

On each step of simulation, only one of these six events occurs. The time between two consecutive events is exponentially distributed with the rate I. The probability of an event of specific type is given by the formula:

IsidetypeI.E8

For example, the probability of cancelation of some buy limit (bid) order is:

IbidCI.E9

4.2. Liquidity providers

Liquidity providers submit limit orders buy or sell of volume ν at some price level l. Price level also takes integer values 1,2,,K; with the probability qLl. We also assume that maximal price level K=1000. The distribution function qLl is determined by the empirical rate ÎLl. The volume ν of an order takes integer values 1,2,,VL; with probability pLν. We assume that maximal volume VL=1000. The distribution pLν is modeled upon the empirical distribution p̂Lν. The distribution functions for the volume and the price level are the same for providers of sell and buy orders.

The limit orders can be executed partially, meaning that if they are bigger than the size of a market order then just some part of them is executed.

The infinitesimal rate of submitting liquidity, that is, limit orders to the book are:

Vin=SLIaskL+IbidL,E10

where SL stands for the average size of a limit order:

SL=ν=1VLνpLν.E11

4.3. Liquidity takers

Liquidity takers submit either market orders or just cancel existent limit orders in the book. Market orders have a random volume ν, which takes values 1,2,,VM; with probability pMν, which is modeled upon the empirical distribution p̂Mν. The maximal volume VM=100.

4.4. Conditions of equilibrium

Cancelation of limit orders happens with an equal probability for all active limit orders buy or sell. Let us define:

SC=ν=1VLνpCν,E12

where pCν is the probability of canceling limit order of volume ν. Active limit orders in the book are subjected to the flow of market orders. Market orders can take limit orders completely or just make the size of limit orders smaller than when they were actually submitted. Therefore,

SC<SL.E13

The rate of liquidity consumption is defined as:

Vout=SMIaskM+IbidM+SCIaskC+IbidC,E14

where

SM=ν=1VMνpMν.E15

The quantities s and d determine instant liquidity in the book. The infinitesimal rate of change of instant liquidity is given by:

Δs=IaskLSLIaskMSMIaskCSC,E16

and

Δd=IbidLSLIbidMSMIbidCSC.E17

Obviously in the stationary regime Δs=Δd=0 and the following identities hold:

SLIaskL=SMIaskM+SCIaskC,E18
SLIbidL=SMIbidM+SCIbidC.E19

These imply Vin=Vout. When market orders are not present IbidM=IaskM=0, we have:

SLIaskL=SCIaskC,E20
SLIbidL=SCIbidC.E21

Let us also define aggregated supply of sell orders:

S=IaskLSL+IbidMSMIaskCSC,E22

and buy orders

D=IbidLSL+IaskMSMIbidCSC.E23

We are going to study price dynamics in terms s,d,S,D.

Advertisement

5. Results of simulation

We would like to note that sometime during simulation there are no limit orders in the book on sell or buy side. In other words, due to randomness liquidity in the book can drop to zero, meaning s=0 or d=0. In such case when market order arrives, it will be no limit orders in the book to match market order. In order to avoid this we impose the following conditions:

s>smin,d>dmin,E24

where smin>VM and dmin>VM. Once any of these conditions have been violated we need to stop the flow of market orders and also stop cancelations:

IbidM=IbidC=0,ifd<dmin,E25

or

IaskM=IaskC=0,ifs<smin.E26

Another problem in running simulations is an unlimited growth of a number of limit orders in the book; in other words, instant liquidity cannot grow indefinitely. We arrange parameters (the rates Isidetype) such that aggregated rate of liquidity supply is less than aggregated rate of liquidity consumption. This implies that the rates have to be such that the following conditions hold:

Δd<0,ford>dmin,E27

and

Δs<0,fors>smin.E28

5.1. The profile of the book and the spread

Let us define profile of the book as the state of all queues at a particular moment of time. Average profile is computed by averaging instantaneous profiles for each second on a particular time interval.

The response of the book profile to the flow of market orders can be easily understood. When the market orders are absent IbidM=0, and IaskM=0 all existent orders are canceled without exception and SL=SC. This implies that:

IaskL=IaskC,IbidL=IbidC.E29

Since in our model the size of limit order is independent from the price and direction of the trade then the book is filled uniformly with the limit orders as it is shown in Figure 12.

Figure 12.

The book profile without market orders.

Consider now the spread:

δ=paskpbids=iaskibid,E30

and let us study how it depends on the size of a market order.

When the market orders submission rate is small:

IaskMI<0.01,IbidMI<0.01,E31

then the book profile remains unchanged as shown in Figure 13.

Figure 13.

The book profile with small rate of market orders.

The spread (after the market order has been executed) depends linearly on the size vM of a market order:

δvM.E32

The empirical relation between the size and a spread is depicted in Figure 14. The size of limit order is depicted on the vertical axis, and the spread is shown on the horizontal axis.

Figure 14.

The size of market orders as the function of spread.

When the rate of market orders increases:

IaskMI0.1,IbidMI0.1,E33

then the book profile changes. On the levels closest to the bid or ask the size of the book is almost linearly depends on a level number as shown in Figure 15:

Xibidll,Xiask+ll,E34

where l>0. When market order arrives, it annihilates limit orders at the level proportional to the square root of the volume vM and:

δvM.E35

5.2. The balance of liquidity in the book and in the order flow

We define the parameter I=179 events/s. All other parameters in the balanced case are given in the table (Figure 16).

Figure 15.

The book profile with the high rate of market orders.

Figure 16.

Parameters in the balanced case.

A sample of the price evolution in our model is given in Figure 17.

Figure 17.

Price in the balanced case.

Apparently the price does not exhibit any preferred direction. We refer to [9] for details of this simulation.

5.3. The disbalance of liquidity in the book

By adjusting smin and dmin one can model price movements. We assume that the all other rates on the sell and buy side are equal:

IbidM=IaskM,IbidC=IaskC,IbidL=IaskL.E36

If smin>dmin then the book is thinner on the buy side (below the price) and this leads to price decrease. If on the opposite smin<dmin then the book is thinner on the sell side (above the price) and this leads to price increase.

Indeed, the dependence of δsell on the volume of sell market order vM is getting bigger as soon as dmin is getting smaller. Similarly, dependence of δbuy on the volume of buy market order vM is getting bigger as soon as smin is getting smaller. As a very crude approximation we can take buy market order:

vMδselldmin,E37

and for sell market order:

vMδbuysmin.E38

Therefore,

δsellδbuysmindmin.E39

If smin<dmin, then:

δsellδbuy<1E40

and the price has to increase. If smin>dmin, then:

δsellδbuy>1E41

and the price has to decrease.

This is illustrated in Figure 18. The first graph is a price and the second graph, which is the vertical column is the volume. The third graph is the graph for instantaneous liquidity s and d. The white and green lines are the graphs smin and dmin. Depending on the relation between smin and dmin one can observe increase or decrease of the price.

Figure 18.

Thinning of the book on the buy or sell side.

5.4. The disbalance of sell and buy orders in the order flow

Such disbalance occurs when IbidMIaskM. At the same time the condition Δs=Δd=0 holds. Figure 19 shows monotonous increase of the price. The first graph represent the price and the second two red and yellow lines are s5 and d5.

Figure 19.

The upward trend.

Figure 20 also shows monotonous increase of the price but instead of s5 and d5 it has graphs of s and d.

Figure 20.

The upward trend.

References

  1. 1. Gode DK, Sunder S. Allocative efficiency of markets with zero-intelligence traders: Market as a partial substitute for individual rationality. The Journal of Political Economy. 1993;101(1):119-137
  2. 2. Biais B, Hillion P, Spatt C. An empirical analysis of the limit order book and the order flow in the Paris Bourse. Journal of Finance. 1995;5:1655-1689
  3. 3. Bouchaud J-P, Mezard M, Potters M. Statistical properties of the stock order books: Empirical results and models. Quantitative Finance. 2002;2(4):251-256
  4. 4. Smith E, Farmer JD, Gillemot L, Krishnamurthy S. Statistical theory of the continuous double auction. Quantitative Finance. 2003;3(6):481-514
  5. 5. Daniels M, Farmer JD, Gillemot L, Iori G, Smith E. A quantitative model of trading and price formation in financial markets. Physical Review Letters. 2003;90:108102
  6. 6. Mike S, Farmer JD. An empirical behavioral model of price formation. Journal of Economic Dynamics and Control. 2008;32:200
  7. 7. Chakraborti A, Toke IM, Patriarca M, Abergel F. Econophysics review II. Agent based models. Quantitative Finance. 2011;11(7):1013-1041
  8. 8. Samanidou E, Zschischang E, Stauffer D, Lux T. Agent based models of financial markets. Reports on Progress in Physics. 2007;70:409-450
  9. 9. Glekin AO. Stochastic multi-agent model for the order book dynamics. The Program Products and Systems. 2013;3:283-288
  10. 10. Muzychka S, Lykov A, Vaninsky K. An investor’s sentiment in multi-agent model of the continuous double auction. International Journal of Theoretical and Applied Finance. 2015;68(5):865-888
  11. 11. Muzychka S, Vaninsky K. A class of nonlinear random walks related to the Ornstein-Uhlenbeck process. Markov Processes and Related Fields. 2012;17(2):277-304. arXiv:1107.0850
  12. 12. Chakraborti A, Toke IM, Patriarca M, Abergel F. Econophysics review I. Empirical facts. Quantitative Finance. 2011;11(7):991-1012

Written By

Alexander Glekin, Alexander Lykov and Kirill Vaninsky

Submitted: 30 April 2018 Reviewed: 14 May 2018 Published: 05 November 2018