You are on page 1of 72

A stochastic model for order book dynamics

Sasha Stoikov (with Rama Cont and Rishi Talreja)


Cornell University

October 21, 2008

Motivation
Two major types of market mechanisms: 1 Quote driven (e.g. NYSE specialist) 2 Order driven (e.g. Arca, Instinet, Tokyo stock exchange)

Motivation
Two major types of market mechanisms: 1 Quote driven (e.g. NYSE specialist) 2 Order driven (e.g. Arca, Instinet, Tokyo stock exchange) Two approaches to order driven markets: 1 Markets are made up of many rational individuals acting in their own best interest (e.g. Parlour (1998), Foucault et al. (2005), Rosu (2008)) 2 The collective behavior of these rational people can be reproduced by modeling non strategic traders (e.g. Bouchaud et al. (2002), Farmer et al. (2004))

Motivation
Two major types of market mechanisms: 1 Quote driven (e.g. NYSE specialist) 2 Order driven (e.g. Arca, Instinet, Tokyo stock exchange) Two approaches to order driven markets: 1 Markets are made up of many rational individuals acting in their own best interest (e.g. Parlour (1998), Foucault et al. (2005), Rosu (2008)) 2 The collective behavior of these rational people can be reproduced by modeling non strategic traders (e.g. Bouchaud et al. (2002), Farmer et al. (2004)) The above approaches focus on equilibrium properties

Motivation
Two major types of market mechanisms: 1 Quote driven (e.g. NYSE specialist) 2 Order driven (e.g. Arca, Instinet, Tokyo stock exchange) Two approaches to order driven markets: 1 Markets are made up of many rational individuals acting in their own best interest (e.g. Parlour (1998), Foucault et al. (2005), Rosu (2008)) 2 The collective behavior of these rational people can be reproduced by modeling non strategic traders (e.g. Bouchaud et al. (2002), Farmer et al. (2004)) The above approaches focus on equilibrium properties These models seem challenging to estimate

Model objectives

To predict short term price behavior 1 Given the current order book 2 Given statistics on the order ow

Model objectives

To predict short term price behavior 1 Given the current order book 2 Given statistics on the order ow To test strategies that impact the price dynamics 1 Strategies for liquidity providers 2 Block order execution 3 Size eects

Model objectives

To predict short term price behavior 1 Given the current order book 2 Given statistics on the order ow To test strategies that impact the price dynamics 1 Strategies for liquidity providers 2 Block order execution 3 Size eects We should focus on computing conditional probabilities

Model objectives

To predict short term price behavior 1 Given the current order book 2 Given statistics on the order ow To test strategies that impact the price dynamics 1 Strategies for liquidity providers 2 Block order execution 3 Size eects We should focus on computing conditional probabilities Our model should be easy to estimate

Outline
1

The order book


What is an order book? Modeling the order book

Outline
1

The order book


What is an order book? Modeling the order book

Estimation
The rates of market orders, limit orders and cancellations Comparing data to simulation

Outline
1

The order book


What is an order book? Modeling the order book

Estimation
The rates of market orders, limit orders and cancellations Comparing data to simulation

Conditional probabilities
Laplace transforms methods Birth death processes

Outline
1

The order book


What is an order book? Modeling the order book

Estimation
The rates of market orders, limit orders and cancellations Comparing data to simulation

Conditional probabilities

Laplace transforms methods Birth death processes Probability of the price going up Probability of executing a limit order before the price moves Probability of making the spread

Outline
1

The order book


What is an order book? Modeling the order book

Estimation
The rates of market orders, limit orders and cancellations Comparing data to simulation

Conditional probabilities

Laplace transforms methods Birth death processes Probability of the price going up Probability of executing a limit order before the price moves Probability of making the spread

Conclusion

A market order

A limit order

A limit order

A cancellation

Notation
Continuous-time Markov chain Xt (Xt1 , . . . , Xtn ), where |Xti |

is the number of limit orders in the book at price i

Notation
Continuous-time Markov chain Xt (Xt1 , . . . , Xtn ), where |Xti |

is the number of limit orders in the book at price i


If Xti < 0 then there are Xti bid orders at price i ; if Xti > 0

then there are Xti ask orders at price i .

Notation
Continuous-time Markov chain Xt (Xt1 , . . . , Xtn ), where |Xti |

is the number of limit orders in the book at price i


If Xti < 0 then there are Xti bid orders at price i ; if Xti > 0

then there are Xti ask orders at price i . pA (t) = inf{i , Xti > 0},

The best ask process

t 0.

The best bid process pB (t) = sup{i , Xti < 0}, t 0.

Assumptions

Market buy (resp. sell) orders arrive at independent,

