As Model

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 24

Algorithmic Trading

PIMS Summer School 2016


Market Making

Álvaro Cartea & Sebastian Jaimungal


University of Oxford & University of Toronto

July, 2016

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 1 / 24


The Limit Order Book
I The limit order book is a record of collective interest to buy or
sell certain quantities of an asset at a certain price.
Buy Orders Sell Orders
Price Volume Price Volume
60.00 80 60.10 75
59.90 100 60.20 75
59.80 90 60.30 50

I Graphical representation of the limit order book:


Volume

Price

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 2 / 24


Market Orders
I An incoming market order lifts limit orders from the book.

Volume

Price

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 3 / 24


Market Orders
I An incoming market order lifts limit orders from the book.

Volume

Price

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 4 / 24


Market Orders
I An incoming market order lifts limit orders from the book.

Volume

Price

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 5 / 24


Agent’s Goal
I Optimally place limit orders in the limit order book (LOB)

Volume

Price

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 6 / 24


Market Making

I The market maker’s problem is to find prices at which to


post limit buy/sell orders to profit from round-trip trades

I The benchmark models: Ho & Stoll (81), Avellanda &


Stoikov (08) Cartea & Jaimungal (12), and others
I Need to account for
I market order arrival rate

I Probability that market maker is filled at a given level

I midprice dynamics

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 7 / 24


Market Making

I Midprice dSt = σ dWt , σ > 0,


I δ ± depth at which the agent posts LOs:
I Sell LOs are posted at a price of St +δt+

I Buy LOs at St −δt−

I M ± Poisson arrival of other participants’ buy (+) and sell (−)


MOs which arrive at with intensities λ± ,

I N δ,± counting processes for the agent’s filled sell (+) and buy
(−) LOs,

I Conditional on an MO arrival, the LO is filled with probability


± ±
e −κ δt with κ± ≥ 0

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 8 / 24


Market Maker’s Control Problem
The MM’s performance criteria is
 Z T 
H δ (t, x, S, q) = Et,x,q,S XTδ + QTδ (ST − α QTδ )−φ (Quδ )2 du ,
t

α ≥ 0, and φ ≥ 0. Value function is

H(t, x, S, q) = sup H δ (t, x, S, q) ,


δ ± ∈A

and inventory capped: above by q > 0 and below by q < 0.


I X δ cash process

dXtδ = St +δt+ dNδ,+ − St −δt− dNδ,−


 
t t .

I Q δ inventory process and satisfies


δ δ
Qtδ = Nt ,− − Nt ,+ .

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 9 / 24


DPE

A DPP holds and the value function satisfies the DPE


0 = ∂t H + 1
σ 2 ∂SS H − φ q2
|2 {z } |{z}
midprice diffusion running inv penalty
( )
+ −κ+ δ + + 
+ λ sup e H(t, x + (S + δ ), q − 1, S) − H 1q>q
δ+
| {z }
Prob Filled sell LO
 
 − −

+ λ− sup −κ δ
H t, x − (S − δ − ), q + 1, S − H
 
e 1q<q ,
δ−  | {z } 
Prob Filled buy LO

where 1 is the indicator function, and with terminal condition

H(T , x, S, q) = x + q (S − α q) .

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 10 / 24


Solving HJB
I Make an ansatz for H. In particular, write

H(t, x, q, S) = x + q S + h(t, q) .

I first term is accumulated cash

I second term is the book value of the inventory


marked-to-market

I last term is the added value from following an optimal market


making strategy up to T .

n + + o
φ q 2 = ∂t h(t, q) +λ+ sup e−κ δ δ ++ h(t, q − 1) − h(t, q) 1q>q
δ+ n
− − o
+λ sup e−κ δ δ −+ h(t, q + 1) − h(t, q) 1q<q ,

δ−

with terminal condition h(T , q) = −α q 2 .


