Optimal Stochastic Control for Pairs Trading Hui Gong, UCL - - PowerPoint PPT Presentation

optimal stochastic control for pairs trading
SMART_READER_LITE
LIVE PREVIEW

Optimal Stochastic Control for Pairs Trading Hui Gong, UCL - - PowerPoint PPT Presentation

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Optimal Stochastic Control for Pairs Trading Hui Gong, UCL http://www.homepages.ucl.ac.uk/ucahgon/ March 26, 2014 Hui


slide-1
SLIDE 1

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise

Optimal Stochastic Control for Pairs Trading

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ March 26, 2014

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-2
SLIDE 2

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise

Introduction Optimal Stochastic Control Model Dynamics of Paired Stock Prices Co-integrating Vector Dynamic of Wealth Value Integrability Condition Agent’s Objective The HJB equation & Its Solution HJB Equation Particular Case δ = 0 Solution Implementation & Exercise Implement Pairs Trading in MATLAB Exercise

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-3
SLIDE 3

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise

Introduction

Pairs Trading is an investment strategy used by many Hedge

  • Funds. Consider two co-integrated and correlated stocks which

trade at some spread. For a given period, we need to maximise the agent’s terminal utility of wealth subject to budget constraints.

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-4
SLIDE 4

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Dynamics of Paired Stock Prices Co-integrating Vector Dynamic of Wealth Value Integrability Condition Agent’s Objective

Let S1 and S2 denote the co-integrated stock price which satisfies the stochastic differential equations dS1 = (µ1 + δz(t)) S1dt + σ1S1dB1 , (1) dS2 = µ2S2dt + σ2S2

  • ρdB1 +
  • 1 − ρ2dB2
  • ,

(2) where B1 and B2 are independent Brownian Motions.

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-5
SLIDE 5

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Dynamics of Paired Stock Prices Co-integrating Vector Dynamic of Wealth Value Integrability Condition Agent’s Objective

The instantaneous co-integrating vector z(t) is defined by z(t) = a + ln S1(t) + β ln S2(t) . (3) The dynamics of z(t) is a stationary Ornstein-Uhlenbeck process dz = α (η − z) dt + σβdBt , where α = −δ is the speed of mean reversion, σβ =

  • σ2

1 + β2σ2 2 + 2βσ1σ2ρ,

Bt = σ1+βσ2ρ

σβ

B1 + β σ2 √

1−ρ2 σβ

B2 is a Brownian motion adapted to Ft and η = −1 δ

  • µ1 − σ2

1

2 + β

  • µ2 − σ2

2

2

  • is the equilibrium level.

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-6
SLIDE 6

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Dynamics of Paired Stock Prices Co-integrating Vector Dynamic of Wealth Value Integrability Condition Agent’s Objective

The dynamic of wealth value is given by dW = π1(t)dS1 + π2(t)dS2 . (4) Substitute equation (1) and (2) into the value of wealth (4), then we obtain the SDE as below dW = π1(t) (µ1 + δz(t)) S1dt + π2(t)µ2S2dt +π1(t)σ1S1dB1 + π2(t)σ2S2

  • ρdB1 +
  • 1 − ρ2dB2
  • .

(5)

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-7
SLIDE 7

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Dynamics of Paired Stock Prices Co-integrating Vector Dynamic of Wealth Value Integrability Condition Agent’s Objective

A pair of controls (π1, π2) is said to be admissible if π1 and π2 are real-valued, progressively measurable, are such that, (1)(2)(5) define a unique solution (W , S1, S2) for any t ∈ [0, T] and (π1, π2, S1, S2) satisfy the integrability condition E T

t

(π1S1)2 + (π2S2)2ds < +∞ .

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-8
SLIDE 8

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Dynamics of Paired Stock Prices Co-integrating Vector Dynamic of Wealth Value Integrability Condition Agent’s Objective

Assume that the agent’s objective is J(t, W , S1, S2) = max