exponential times with rate ,


Limit buy (resp. sell) orders arrive at a distance of i ticks

from the opposite best quote at independent, exponential times with rate (i ),
Cancellations of limit orders at a distance of i ticks from the

opposite best quote occur at a rate proportional to the number of outstanding orders: if the number of outstanding orders at that level is x then the cancellation rate is (i )x.
The above events are mutually independent.

The transition rates


Let x i 1 x (0, . . . , 1, . . . , 0), where the 1 in the vector on the right-hand side is in the i th component. x x x x x x x i 1 x i +1 x pB (t)+1 x pA (t)1 x i +1 x i 1 with with with with with with rate rate rate rate rate rate (pA (t) i ) (i pB (t)) (pA (t) i )|x i | (i pB (t))|x i | for for i < pA (t), i > pB (t),

for for

i < pA (t), i > pA (t),

Ergodic property

Proposition
X is an ergodic Markov process. In particular, X has a proper stationary distribution. We may compute time averages of various quantities in a simulation
average shape of the order book volatility

and interpret them as expectations in the model.

The market order rate

Number of seconds in 125 days of data

T = 125 4.5 60 60 = 2, 025, 000s


Number of market orders in our data N = 64, 777 Average size of market orders S = 8.84 Average size of limit orders S = 14.27

The market order rate

Number of seconds in 125 days of data

T = 125 4.5 60 60 = 2, 025, 000s


Number of market orders in our data N = 64, 777 Average size of market orders S = 8.84 Average size of limit orders S = 14.27 The market order rate

= orders per second

N S = 0.0198 T S

The limit order rate function


Number of limit orders at distances 1-5 from the best

opposite quote in our data N = [71, 884 50, 851 36, 825

29, 567

25, 831]

The limit order rate function


Number of limit orders at distances 1-5 from the best

opposite quote in our data N = [71, 884 50, 851 36, 825 29, 567 Limit order rate function for 1 d 5: N (d) (d) = T orders per second.

25, 831]

The limit order rate function


Number of limit orders at distances 1-5 from the best

opposite quote in our data N = [71, 884 50, 851 36, 825 29, 567 Limit order rate function for 1 d 5: N (d) (d) = T

25, 831]

orders per second. For d > 5 extrapolate with a power law function of the form k (d) = d k and are obtained by minimizing the least square distance
5

min
k, d=1

k (d) d

The limit order rate function


0.04 Data Simulation 0.035

0.03

Limit order arrival rate

0.025

0.02

0.015

0.01

0.005

4 5 6 7 8 9 Distance from opposite best quote in ticks

10

The cancel rate function


Number of cancellations in our data (distances 1-5 from the

best opposite quote) N = [23, 829 37, 698

32, 370

27, 264

23, 218]

The cancel rate function


Number of cancellations in our data (distances 1-5 from the

best opposite quote) N = [23, 829 37, 698

32, 370

27, 264

23, 218]

Average cancellation size S = 18.61 Average number of orders at a distance of d from best quote

Q(d).

The cancel rate function


Number of cancellations in our data (distances 1-5 from the

best opposite quote) N = [23, 829 37, 698

32, 370

27, 264

23, 218]

Average cancellation size S = 18.61 Average number of orders at a distance of d from best quote

Q(d).
Cancel rate function for 1 d 5:

N (d) S (d) = TQ(d) S For d > 5, we let (d) = (5).

The cancel rate function


0.014 Data Simulation 0.012

0.01 Cancelation rate per order

0.008

0.006

0.004

0.002

4 5 6 7 8 9 Distance from opposite best quote in ticks

10

Comparing movies

Order book simulation for Sky Perfect Communications.

Comparing Sample paths


7.8 7.7 Last traded price 7.6 7.5 7.4 7.3 7.2 7.1 x 10
4

Empirical

100

200

300

400 500 Number of trades

600

700

800

7.8 7.7 Last traded price 7.6 7.5 7.4 7.3 7.2 7.1

x 10

Simulation

100

200

300

400 500 Number of trades

600

700

800

Comparing average order book shape

Empirical Simulation

Average number of orders

1.5

0.5

2 3 4 Distance from opposite best quote in ticks

Comparing one step ahead predictions


In our model, we may compute the probability of a queue

going up, when there are m orders in the queue, for 1 d 5, conditional on the best quotes not changing.
d pup (m) =

(d) (d)m + (d) + (d) (d)m + (d)

for d = 1
d pup (m) =

for d > 1

Comparing one step ahead predictions


In our model, we may compute the probability of a queue

going up, when there are m orders in the queue, for 1 d 5, conditional on the best quotes not changing.
d pup (m) =

(d) (d)m + (d) + (d) (d)m + (d)