(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 11 / 24
Optimal Controls

Then the optimal depths in feedback form are given by


1
δ +,∗ (t, q) = − h(t, q − 1) + h(t, q) , q 6= q , (1a)
κ+
1
δ −,∗ (t, q) = − − h(t, q + 1) + h(t, q) , q 6= q , (1b)
κ
and boundaries δ +,∗ (t, q) = +∞ and δ −,∗ (t, q) = +∞.

Substituting the optimal controls into the DPE we obtain


+ +
φ q 2 = ∂t h(t, q)+ λκ+ e −1 e −κ (−h(t,q−1)+h(t,q) 1q>q
− − (2)
+ λκ− e −1 e −κ (−h(t,q+1)+h(t,q)) 1q<q .

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 12 / 24


Symmetric fill probability
Analytical solution if κ = κ+ = κ− :
1
h(t, q) = log ω(t, q) ,
κ
and stack ω(t, q) into a vector
 0
ω(t, q) = ω(t, q), ω(t, q − 1), . . . , ω(t, q) .

Now, let A denote the (q − q + 1)-square matrix whose rows are


labeled from q to q and whose entries are given by

 −φκ q 2 , i = q,
 + −1

λ e , i = q − 1,
Ai,q = − −1 (3)

 λ e , i = q + 1,
0, otherwise,

2
with terminal and boundary conditions ω(T , q) = e −ακq .

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 13 / 24


Then,
ω(t) = e A(T −t) z , (4)
where z is a (q − q + 1)-dim vector where each component is
2
zj = e −ακ j , j = q, . . . , q. Inserting the controls (1) into the DPE

equation (2) and writing h(t, q) = κ1 log ω(t, q), after some
straightforward computations, one finds that ω(t, q) satisfy the
coupled system of equations

∂t ω(t) + Aω(t) = 0. (5)

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 14 / 24


Optimal Postings

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 15 / 24


Optimal postings φ = 0.001

0.02 0.02

q = −2 q=2

Buy Depth (δ− )


Sell Depth (δ+ )

0.015 0.015
q = −1 q=1
q=0 q=0
0.01 q=1 0.01 q = −1
q=2 q = −2
0.005 0.005
q=3 q = −3

0 0
0 10 20 30 0 10 20 30
Time (secs) Time (secs)
(a) φ = 0.001

Figure : The optimal depths as a function of time for various inventory


levels, T = 30, λ± = 1, κ± = 100, q = −q = 3, α = 0.0001, σ = 0.01,
S0 = 100.

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 16 / 24


Optimal postings φ = 0.02

0.02 0.02
q = −2 q=2

Buy Depth (δ− )


Sell Depth (δ+ )

0.015 0.015 q=1


q = −1
q=0 q=0
0.01 0.01
q=1 q = −1

q=2 q = −2
0.005 0.005
q=3 q = −3
0 0
0 10 20 30 0 10 20 30
Time (secs) Time (secs)
(a) φ = 0.02

Figure : The optimal depths as a function of time for various inventory


levels, T = 30, λ± = 1, κ± = 100, q = −q = 3, α = 0.0001, σ = 0.01,
S0 = 100.

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 17 / 24


Mean reversion in inventory

Given the pair of optimal strategies δ + (t, q), δ − (t, q), the expected
drift in inventories qt is given by

1
µ(t, q) , lim E [Qs − Qt | Qt − = q] ,
s↓t s −t (6)
− −κ− δ −,∗ (t,q) + −κ+ δ +,∗ (t,q)
=λ e −λ e .

I The drift µ(t, q) depends on time.

I For the same level of inventory the speed depends on how


near of far is the strategy from T

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 18 / 24


Inventory

25 30

Inventory Drift (7(q))


◦ Sell
Fill Rate (λ e−κ δ(q) )

20 + Buy 20

10
15
0
10
-10
5 -20

0 -30
−10 −5 0 5 10 -10 -5 0 5 10
Inventory (q) Inventory (q)

Figure : Long-term inventory level. Model parameters are: λ± = 1,


κ± = 100, q = −q = 10, α = 0.0001, σ = 0.01, S0 = 100, and
φ = 2 × 10−3 , 10−3 , 5 × 10−4 .


(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 19 / 24


10
100.14
Inventory (Qt )

Midprice (St )
5 100.12

100.1
0

100.08
-5
100.06
-10
0 100 200 300 185 190 195
Time (sec.) Time (sec.)

Figure : Inventory and midprice path. Model parameters are: λ± = 1,


κ± = 100, q = −q = 10, φ = 0.02, α = 0.0001, σ = 0.01, S0 = 100.

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 20 / 24


Profit and Loss

6 10
φ = 0.001 φ = 0.001
φ = 0.05 φ = 0.05
φ = 0.1 8 φ = 0.1
φ=1 φ=1
Frequency

Frequency
4
6

4
2
2

0 0
0 0.2 0.4 0.6 0.8 −10 −5 0 5 10
Profit and Loss Lifetime Inventory (Qt )

Figure : P&L and Life Inventory of the optimal strategy for 10,000
simulations, λ± = 1, κ± = 100, q = −q = 10, α = 0.0001, σ = 0.01,
and S0 = 100.

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 21 / 24


Market Making with No Terminal Penalty

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 22 / 24


Solving HJB with α = 0

Assume no penalties for liquidating inventories at time T . Thus


the ansatz is
H(t, x, q, S) = x + q S + g(t) . (7)
Thus,
n + +
o n − −
o
0 = gt (t) + λ+ sup e−κ δ δ + + λ− sup e−κ δ δ − ,
δ+ δ−

and the optimal postings are:


1
δ ∗,+ =
κ+
and
1
δ ∗,− = .
κ−

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 23 / 24


Solving HJB with α = 0

Alternatively note that


I A risk-neutral MM, who does not penalise inventories, seeks
to maximise the probability of being filled at every instant in
time.

I Thus, the MM chooses δ ± to maximise the expected depth


conditional on a market order hitting or lifting the appropriate
± ±
side of the book: maximises δ ± e −κ δ . The FOC
± δ± ± δ±
e −κ − κ± δ ± e −κ = 0. (8)

Thus, we see that the optimal half spreads are as above.

(c) Cartea & Jaimungal, 2016 Algo Trading July, 2016 24 / 24

You might also like