(π1,π2)∈At

E

  • U
  • W t,W ,S1,S2

T

  • ,

(6) where J (t, W , S1, S2) denote the value function, the agent seeks an admissible control pair (π1, π2) that maximizes the utility of wealth at time T. Specifying U (W ). Now let us assume the utility function like U(W ) = − exp(−γW ) , (7) which is the CARA (Constant Absolute Risk Aversion) utility, where γ > 0 is constant and equal to the absolute risk aversion.

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-9
SLIDE 9

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise HJB Equation Particular Case δ = 0 Solution

We expect the value function J(t, W , S1, S2) satisfy the following HJB partial differential equation: Jt + max

π1,π2[ (π1(µ1 + δz)S1 + π2µ2S2) JW + (µ1 + δz)S1JS1 + µ2S2JS2

+π1σ2

1S2 1JWS1 + π2ρσ1σ2S1S2JWS1

+π2σ2

2S2 2JWS2 + π1ρσ1σ2S1S2JWS2

+1 2

  • π2

1σ2 1S2 1 + ρπ1π2σ1σ2S1S2 + π2 2σ2 2S2 2

  • JWW

+1 2σ2

1S2 1JS1S1 + ρσ1σ2S1S2JS1S2 + 1

2σ2

2S2 2JS2S2] = 0 ,

(8) with the final condition J(T, W , S1, S2) = U(WT) = − exp(−γWT) . (9)

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-10
SLIDE 10

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise HJB Equation Particular Case δ = 0 Solution

Ansatz S1 = ex , S2 = ey , J(t, W , S1, S2) = −e−γW g(t, x, y) . Then the transformed HJB equation will be gt = max[ (π1(µ1 + δz)S1 + π2µ2S2) γg − (µ1 + δz)gx − µ2gy +π1σ2

1S1γgx + π2ρσ1σ2S2γgx + π2σ2 2S2γgy + π1ρσ1σ2S1γgy

−1 2

  • π2

1σ2 1S2 1 + 2π1π2ρσ1σ2S1S2 + π2 2σ2 2S2 2

  • γ2g

−1 2σ2

1(gxx − gx) − 1

2σ2

2(gyy − gy) − ρσ1σ2gxy] ,

(10) subject to g(T, x, y) = 1 . (11)

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-11
SLIDE 11

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise HJB Equation Particular Case δ = 0 Solution

Optimal Control Weights (initial)

π∗

1

= (µ1 + δz) γ(1 − ρ2)σ2

1S1

+ gx γgS1 − ρ µ2 γ(1 − ρ2)σ1σ2S1 , (12) π∗

2

= µ2 γ(1 − ρ2)σ2

2S2

+ gy γgS2 − ρ (µ1 + δz) γ(1 − ρ2)σ1σ2S2 . (13)

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-12
SLIDE 12

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise HJB Equation Particular Case δ = 0 Solution

Particular Case δ = 0

If we set δ = 0, the value function is independent of the stocks and the amount invested in each stock are constant. Then the closed form for the value function and the amount corresponding to δ = 0 will be g(t, x, y) = exp

1 2(1 − ρ2) µ2

1

σ2

1

+ µ2

2

σ2

2

− 2ρµ1µ2 σ1σ2

  • (T − t)
  • ,

π∗

1S1

= µ1 γ(1 − ρ2)σ2

1

− ρµ2 γ(1 − ρ2)σ1σ2 , π∗

2S2

= µ2 γ(1 − ρ2)σ2

2

− ρµ1 γ(1 − ρ2)σ1σ2 .

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-13
SLIDE 13

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise HJB Equation Particular Case δ = 0 Solution

Reduce the HJB equation into a one-dimensional equation by letting X = µ1 + δz = µ1 + δ(a + x + βy) , and by using the exponential change of variable Φ(t, X) = − ln(g(t, x, y)) i.e. g = exp(−Φ).Then we will obtain the linear parabolic PDE Φt = − 1 1 − ρ2 1 2(X 2 σ2

1

+ µ2

2

σ2

2

) − ρ µ2X σ1σ2

  • + 1