for d = 1
d pup (m) =

for d > 1
We can compare these probabilities to the empirical

probabilities of these queues going up

Comparing one step ahead predictions


1 tick from opposite quote Probability of increase 1 Empirical Model 0.5 Probability of increase 1 Empirical Model 0.5 2 ticks from opposite quote

3 4 Queue size

3 4 Queue size

3 ticks from opposite quote Probability of increase 1 Empirical Model 0.5 Probability of increase 1

4 ticks from opposite quote Empirical Model 0.5

3 4 Queue size

3 4 Queue size

5 ticks from opposite quote Probability of increase 1 Empirical Model 0.5

3 4 Queue size

Conditional probabilities of interest

The probability that the midprice goes up before it goes down

(spread=1)

Conditional probabilities of interest

The probability that the midprice goes up before it goes down

(spread=1)
The probability that the midprice goes up before it goes down

(spread>1)

Conditional probabilities of interest

The probability that the midprice goes up before it goes down

(spread=1)
The probability that the midprice goes up before it goes down

(spread>1)
The probability that an order at the bid executes before the

ask queue disappears (spread=1)

Conditional probabilities of interest

The probability that the midprice goes up before it goes down

(spread=1)
The probability that the midprice goes up before it goes down

(spread>1)
The probability that an order at the bid executes before the

ask queue disappears (spread=1)


The probability that both a buy and a sell limit order execute

before the best quotes move (spread=1)

Laplace transforms
The two-sided Laplace transform

f (s) = E [e sT ] =

e st f (t)dt

where f (t) is the pdf of a random variable T

Laplace transforms
The two-sided Laplace transform

f (s) = E [e sT ] =

e st f (t)dt

where f (t) is the pdf of a random variable T


The inverse

f (t) =

1 2i

+i i

e ts f (s)ds

Laplace transforms
The two-sided Laplace transform

f (s) = E [e sT ] =

e st f (t)dt

where f (t) is the pdf of a random variable T


The inverse

f (t) =

1 2i

+i i

e ts f (s)ds

We may compute the Laplace transform of many random

variables of interest in our model

Laplace transforms
The two-sided Laplace transform

f (s) = E [e sT ] =

e st f (t)dt

where f (t) is the pdf of a random variable T


The inverse

f (t) =

1 2i

+i i

e ts f (s)ds

We may compute the Laplace transform of many random

variables of interest in our model


Numerically computing the inverse is fast!

A birth death process


For each price level, the number of orders is a birth death

process with birth rate and death rate k = + k.

A birth death process


For each price level, the number of orders is a birth death

process with birth rate and death rate k = + k.

T i ,i 1 - rst time that the BD process goes from i to i 1

A birth death process


For each price level, the number of orders is a birth death

process with birth rate and death rate k = + k.

T i ,i 1 - rst time that the BD process goes from i to i 1 The Laplace transform of the rst passage time
i ,i 1 fi ,i 1(s) = E [e sT ]

A birth death process


For each price level, the number of orders is a birth death

process with birth rate and death rate k = + k.

T i ,i 1 - rst time that the BD process goes from i to i 1 The Laplace transform of the rst passage time
i ,i 1 fi ,i 1(s) = E [e sT ]

A recurrence relation for f fi ,i 1 (s) = i + fi +1,i (s)fi ,i 1 (s) i + + s i + + s

First passage time of a birth death process


The recurrence relation allows us to express the Laplace

transform of the rst passage time as a continued fraction 1 k fi ,i 1(s) = k=i + k + s

First passage time of a birth death process


The recurrence relation allows us to express the Laplace

transform of the rst passage time as a continued fraction 1 k fi ,i 1(s) = k=i + k + s


Continued fractions:

k=1 where

ak lim wn n bk n 1,

wn = t1 t2 tn (0), and tk (u) = ak , bk + u

k 1.

First passage time of a birth death process


The recurrence relation allows us to express the Laplace

transform of the rst passage time as a continued fraction 1 k fi ,i 1(s) = k=i + k + s


Continued fractions:

k=1 where

ak lim wn n bk n 1,

wn = t1 t2 tn (0), and tk (u) =


Abate and Whitt (1999)

ak , bk + u

k 1.

First passage time of a birth death process


Let b denote the rst-passage time to 0 of a BD process

starting at b

First passage time of a birth death process


Let b denote the rst-passage time to 0 of a BD process

starting at b

b = b,b1 + b1,b2 + + 1,0 where i ,i 1 denotes the rst-passage time of the birth-death process from the state i to the state i 1

First passage time of a birth death process


Let b denote the rst-passage time to 0 of a BD process

starting at b

