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
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 .
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 . The limiting case of the model corresponding to the book of fixed density one was rigorously considered by us in  and .
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 .
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 is the smallest price to sell and 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.
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 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 , where is aggregated volume of orders at level . The component is 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 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 , . For RTS futures .
Similarly, the empirical rate of canceling limit orders on the logarithmic scale is presented in Figure 3. For level 10 and higher, the rate of canceling orders follows the power law with .
Moreover, , for . At the same time, for as shown in Figure 4.
3.2. The order volume
The empirical distribution of market orders volumes 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 .
The distribution of limit order volume 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 . For orders multiple of 10, the distribution is the same with . For orders multiple of 100, the law is also the same but .
3.3. The book profile
The book profile was determined by averaging the volume at particular level counted from the mid price
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 and defined above. The volume is measured for each second. The results are presented in Figure 9.
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 where the parameter is called the rate.
Parameters for providers and takers of liquidity we denote with the lower subscript and parameters of takers and providers of liquidity are denoted with the subscript . The superscript specifies a type of order and stands for the following:
market order, and
cancelation of an active limit order in the book.
Every group of market participants acts with the Poisson rate 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:
the rate of submitting limit buy orders;
the rate of submitting limit sell orders;
the rate of submitting market buy orders;
the rate of submitting market sell orders;
the rate of submitting cancelation request for limit sell orders; and.
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 . 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 . Price level also takes integer values with the probability We also assume that maximal price level . The distribution function is determined by the empirical rate . The volume of an order takes integer values with probability We assume that maximal volume The distribution is modeled upon the empirical distribution . 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 stands 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 with probability , which is modeled upon the empirical distribution . The maximal volume .
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 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 and determine instant liquidity in the book. The infinitesimal rate of change of instant liquidity is given by:
Obviously in the stationary regime and the following identities hold:
These imply . When market orders are not present we have:
Let us also define aggregated supply of sell orders:
and buy orders
We are going to study price dynamics in terms .
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 or . 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 and . 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 ) 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 , and all existent orders are canceled without exception and . 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.
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.
The spread (after the market order has been executed) depends linearly on the size of 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.
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 . When market order arrives, it annihilates limit orders at the level proportional to the square root of the volume and:
5.2. The balance of liquidity in the book and in the order flow
We define the parameter events/s. All other parameters in the balanced case are given in the table (Figure 16).
A sample of the price evolution in our model is given in Figure 17.
Apparently the price does not exhibit any preferred direction. We refer to  for details of this simulation.
5.3. The disbalance of liquidity in the book
By adjusting and one can model price movements. We assume that the all other rates on the sell and buy side are equal:
If then the book is thinner on the buy side (below the price) and this leads to price decrease. If on the opposite then the book is thinner on the sell side (above the price) and this leads to price increase.
Indeed, the dependence of on the volume of sell market order is getting bigger as soon as is getting smaller. Similarly, dependence of on the volume of buy market order is getting bigger as soon as is getting smaller. As a very crude approximation we can take buy market order:
and for sell market order:
If , then:
and the price has to increase. If , 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 and . The white and green lines are the graphs and . Depending on the relation between and one can observe increase or decrease of the price.
5.4. The disbalance of sell and buy orders in the order flow
Such disbalance occurs when At the same time the condition holds. Figure 19 shows monotonous increase of the price. The first graph represent the price and the second two red and yellow lines are and .
Figure 20 also shows monotonous increase of the price but instead of and it has graphs of and .