Open access peer-reviewed chapter

On Simulation of Various Effects in Consolidated Order Book

By Alexander Glekin, Alexander Lykov and Kirill Vaninsky

Submitted: April 30th 2018Reviewed: May 14th 2018Published: November 5th 2018

DOI: 10.5772/intechopen.78670

Downloaded: 817


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.


  • 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].


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


where paskis the smallest price to sell and s=5is 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):


where pbidis 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 Xiis aggregated volume of orders at level i. The component Xiis positive if these are buy orders and negative if these are sell orders. Note that:


We define instant liquidity to sell as:


And instant liquidity to buy as:


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.


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 ÎLlcan 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 ÎClon 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<ÎLlfor l<10as shown in Figure 4.

Figure 4.

The smoothed curves for ratesÎClandÎ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 distributionp̂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 distributionp̂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


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 ŝ100and d̂100defined above. The volume is measured for each second. The results are presented in Figure 9.

Figure 9.

The time dynamics of the aggregated volumesŝ100andd̂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.


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>0is called the rate.

Parameters for providers and takers of buyliquidity we denote with the lower subscript bidand parameters of takers and providers of sellliquidity are denoted with the subscript ask. The superscript specifies a type of order and stands for the following:

  • Llimit order,

  • Mmarket order, and

  • Ccancelation of an active limit order in the book.

Every group of market participants acts with the Poisson rate Isidetypewhere 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:



IbidLthe rate of submitting limit buy orders;

IaskLthe rate of submitting limit sell orders;

IaskMthe rate of submitting market buy orders;

IbidMthe rate of submitting market sell orders;

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

IbidCthe 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:


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


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 qLlis 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:


where SLstands for the average size of a limit order:


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:


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,


The rate of liquidity consumption is defined as:




The quantities sand ddetermine instant liquidity in the book. The infinitesimal rate of change of instant liquidity is given by:




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


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


Let us also define aggregated supply of sell orders:


and buy orders


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


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=0or 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:


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




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:




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=0all existent orders are canceled without exception and SL=SC. This implies that:


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:


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

When the market orders submission rate is small:


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 vMof a market order:


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:


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:


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


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

We define the parameter I=179events/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 sminand dminone can model price movements. We assume that the all other rates on the sell and buy side are equal:


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

Indeed, the dependence of δsellon the volume of sell market order vMis getting bigger as soon as dminis getting smaller. Similarly, dependence of δbuyon the volume of buy market order vMis getting bigger as soon as sminis getting smaller. As a very crude approximation we can take buy market order:


and for sell market order:




If smin<dmin, then:


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


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 sand d. The white and green lines are the graphs sminand dmin. Depending on the relation between sminand dminone 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=0holds. Figure 19 shows monotonous increase of the price. The first graph represent the price and the second two red and yellow lines are s5and d5.

Figure 19.

The upward trend.

Figure 20 also shows monotonous increase of the price but instead of s5and d5it has graphs of sand d.

Figure 20.

The upward trend.

© 2018 The Author(s). Licensee IntechOpen. This chapter is distributed under the terms of the Creative Commons Attribution 3.0 License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

How to cite and reference

Link to this chapter Copy to clipboard

Cite this chapter Copy to clipboard

Alexander Glekin, Alexander Lykov and Kirill Vaninsky (November 5th 2018). On Simulation of Various Effects in Consolidated Order Book, Trade and Global Market, Vito Bobek, IntechOpen, DOI: 10.5772/intechopen.78670. Available from:

chapter statistics

817total chapter downloads

More statistics for editors and authors

Login to your personal dashboard for more detailed statistics on your publications.

Access personal reporting

Related Content

This Book

Next chapter

Can Fundamental Analysis Provide Relevant Information for Understanding the Underlying Value of a Company?

By Raúl Navas, Ana Paula Matias Gama and Sónia R. Bentes

Related Book

International Trade from Economic and Policy Perspective

Edited by Vito Bobek

First chapter

A Survey of Effects of International Trade on Growth

By Maria Hamideh Ramjerdi

We are IntechOpen, the world's leading publisher of Open Access books. Built by scientists, for scientists. Our readership spans scientists, professors, researchers, librarians, and students, as well as business professionals. We share our knowledge and peer-reveiwed research papers with libraries, scientific and engineering societies, and also work with corporate R&D departments and government entities.

More About Us