2(σ2

1 + βσ2 2)(δΦX)

−1 2(σ2

1 + β2σ2 2 + 2σ1σ2βρ)(δ2ΦXX) .

(14) for any real number X and time 0 t < T and is subject to the terminal condition Φ(T, X) = 0 . (15)

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-14
SLIDE 14

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise HJB Equation Particular Case δ = 0 Solution

Assume Φ(t, X) = a(t)X 2 + b(t)X + c(t) is an explicit solution of the PDE in (14), where the coefficient a, b, c are given by a(t) = 1 2 (T − t) (1 − ρ2)σ2

1

, b(t) = −1 4 (σ2

1 + βσ2 2)δ

(1 − ρ2)σ2

1

(T − t)2 − ρµ2 (1 − ρ2)σ1σ2 (T − t) , c(t) = 1 2 µ2

2

(1 − ρ2)σ2

2

(T − t) + 1 4 (σ2

1 + βσ2 2 + 2σ1σ2βρ)δ2

(1 − ρ2)σ2

1

(T − t)2 +1 4 µ2(σ2

1 + βσ2 2)δρ

(1 − ρ2)σ1σ2 (T − t)2 + 1 24 (σ2

1 + βσ2 2)2δ2

(1 − ρ2)σ2

1

(T − t)3 .

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-15
SLIDE 15

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise HJB Equation Particular Case δ = 0 Solution

Optimal Control Pair (final)

π∗

1S1

= (µ1 + δz) γ(1 − ρ2)σ2

1

+ δ(−2a(t)(µ1 + δz) − b(t)) γ − ρµ2 γ(1 − ρ2)σ1σ2 , (16) π∗

2S2

= µ2 γ(1 − ρ2)σ2

2

+ δβ(−2a(t)(µ1 + δz) − b(t)) γ − ρ(µ1 + δz) γ(1 − ρ2)σ1σ2 . (17)

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-16
SLIDE 16

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Implement Pairs Trading in MATLAB Exercise

The Dynamics of S1 & S2

S0

1 = 25, S0 2 = 50, z(0) = 0.2, µ1 = 0.1, µ2 = 0.05

σ1 = 0.4, σ2 = 0.3, δ = 0.2, ρ = −0.7, β = 0.5, γ = 0.5

50 100 150 200 250 20 25 30 35 40 45 50 55 60 S1 & S2 S1 S2

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-17
SLIDE 17

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Implement Pairs Trading in MATLAB Exercise

The Dynamics of π1 & π2

50 100 150 200 250 0.08 0.1 0.12 0.14 0.16 0.18 0.2 π1 & π2 π1 π2

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-18
SLIDE 18

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Implement Pairs Trading in MATLAB Exercise

The Dynamics of π1S1 & π2S2

50 100 150 200 250 3.8 4 4.2 4.4 4.6 4.8 5 5.2 5.4 π1S1 & π2S2 π1S1 π2S2

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-19
SLIDE 19

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Implement Pairs Trading in MATLAB Exercise

Comparison with the Static control pair

π1 = 0.1578 & π2 = 0.1010

50 100 150 200 250 8 8.2 8.4 8.6 8.8 9 9.2 9.4 9.6 9.8 10 Compare with the constant no. of shares held Dynamic control pair Static control pair

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading

slide-20
SLIDE 20

Outline Introduction Optimal Stochastic Control Model The HJB equation & Its Solution Implementation & Exercise Implement Pairs Trading in MATLAB Exercise

Derive the explicit form for a(t), b(t) and c(t) in Slides Page 14.

Hui Gong, UCL http://www.homepages.ucl.ac.uk/˜ucahgon/ Optimal Stochastic Control for Pairs Trading