b = b,b1 + b1,b2 + + 1,0 where i ,i 1 denotes the rst-passage time of the birth-death process from the state i to the state i 1
The Laplace transform of b

fb (s) =

b=1 i k=i

k + k + s

Probability of the mid price moving up: spread=1


b is the random time when a bid queue with b orders disappears. a is the random time when an ask queue with a orders disappears.

Theorem
Pa,b P[a < b ] is given by the inverse Laplace transform of 1 Fa,b (s) = fb (s)fa (s), s evaluated at t = 0, where fb (s) = 1
b

b=1 i k=i

( + k) + ( + k) + s

Probability of the mid price moving up: spread>1


Theorem
For S(0) = pA (0) pB (0) > 1, the quantity
P[A B < B A ]

is given by the inverse Laplace transform of 1 Fa,b,S (s) = hb (s)ha (s), s evaluated at t = 0, where hb (s) = and S1 (i ). i =1 (fb (s + ) 1) fb (s + ) + +s

Probability of executing an order before the price moves


b is the random time when the bth order at the bid is executed, given that it is not cancelled.

Theorem
Pa,b P[b < a ] is given by the inverse Laplace transform of 1 Fa,b (s) = gb (s)fa (s), s evaluated at t = 0, where gb (s) = ib1 =1 + i . + i + s

Probability of making the spread

Proposition
The probability Pa,b P[max{b , a } < min{b , a }] of making the spread is given by ha,b + hb,a , where
a

ha,b =
i =0 j=1

P[j < i ]
0

X W P0,i (t)Pa,j (t)gb (t)dt,

where gb is the inverse Laplace transform of gb and...

Probability of making the spread


Proposition
e
X (t)

X P0,i (t) W Pa,j (t)

X (t)i , i!
a,j

X (t) tk W k (Q ) k! a

1 e t

W Qa t

k=0

a,j

W Qa

0 0 0 0 0 0 0 + 0 . . . . .. .. . . . . . . . . 0 0 + (a 1) (a 1)

Probability of increase in mid price


b 1 2 3 4 5 1 .512 .691 .757 .806 .822 2 .304 .502 .601 .672 .731 a 3 .263 .444 .533 .580 .640 a 3 .259 .407 .500 .563 .609 4 .242 .376 .472 .529 .714 5 .226 .359 .409 .484 .606

b 1 2 3 4 5

1 .500 .664 .741 .784 .812

2 .336 .500 .593 .652 .693

4 .216 .348 .437 .500 .548

5 .188 .307 .391 .452 .500

Table: Empirical frequencies (top) and Laplace transform results (bottom).

Probability of executing a limit order


My order is the bth order at the bid. The ask has a orders. The probability that my order is executed before the ask

moves: a 3 .794 .664 .578 .517 .472

b 1 2 3 4 5

1 .503 .359 .291 .251 .224

2 .698 .551 .465 .409 .369

4 .848 .737 .656 .596 .548

5 .882 .787 .713 .654 .607

Probability of making the spread


I have one limit order that is bth order at the bid. I have one limit order that is ath order at the ask. The probability that both are executed before the mid price

moves: a 3 .309 .406 .441 .452 .452

b 1 2 3 4 5

1 .266 .308 .309 .300 .288

2 .308 .386 .406 .406 .400

4 .300 .406 .452 .471 .479

5 .288 .400 .452 .479 .491

Conclusion

We propose to model an order book as a continuous-time

Markov chain

Conclusion

We propose to model an order book as a continuous-time

Markov chain
Conditional on the best bid and ask prices, each price level is

a standard (M/M/1+M) queue

Conclusion

We propose to model an order book as a continuous-time

Markov chain
Conditional on the best bid and ask prices, each price level is

a standard (M/M/1+M) queue


We estimate model parameters with Level II trades and

quotes data

Conclusion

We propose to model an order book as a continuous-time

Markov chain
Conditional on the best bid and ask prices, each price level is

a standard (M/M/1+M) queue


We estimate model parameters with Level II trades and

quotes data
We nd that our simulation is comparable to the data

Conclusion

We propose to model an order book as a continuous-time

Markov chain
Conditional on the best bid and ask prices, each price level is

a standard (M/M/1+M) queue


We estimate model parameters with Level II trades and

quotes data
We nd that our simulation is comparable to the data We use Laplace transform methods to compute conditional

probabilities

Conclusion

We propose to model an order book as a continuous-time

Markov chain
Conditional on the best bid and ask prices, each price level is

a standard (M/M/1+M) queue


We estimate model parameters with Level II trades and

quotes data
We nd that our simulation is comparable to the data We use Laplace transform methods to compute conditional

probabilities
Thanks! Any questions?

You might also like