Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf ·...

71
Optimal Trading Strategies Stochastic Control Haksun Li [email protected] www.numericalmethod.com

Transcript of Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf ·...

Page 1: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Optimal Trading Strategies

Stochastic Control

Haksun Li [email protected]

www.numericalmethod.com

Page 2: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Speaker Profile Dr. Haksun Li CEO, Numerical Method Inc. (Ex-)Adjunct Professors, Industry Fellow, Advisor,

Consultant with the National University of Singapore, Nanyang Technological University, Fudan University, the Hong Kong University of Science and Technology.

Quantitative Trader/Analyst, BNPP, UBS PhD, Computer Sci, University of Michigan Ann Arbor M.S., Financial Mathematics, University of Chicago B.S., Mathematics, University of Chicago

2

Page 3: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

References Optimal Pairs Trading: A Stochastic Control

Approach. Mudchanatongsuk, S., Primbs, J.A., Wong, W. Dept. of Manage. Sci. & Eng., Stanford Univ., Stanford, CA. 2008.

Optimal Trend Following Trading Rules. Dai, M., Zhang, Q., Zhu Q. J. 2011

3

Page 4: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Mean Reversion Trading

4

Page 5: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Stochastic Control We model the difference between the log-returns of

two assets as an Ornstein-Uhlenbeck process. We compute the optimal position to take as a function

of the deviation from the equilibrium. This is done by solving the corresponding the

Hamilton-Jacobi-Bellman equation.

5

Page 6: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Formulation Assume a risk free asset 𝑀𝑡, which satisfies 𝑑𝑀𝑡 = 𝑟𝑀𝑡𝑑𝑑

Assume two assets,𝐴𝑡 and 𝐵𝑡. Assume 𝐵𝑡follows a geometric Brownian motion. 𝑑𝐵𝑡 = 𝜇𝐵𝑡𝑑𝑑 + 𝜎𝐵𝑡𝑑𝑧𝑡

𝑥𝑡is the spread between the two assets. 𝑥𝑡 = log𝐴𝑡 − log𝐵𝑡

6

Page 7: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Ornstein-Uhlenbeck Process We assume the spread, the basket that we want to

trade, follows a mean-reverting process. 𝑑𝑥𝑡 = 𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + 𝜂𝑑𝜔𝑡

𝜃 is the long term equilibrium to which the spread reverts.

𝑘 is the rate of reversion. It must be positive to ensure stability around the equilibrium value.

7

Page 8: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Instantaneous Correlation Let 𝜌 denote the instantaneous correlation coefficient

between 𝑧 and 𝜔. 𝐸 𝑑𝜔𝑡𝑑𝑧𝑡 = 𝜌𝑑𝑑

8

Page 9: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Univariate Ito’s Lemma

9

Assume 𝑑𝑋𝑡 = 𝜇𝑡𝑑𝑑 + 𝜎𝑡𝑑𝐵𝑡 𝑓 𝑑,𝑋𝑡 is twice differentiable of two real variables

We have

𝑑𝑓 𝑑,𝑋𝑡 = 𝜕𝜕𝜕𝑡

+ 𝜇𝑡𝜕𝜕𝜕𝜕

+ 𝜎𝑡2

2𝜕2𝜕𝜕𝜕2

𝑑𝑑 + 𝜎𝑡𝜕𝜕𝜕𝜕𝑑𝐵𝑡

Page 10: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Log example For G.B.M., 𝑑𝑋𝑡 = 𝜇𝑋𝑡𝑑𝑑 + 𝜎𝑋𝑡𝑑𝑧𝑡 , 𝑑 log𝑋𝑡 =? 𝑓 𝑥 = log 𝑥

𝜕𝜕𝜕𝑡

= 0

𝜕𝜕𝜕𝜕

= 1𝜕

𝜕2𝜕𝜕𝜕2

= − 1𝜕2

𝑑 log𝑋𝑡 = 𝜇𝑋𝑡1𝑋𝑡

+ 𝜎𝑋𝑡 2

2− 1

𝑋𝑡2𝑑𝑑 + 𝜎𝑋𝑡

1𝑋𝑡

𝑑𝐵𝑡

= 𝜇 − 𝜎2

2𝑑𝑑 + 𝜎𝑑𝐵𝑡

10

Page 11: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Multivariate Ito’s Lemma

11

Assume 𝑋𝑡 = 𝑋1𝑡,𝑋2𝑡 ,⋯ ,𝑋𝑛𝑡 is a vector Ito process 𝑓 𝑥1𝑡 , 𝑥2𝑡 ,⋯ , 𝑥𝑛𝑡 is twice differentiable

We have 𝑑𝑓 𝑋1𝑡,𝑋2𝑡 ,⋯ ,𝑋𝑛𝑡 = ∑ 𝜕

𝜕𝜕𝑖𝑛𝑖=1 𝑓 𝑋1𝑡,𝑋2𝑡 ,⋯ ,𝑋𝑛𝑡 𝑑𝑋𝑖 𝑑

+ 12∑ ∑ 𝜕2

𝜕𝜕𝑖𝜕𝜕𝑗𝑛𝑗=1

𝑛𝑖=1 𝑓 𝑋1𝑡,𝑋2𝑡 ,⋯ ,𝑋𝑛𝑡 𝑑 𝑋𝑖 ,𝑋𝑗 𝑑

Page 12: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Multivariate Example log𝐴𝑡 = 𝑥𝑡 + log𝐵𝑡 𝐴𝑡 = exp 𝑥𝑡 + log𝐵𝑡

𝜕𝐴𝑡𝜕𝜕𝑡

= exp 𝑥𝑡 + log𝐵𝑡 = 𝐴𝑡

𝜕𝐴𝑡𝜕𝐵𝑡

= exp 𝑥𝑡 + log𝐵𝑡1𝐵𝑡

= 𝐴𝑡𝐵𝑡

𝜕2𝐴𝑡𝜕𝜕𝑡2

= 𝜕𝐴𝑡𝜕𝜕𝑡

= 𝐴𝑡

𝜕2𝐴𝑡𝜕𝐵𝑡2

= 𝜕𝜕𝐵𝑡

𝐴𝑡𝐵𝑡

= 0

𝜕2𝐴𝑡𝜕𝐵𝑡𝜕𝜕𝑡

= 𝜕𝜕𝐵𝑡

𝜕𝐴𝑡𝜕𝜕𝑡

= 𝜕𝐴𝑡𝜕𝐵𝑡

= 𝐴𝑡𝐵𝑡

12

Page 13: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

What is the Dynamic of Asset At? 𝜕𝐴𝑡 =𝜕𝐴𝑡𝜕𝜕

𝑑𝑥𝑡 + 𝜕𝐴𝑡𝜕𝐵𝑡

𝑑𝐵𝑡 + 12𝜕2𝐴𝑡𝜕𝜕2

𝑑𝑥𝑡 2 + 𝜕2𝐴𝑡𝜕𝐵𝑡𝜕𝜕

𝑑𝑥𝑡 𝑑𝐵𝑡

= 𝐴𝑡𝑑𝑥𝑡 + 𝐴𝑡𝐵𝑡𝑑𝐵𝑡 + 1

2𝐴𝑡 𝑑𝑥𝑡 2 + 𝐴𝑡

𝐵𝑡𝑑𝑥𝑡 𝑑𝐵𝑡

= 𝐴𝑡 𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + 𝜂𝑑𝜔𝑡 + 𝐴𝑡𝐵𝑡

𝜇𝐵𝑡𝑑𝑑 + 𝜎𝐵𝑡𝑑𝑧𝑡 +12𝐴𝑡𝜂2𝑑𝑑 + 𝐴𝑡

𝐵𝑡𝜌𝜂𝜎𝐵𝑡𝑑𝑑

13

Page 14: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Dynamic of Asset At 𝜕𝐴𝑡 = 𝐴𝑡 𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + 𝜂𝑑𝜔𝑡 + 𝐴𝑡 𝜇𝑑𝑑 + 𝜎𝑑𝑧𝑡 +12𝐴𝑡𝜂2𝑑𝑑 + 𝐴𝑡𝜌𝜂𝜎𝑑𝑑

= 𝐴𝑡 𝑘 𝜃 − 𝑥𝑡 + 𝜇 + 12𝜂2 + 𝜌𝜂𝜎 𝑑𝑑 + 𝐴𝑡𝜂𝑑𝜔𝑡 +

𝐴𝑡𝜎𝑑𝑧𝑡

= 𝐴𝑡 𝜇 + 𝑘 𝜃 − 𝑥𝑡 + 12𝜂2 + 𝜌𝜂𝜎 𝑑𝑑 + 𝜎𝑑𝑧𝑡 + 𝜂𝑑𝜔𝑡

14

Page 15: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Notations 𝑉𝑡: the value of a self-financing pairs trading portfolio ℎ𝑡:the portfolio weight for stock A ℎ𝑡� = −ℎ𝑡:the portfolio weight for stock B

15

Page 16: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Self-Financing Portfolio Dynamic

𝑑𝑉𝑡𝑉𝑡

= ℎ𝑡𝑑𝐴𝑡𝐴𝑡

+ ℎ𝑡�𝑑𝐵𝑡𝐵𝑡

+ 𝑑𝑀𝑡𝑀𝑡

=ℎ𝑡 𝜇 + 𝑘 𝜃 − 𝑥𝑡 + 1

2𝜂2 + 𝜌𝜂𝜎 𝑑𝑑 + 𝜎𝑑𝑧𝑡 + 𝜂𝑑𝜔𝑡 −

ℎ𝑡 𝜇𝑑𝑑 + 𝜎𝑑𝑧𝑡 + 𝑟𝑑𝑑

= ℎ𝑡 𝑘 𝜃 − 𝑥𝑡 + 12𝜂2 + 𝜌𝜂𝜎 𝑑𝑑 + 𝜂𝑑𝜔𝑡 + 𝑟𝑑𝑑

= ℎ𝑡 𝑘 𝜃 − 𝑥𝑡 + 12𝜂2 + 𝜌𝜂𝜎 + 𝑟 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡

16

Page 17: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Power Utility Investor preference: 𝑈 𝑥 = 𝑥𝛾 𝑥 ≥ 0 0 < 𝛾 < 1

17

Page 18: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Problem Formulation max

ℎ𝑡𝐸 𝑉𝑇𝛾 , s.t.,

𝑉 0 = 𝑣0, x 0 = 𝑥0 𝑑𝑥𝑡 = 𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + 𝜂𝑑𝜔𝑡 𝑑𝑉𝑡 = ℎ𝑡𝑑𝑥𝑡 = ℎ𝑡𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡 Note that we simplify GBM to BM of 𝑉𝑡, and remove

some constants.

18

Page 19: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Dynamic Programming

19

Consider a stage problem to minimize (or maximize) the accumulated costs over a system path.

s0

s11

s12

time t = 0 t = 1

S21

S22

s23

t = 2

3

2

3

5

Cost = 𝑐3 + ∑ 𝑐𝑡2𝑡=0

s3

s12

5

4

3

1

5

Page 20: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Dynamic Programming Formulation State change: 𝑥𝑘+1 = 𝑓𝑘 𝑥𝑘 ,𝑢𝑘 ,𝜔𝑘 𝑘: time 𝑥𝑘: state 𝑢𝑘: control decision selected at time 𝑘 𝜔𝑘: a random noise

Cost: 𝑔𝑁 𝑥𝑁 + ∑ 𝑔𝑘 𝑥𝑘 ,𝑢𝑘 ,𝜔𝑘𝑁−1𝑘=0

Objective: minimize (maximize) the expected cost. We need to take expectation to account for the noise, 𝜔𝑘.

20

Page 21: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Principle of Optimality Let 𝜋∗ = 𝜇0∗, 𝜇1∗,⋯ , 𝜇𝑁−1∗ be an optimal policy for

the basic problem, and assume that when using 𝜋∗, a give state 𝑥𝑖 occurs at time 𝑖 with positive probability. Consider the sub-problem whereby we are at 𝑥𝑖 at time 𝑖 and wish to minimize the “cost-to-go” from time 𝑖 to time 𝑁. 𝐸 𝑔𝑁 𝑥𝑁 + ∑ 𝑔𝑘 𝑥𝑘 ,𝑢𝑘 ,𝜔𝑘

𝑁−1𝑘=𝑖

Then the truncated policy 𝜇𝑖∗, 𝜇𝑖+1∗,⋯ , 𝜇𝑁−1∗ is optimal for this sub-problem.

21

Page 22: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Dynamic Programming Algorithm For every initial state 𝑥0, the optimal cost 𝐽∗ 𝑥𝑘 of the

basic problem is equal to 𝐽0 𝑥0 , given by the last step of the following algorithm, which proceeds backward in time from period 𝑁 − 1 to period 0: 𝐽𝑁 𝑥𝑁 = 𝑔𝑁 𝑥𝑁

𝐽𝑘 𝑥𝑘 = min𝑢𝑘

𝐸 𝑔𝑘 𝑥𝑘 ,𝑢𝑘 ,𝜔𝑘 + 𝐽𝑘+1 𝑓𝑘 𝑥𝑘 ,𝑢𝑘 ,𝜔𝑘

22

Page 23: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Value function Terminal condition: 𝐺 𝑇,𝑉, 𝑥 = 𝑉𝛾

DP equation: 𝐺 𝑑,𝑉𝑡 , 𝑥𝑡 = m𝑎𝑥

ℎ𝑡𝐸 𝐺 𝑑 + 𝑑𝑑,𝑉𝑡+𝑑𝑡 , 𝑥𝑡+𝑑𝑡

𝐺 𝑑,𝑉𝑡 , 𝑥𝑡 = m𝑎𝑥ℎ𝑡

𝐸 𝐺 𝑑,𝑉𝑡 , 𝑥𝑡 + Δ𝐺

By Ito’s lemma: Δ𝐺 =𝐺𝑡𝑑𝑑 + 𝐺𝑉 𝑑𝑉 + 𝐺𝜕 𝑑𝑥 + 1

2𝐺𝑉𝑉 𝑑𝑉 2 + 1

2𝐺𝜕𝜕 𝑑𝑥 2 +

𝐺𝑉𝜕 𝑑𝑉 𝑑𝑥

23

Page 24: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Hamilton-Jacobi-Bellman Equation Cancel 𝐺 𝑑,𝑉𝑡, 𝑥𝑡 on both LHS and RHS. Divide by time discretization, Δ𝑑. Take limit as Δ𝑑 → 0, hence Ito. 0 = m𝑎𝑥

ℎ𝑡𝐸 Δ𝐺

m𝑎𝑥ℎ𝑡

𝐸 𝐺𝑡𝑑𝑑 + 𝐺𝑉 𝑑𝑉 + 𝐺𝜕 𝑑𝑥 + 12𝐺𝑉𝑉 𝑑𝑉 2 + 1

2𝐺𝜕𝜕 𝑑𝑥 2 + 𝐺𝑉𝜕 𝑑𝑉 𝑑𝑥 =

0 The optimal portfolio position is ℎ𝑡

∗.

24

Page 25: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

HJB for Our Portfolio Value m𝑎𝑥

ℎ𝑡𝐸 𝐺𝑡𝑑𝑑 + 𝐺𝑉 𝑑𝑉 + 𝐺𝜕 𝑑𝑥 + 1

2𝐺𝑉𝑉 𝑑𝑉 2 + 1

2𝐺𝜕𝜕 𝑑𝑥 2 + 𝐺𝑉𝜕 𝑑𝑉 𝑑𝑥 =

0

m𝑎𝑥ℎ𝑡

𝐸𝐺𝑡𝑑𝑑 + 𝐺𝑉 ℎ𝑡𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡 + 𝐺𝜕 𝑑𝑥 +12𝐺𝑉𝑉 ℎ𝑡𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡 2 + 1

2𝐺𝜕𝜕 𝑑𝑥 2 +

𝐺𝑉𝜕 ℎ𝑡𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡 𝑑𝑥= 0

m𝑎𝑥ℎ𝑡

𝐸

𝐺𝑡𝑑𝑑 + 𝐺𝑉 ℎ𝑡𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡 +𝐺𝜕 𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + 𝜂𝑑𝜔𝑡 +

12𝐺𝑉𝑉 ℎ𝑡𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡 2 +12𝐺𝜕𝜕 𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + 𝜂𝑑𝜔𝑡 2 +

𝐺𝑉𝜕 ℎ𝑡𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + ℎ𝑡𝜂𝑑𝜔𝑡 × 𝑘 𝜃 − 𝑥𝑡 𝑑𝑑 + 𝜂𝑑𝜔𝑡

= 0

25

Page 26: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Taking Expectation All 𝜂𝑑𝜔𝑡 disapper because of the expectation operator. Only the deterministic 𝑑𝑑 terms remain. Divide LHR and RHS by 𝑑𝑑.

m𝑎𝑥ℎ𝑡

𝐺𝑡 + 𝐺𝑉 ℎ𝑡𝑘 𝜃 − 𝑥𝑡 +𝐺𝜕 𝑘 𝜃 − 𝑥𝑡 + 1

2𝐺𝑉𝑉 ℎ𝑡𝜂 2 + 1

2𝐺𝜕𝜕𝜂2

+𝐺𝑉𝜕 ℎ𝑡𝜂2= 0

26

Page 27: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Dynamic Programming Solution Solve for the cost-to-go function, 𝐺𝑡. Assume that the optimal policy is ℎ𝑡

∗.

27

Page 28: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

First Order Condition Differentiate w.r.t. ℎ𝑡. 𝐺𝑉 𝑘 𝜃 − 𝑥𝑡 + ℎ𝑡

∗𝐺𝑉𝑉𝜂2 + 𝐺𝑉𝜕𝜂2 = 0

ℎ𝑡∗ = −𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉𝜂2

In order to determine the optimal position, ℎ𝑡∗, we

need to solve for 𝐺 to get 𝐺𝑉, 𝐺𝑉𝜕, and 𝐺𝑉𝑉.

28

Page 29: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

The Partial Differential Equation (1)

𝐺𝑡 −

𝐺𝑉𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉𝜂2𝑘 𝜃 − 𝑥𝑡 +

𝐺𝜕 𝑘 𝜃 − 𝑥𝑡 +12𝐺𝑉𝑉𝜂2

𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉𝜂2

2+

12𝐺𝜕𝜕𝜂2 −

𝐺𝑉𝜕𝜂2𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉𝜂2

= 0

29

Page 30: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

The Partial Differential Equation (2)

𝐺𝑡 −

𝐺𝑉𝑘 𝜃 − 𝑥𝑡𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉𝜂2+

𝐺𝜕 𝑘 𝜃 − 𝑥𝑡 +12𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

2

𝐺𝑉𝑉𝜂2+

12𝐺𝜕𝜕𝜂2 −

𝐺𝑉𝜕𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉

= 0

30

Page 31: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Dis-equilibrium Let 𝑏 = 𝑘 𝜃 − 𝑥𝑡 . Rewrite:

𝐺𝑡 − 𝐺𝑉𝑏𝐺𝑉𝑏+𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉𝜂2+ 𝐺𝜕𝑏 + 1

2𝐺𝑉𝑏+𝐺𝑉𝑉𝜂2

2

𝐺𝑉𝑉𝜂2+ 1

2𝐺𝜕𝜕𝜂2 −

𝐺𝑉𝜕𝐺𝑉𝑏+𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉= 0

Multiply by 𝐺𝑉𝑉𝜂2. 𝐺𝑡𝐺𝑉𝑉𝜂2 − 𝐺𝑉𝑏 𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 + 𝐺𝜕𝑏𝐺𝑉𝑉𝜂2 +12𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 2 + 1

2𝐺𝜕𝜕𝐺𝑉𝑉𝜂4 −

𝐺𝑉𝜕𝜂2 𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 = 0

31

Page 32: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Simplification Note that −𝐺𝑉𝑏 𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 + 1

2𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 2 −

𝐺𝑉𝜕𝜂2 𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 = −12𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 2

The PDE becomes

𝐺𝑡𝐺𝑉𝑉𝜂2 + 𝐺𝜕𝑏𝐺𝑉𝑉𝜂2 + 12𝐺𝜕𝜕𝐺𝑉𝑉𝜂4 −

12𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 2 = 0

32

Page 33: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

The Partial Differential Equation (3)

𝐺𝑡𝐺𝑉𝑉𝜂2 + 𝐺𝜕𝑏𝐺𝑉𝑉𝜂2 + 12𝐺𝜕𝜕𝐺𝑉𝑉𝜂4 −

12𝐺𝑉𝑏 + 𝐺𝑉𝜕𝜂2 2 = 0

33

Page 34: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Ansatz for G 𝐺 𝑑,𝑉, 𝑥 = 𝑓 𝑑, 𝑥 𝑉𝛾 𝐺 𝑇,𝑉, 𝑥 = 𝑉𝛾 𝑓 𝑇, 𝑥 = 1 𝐺𝑡 = 𝑉𝛾𝑓𝑡 𝐺𝑉 = 𝛾𝑉𝛾−1𝑓 𝐺𝑉𝑉 = 𝛾 𝛾 − 1 𝑉𝛾−2𝑓 𝐺𝜕 = 𝑉𝛾𝑓𝜕 𝐺𝑉𝜕 = 𝛾𝑉𝛾−1𝑓𝜕 𝐺𝜕𝜕 = 𝑉𝛾𝑓𝜕𝜕

34

Page 35: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Another PDE (1) 𝑉𝛾𝑓𝑡𝛾 𝛾 − 1 𝑉𝛾−2𝑓𝜂2 + 𝑉𝛾𝑓𝜕𝑏𝛾 𝛾 − 1 𝑉𝛾−2𝑓𝜂2 +12𝑉𝛾𝑓𝜕𝜕𝛾 𝛾 − 1 𝑉𝛾−2𝑓𝜂4 −

12𝛾𝑉𝛾−1𝑓𝑏 + 𝛾𝑉𝛾−1𝑓𝜕𝜂2 2 = 0

Divide by 𝛾 𝛾 − 1 𝜂2𝑉2𝛾−2.

𝑓𝑡𝑓 + 𝑓𝜕𝑏𝑓 + 12𝑓𝜕𝜕𝑓𝜂2 −

𝛾2 𝛾−1

𝑓 𝑏𝜂

+ 𝑓𝜕𝜂2

= 0

35

Page 36: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Ansatz for 𝑓

𝑓𝑓𝑡 + 𝑏𝑓𝑓𝜕 + 12𝜂2𝑓𝑓𝜕𝜕 −

𝛾2 𝛾−1

𝑏𝜂𝑓 + 𝜂𝑓𝜕

2= 0

𝑓 𝑑, 𝑥 = 𝑔 𝑑 exp 𝑥𝑥 𝑑 + 𝑥2𝛼 𝑑 = 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑓𝑡 =𝑔𝑡 exp 𝑥𝑥 + 𝑥2𝛼 + 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑥𝑥𝑡 + 𝑥2𝛼𝑡

𝑓𝜕 = 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑥 + 2𝑥𝛼 𝑓𝜕𝜕 =𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑥 + 2𝑥𝛼 2 + 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 2𝛼

𝜕𝑉𝜕

= 𝑥 + 2𝛼𝑥

36

Page 37: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Boundary Conditions 𝑓 𝑇, 𝑥 = 𝑔 𝑇 exp 𝑥𝑥 𝑇 + 𝑥2𝛼 𝑇 = 1 𝑔 𝑇 = 1 𝛼 𝑇 = 0 𝑥 𝑇 = 0

37

Page 38: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Yet Another PDE (1) 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑔𝑡 exp 𝑥𝑥 + 𝑥2𝛼 + 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑥𝑥𝑡 + 𝑥2𝛼𝑡 +𝑏𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑥 + 2𝑥𝛼 +12𝜂2𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑥 + 2𝑥𝛼 2 + 𝑔 exp 𝑥𝑥 + 𝑥2𝛼 2𝛼 −

𝛾2 𝛾−1

𝑏𝜂𝑔 exp 𝑥𝑥 + 𝑥2𝛼 + 𝜂𝑔 exp 𝑥𝑥 + 𝑥2𝛼 𝑥 + 2𝑥𝛼

2

= 0

Divide by g exp 𝑥𝑥 + 𝑥2𝛼 exp 𝑥𝑥 + 𝑥2𝛼 .

𝑔𝑡 + 𝑔 𝑥𝑥𝑡 + 𝑥2𝛼𝑡 + 𝑏𝑔 𝑥 + 2𝑥𝛼 + 12𝜂2 𝑔 𝑥 + 2𝑥𝛼 2 + 𝑔 2𝛼 −

𝛾2 𝛾−1

𝑔 𝑏𝜂

+ 𝜂 𝑥 + 2𝑥𝛼2

= 0

𝑔𝑡 + 𝑔 𝑥𝑥𝑡 + 𝑥2𝛼𝑡 + 𝑏𝑔 𝑥 + 2𝑥𝛼 + 12𝜂2𝑔 𝑥 + 2𝑥𝛼 2 + 𝜂2𝑔𝛼 −

𝛾2 𝛾−1

𝑔 𝑏𝜂

+ 𝜂 𝑥 + 2𝑥𝛼2

= 0

38

Page 39: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Yet Another PDE (2) 𝜆 = 𝛾

2 𝛾−1

𝑔𝑡 + 𝑔 𝑥𝑥𝑡 + 𝑥2𝛼𝑡 + 𝑏𝑔 𝑥 + 2𝑥𝛼 +12𝜂2𝑔 𝑥 + 2𝑥𝛼 2 + 𝜂2𝑔𝛼 − 𝜆𝑔 𝑏

𝜂+ 𝜂 𝑥 + 2𝑥𝛼

2

= 0

39

Page 40: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Expansion in 𝑥 𝑔𝑡 + 𝑔𝑥𝑥𝑡 + 𝑔𝑥2𝛼𝑡 + 𝑏𝑔𝑥 + 2𝑥𝛼𝑏𝑔 + 1

2𝜂2𝑔 𝑥2 + 4𝑥2𝛼2 + 4𝑥𝛼𝑥 + 𝜂2𝑔𝛼 −

𝜆𝑔 𝑏2

𝜂2+ 𝜂2𝑥2 + 4𝜂2𝑥2𝛼2 + 2𝑏𝑥 + 4𝑏𝑥𝛼 + 4𝜂2𝑥𝛼𝑥 = 0

𝑔𝑡 + 𝑔𝑥𝑥𝑡 + 𝑔𝑥2𝛼𝑡 + 𝑘 𝜃 − 𝑥 𝑔𝑥 + 2𝑥𝛼𝑘 𝜃 − 𝑥 𝑔 +12𝜂2𝑔 𝑥2 + 4𝑥2𝛼2 + 4𝑥𝛼𝑥 + 𝜂2𝑔𝛼 −

𝜆𝑔 𝑘2 𝜃−𝜕 2

𝜂2+ 𝜂2𝑥2 + 4𝜂2𝑥2𝛼2 + 2𝑘 𝜃 − 𝑥 𝑥 + 4𝑘 𝜃 − 𝑥 𝑥𝛼 + 4𝜂2𝑥𝛼𝑥 = 0

𝑔𝑡 + 𝑔𝑥𝑥𝑡 + 𝑔𝑥2𝛼𝑡 + 𝑘𝑔𝑥𝜃 − 𝑘𝑔𝑥𝑥 + 2𝑥𝛼𝑘𝑔𝜃 − 2𝛼𝑘𝑔𝑥2 + 12𝜂2𝑔𝑥2 +

2𝜂2𝑔𝑥2𝛼2 + 2𝜂2𝑔𝑥𝛼𝑥 + 𝜂2𝑔𝛼 − 𝜆𝑔𝜂2𝑘2𝜃2 + 2 𝜆𝑔

𝜂2𝑘2𝜃𝑥 − 𝜆𝑔

𝜂2𝑘2𝑥2 − 𝜆𝑔𝜂2𝑥2 −

4𝜆𝑔𝜂2𝑥2𝛼2 − 2𝜆𝑔𝑘𝑥𝜃 + 2𝜆𝑔𝑘𝑥𝑥 − 4𝜆𝑔𝑘𝜃𝑥𝛼 + 4𝜆𝑔𝑘𝑥2𝛼 − 4𝜆𝑔𝜂2𝑥𝛼𝑥 = 0

40

Page 41: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Grouping in 𝑥 𝑔𝑡 + 𝑘𝑔𝑥𝜃 + 1

2𝜂2𝑔𝑥2 + 𝜂2𝑔𝛼 − 𝜆𝑔

𝜂2𝑘2𝜃2 − 𝜆𝑔𝜂2𝑥2 − 2𝜆𝑔𝑘𝑥𝜃 +

𝑔𝑥𝑡 − 𝑘𝑔𝑥 + 2𝛼𝑘𝑔𝜃 + 2𝜂2𝑔𝛼𝑥 + 2 𝜆𝑔𝜂2𝑘2𝜃 + 2𝜆𝑔𝑘𝑥 − 4𝜆𝑔𝑘𝜃𝛼 − 4𝜆𝑔𝜂2𝛼𝑥 𝑥 +

𝑔𝛼𝑡 − 2𝛼𝑘𝑔 + 2𝜂2𝑔𝛼2 − 𝜆𝑔𝜂2𝑘2 − 4𝜆𝑔𝜂2𝛼2 + 4𝜆𝑔𝑘𝛼 𝑥2 = 0

41

Page 42: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

The Three PDE’s (1)

𝑔𝛼𝑡 − 2𝛼𝑘𝑔 + 2𝜂2𝑔𝛼2 − 𝜆𝑔𝜂2𝑘2 − 4𝜆𝑔𝜂2𝛼2 + 4𝜆𝑔𝑘𝛼 =

0

𝑔𝑥𝑡 − 𝑘𝑔𝑥 + 2𝛼𝑘𝑔𝜃 + 2𝜂2𝑔𝛼𝑥 + 2 𝜆𝑔𝜂2𝑘2𝜃 + 2𝜆𝑔𝑘𝑥 −

4𝜆𝑔𝑘𝜃𝛼 − 4𝜆𝑔𝜂2𝛼𝑥 = 0

𝑔𝑡 + 𝑘𝑔𝑥𝜃 + 12𝜂2𝑔𝑥2 + 𝜂2𝑔𝛼 − 𝜆𝑔

𝜂2𝑘2𝜃2 − 𝜆𝑔𝜂2𝑥2 −

2𝜆𝑔𝑘𝑥𝜃 = 0

42

Page 43: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

PDE in 𝛼

𝛼𝑡 + 2𝜂2 − 4𝜆𝜂2 𝛼2 + 4𝜆𝑘 − 2𝑘 𝛼 − 𝜆𝜂2𝑘2 = 0

𝛼𝑡 = 𝜆𝜂2𝑘2 + 2𝑘 1 − 2𝜆 𝛼 + 2𝜂2 2𝜆 − 1 𝛼2

43

Page 44: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

PDE in 𝑥, 𝛼 𝑥𝑡 − 𝑘𝑥 + 2𝜂2𝛼𝑥 + 2𝜆𝑘𝑥 − 4𝜆𝜂2𝛼𝑥 − 4𝜆𝑘𝜃𝛼 +

2 𝜆𝜂2𝑘2𝜃 + 2𝛼𝑘𝜃 = 0

𝑥𝑡 =𝑘 − 2𝜂2𝛼 − 2𝜆𝑘 + 4𝜆𝜂2𝛼 𝑥 +4𝜆𝑘𝜃𝛼 − 2 𝜆

𝜂2𝑘2𝜃 − 2𝛼𝑘𝜃

44

Page 45: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

PDE in 𝑥, 𝛼, 𝑔

𝑔𝑡 + 𝑘𝑔𝑥𝜃 + 12𝜂2𝑔𝑥2 + 𝜂2𝑔𝛼 − 𝜆𝑔

𝜂2𝑘2𝜃2 − 𝜆𝑔𝜂2𝑥2 −

2𝜆𝑔𝑘𝑥𝜃 = 0

𝑔𝑡 = −𝑘𝑔𝑥𝜃 − 12𝜂2𝑔𝑥2 − 𝜂2𝑔𝛼 + 𝜆𝑔

𝜂2𝑘2𝜃2 + 𝜆𝑔𝜂2𝑥2 +

2𝜆𝑔𝑘𝑥𝜃 𝑔𝑡 =𝑔 −𝑘𝑥𝜃 − 1

2𝜂2𝑥2 − 𝜂2𝛼 + 𝜆

𝜂2𝑘2𝜃2 + 𝜆𝜂2𝑥2 + 2𝜆𝑘𝑥𝜃

45

Page 46: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Riccati Equation A Riccati equation is any ordinary differential equation

that is quadratic in the unknown function.

𝛼𝑡 = 𝜆𝜂2𝑘2 + 2𝑘 1 − 2𝜆 𝛼 + 2𝜂2 2𝜆 − 1 𝛼2

𝛼𝑡 = 𝐴0 + 𝐴1𝛼 + 𝐴2𝛼2

46

Page 47: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Solving a Riccati Equation by Integration Suppose a particular solution, 𝛼1, can be found.

𝛼 = 𝛼1 + 1𝑧 is the general solution, subject to some

boundary condition.

47

Page 48: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Particular Solution Either 𝛼1 or 𝛼2 is a particular solution to the ODE.

This can be verified by mere substitution.

𝛼1,2 =−𝐴1± 𝐴12−4𝐴2𝐴0

2𝐴2

48

Page 49: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

𝑧 Substitution

Suppose 𝛼 = 𝛼1 + 1𝑧.

1𝑧̇ = 𝐴0 + 𝐴1 𝛼1 + 1

𝑧+ 𝐴2 𝛼1 + 1

𝑧

2

= 𝐴0 + 𝐴1𝛼1 + 𝐴11𝑧

+ 𝐴2𝛼12 + 𝐴21𝑧2

+ 2𝐴2𝛼1𝑧

= 𝐴0 + 𝐴1𝛼1 + 𝐴11𝑧

+ 𝐴2𝛼12 + 𝐴21𝑧2

+ 2𝐴2𝛼1𝑧

= 𝐴0 + 𝐴1𝛼1 + 𝐴2𝛼12 + 𝐴1+2𝛼1𝐴2𝑧

+ 𝐴2𝑧2

goes to 0 by the definition of 𝛼1

49

Page 50: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Solving 𝑧

1𝑧̇ = 𝐴1+2𝛼1𝐴2

𝑧+ 𝐴2

𝑧2

− 1𝑧2�̇� = 𝐴1+2𝛼1𝐴2

𝑧+ 𝐴2

𝑧2

1st order linear ODE �̇� + 𝐴1 + 2𝛼1𝐴2 𝑧 = −𝐴2

𝑧 𝑑 = −𝐴2𝐴1+2𝛼1𝐴2

+ 𝐶exp − 𝐴1 + 2𝛼1𝐴2 𝑑

50

Page 51: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Solving for 𝛼

𝛼 = 𝛼1 + 1−𝐴2

𝐴1+2𝛼1𝐴2+𝐶exp− 𝐴1+2𝛼1𝐴2 𝑡

boundary condition: 𝛼 𝑇 = 0

𝛼1 + 1−𝐴2

𝐴1+2𝛼1𝐴2+𝐶exp− 𝐴1+2𝛼1𝐴2 𝑇

= 0

𝐶exp − 𝐴1 + 2𝛼1𝐴2 𝑇 = − 1𝛼1

+ 𝐴2𝐴1+2𝛼1𝐴2

𝐶 = exp 𝐴1 + 2𝛼1𝐴2 𝑇𝐴2

𝐴1+2𝛼1𝐴2− 1

𝛼1

51

Page 52: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

𝛼 Solution (1)

𝛼 = 𝛼1 + 1−𝐴2

𝐴1+2𝛼1𝐴2+𝐶exp− 𝐴1+2𝛼1𝐴2 𝑡

=𝛼1 +

1−𝐴2

𝐴1+2𝛼1𝐴2+exp 𝐴1+2𝛼1𝐴2 𝑇 𝐴2

𝐴1+2𝛼1𝐴2− 1𝛼1

exp − 𝐴1+2𝛼1𝐴2 𝑡

= 𝛼1 + 1−𝐴2

𝐴1+2𝛼1𝐴2+exp 𝐴1+2𝛼1𝐴2 𝑇−𝑡 𝐴2

𝐴1+2𝛼1𝐴2− 1𝛼1

= 𝛼1 + 𝛼1 𝐴1+2𝛼1𝐴2−𝛼1𝐴2+exp 𝐴1+2𝛼1𝐴2 𝑇−𝑡 𝛼1𝐴2−𝐴1−2𝛼1𝐴2

52

Page 53: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

𝛼 Solution (2)

𝛼 = 𝛼1 + 𝛼1 𝐴1+2𝛼1𝐴2−𝛼1𝐴2+exp 𝐴1+2𝛼1𝐴2 𝑇−𝑡 −𝐴1−𝛼1𝐴2

= 𝛼1 1 − 𝐴1+2𝛼1𝐴2𝐴2+exp 𝐴1+2𝛼1𝐴2 𝑇−𝑡 𝐴1

𝛼1+𝐴2

= 𝛼1 1 −𝐴1𝐴2+2𝛼1

1+ 𝐴1𝛼1𝐴2

+1 exp 𝐴1+2𝛼1𝐴2 𝑇−𝑡

53

Page 54: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

𝛼 Solution (3)

𝛼 𝑑 = 𝑘2𝜂2

1 − 1 − 𝛾 + 2 1−𝛾

1+ 1− 21− 1−𝛾 exp 2𝑘

1−𝛾 𝑇−𝑡

54

Page 55: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Solving 𝑥 𝑥𝑡 = 𝑘 − 2𝜂2𝛼 − 2𝜆𝑘 + 4𝜆𝜂2𝛼 𝑥 + 4𝜆𝑘𝜃𝛼 − 2 𝜆

𝜂2𝑘2𝜃 − 2𝛼𝑘𝜃

Let 𝜏 = 𝑇 − 𝑑 �̂� 𝜏 = 𝑥 𝑇 − 𝑑 �̂�𝜏 𝜏 = −𝑥𝑡 𝜏 −�̂�𝜏 𝜏 = 𝑥𝑡 𝜏 = 𝑘 − 2𝜂2𝛼 𝜏 − 2𝜆𝑘 + 4𝜆𝜂2𝛼 𝜏 𝑥 𝜏 +

4𝜆𝑘𝜃𝛼 𝜏 − 2 𝜆𝜂2𝑘2𝜃 − 2𝛼 𝜏 𝑘𝜃

�̂�𝜏 𝜏 =−𝑘 + 2𝜂2𝛼� + 2𝜆𝑘 − 4𝜆𝜂2𝛼� �̂� + −4𝜆𝑘𝜃𝛼� + 2 𝜆

𝜂2𝑘2𝜃 + 2𝛼�𝑘𝜃

�̂�𝜏 𝜏 =2𝜆 − 1 𝑘 + 2𝜂2𝛼� 1 − 2𝜆 �̂� + 2𝛼�𝑘𝜃 1 − 2𝜆 + 2 𝜆

𝜂2𝑘2𝜃

55

Page 56: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

First Order Non-Constant Coefficients �̂�𝜏 = 𝐵1�̂� + 𝐵2 𝐵1 𝜏 = 2𝜆 − 1 𝑘 + 2𝜂2𝛼� 1 − 2𝜆

𝐵2 𝜏 = 2𝛼�𝑘𝜃 1 − 2𝜆 + 2 𝜆𝜂2𝑘2𝜃

56

Page 57: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Integrating Factor (1) �̂�𝜏 − 𝐵1�̂� = 𝐵2 We try to find an integrating factor 𝜇 = 𝜇 𝜏 s.t.

𝑑𝑑𝜏

𝜇�̂� = 𝜇 𝑑𝛽�

𝑑𝜏+ �̂� 𝑑𝜇

𝑑𝜏= 𝜇𝐵2

Divide LHS and RHS by 𝜇�̂�.

1𝛽�𝑑𝛽�

𝑑𝜏+ 1

𝜇𝑑𝜇𝑑𝜏

= 𝐵2𝛽�

By comparison, −𝐵1 = 1

𝜇𝑑𝜇𝑑𝜏

57

Page 58: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Integrating Factor (2)

∫−𝐵1𝑑𝜏 = ∫ 𝑑𝜇𝜇

= log 𝜇 + 𝐶

𝜇 = exp ∫−𝐵1𝑑𝜏

𝜇�̂� = ∫𝜇𝐵2𝑑𝜏 + 𝐶

�̂� = ∫ 𝜇𝐵2𝑑𝜏+𝐶𝜇

�̂� = ∫ exp ∫ −𝐵1𝑑𝑢 𝐵2𝑑𝜏+𝐶exp ∫ −𝐵1𝑑𝜏

58

Page 59: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

�̂� Solution

�̂� = ∫ exp ∫ −𝐵1 𝑢 𝑑𝑢𝜏0 𝐵2 𝑠 𝑑𝑠𝜏

0exp ∫ −𝐵1 𝑢 𝑑𝑢𝜏

0+ 𝐶

�̂� 𝜏 =exp ∫ 𝐵1 𝑢 𝑑𝑢𝜏

0 ∫ exp ∫ −𝐵1 𝑢 𝑑𝑢𝑠0 𝐵2 𝑠 𝑑𝑠𝜏

0 + 𝐶

59

Page 60: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

𝐵1, 𝐵2 ∫ 𝐵1 𝑠 𝑑𝑠

𝜏0 = ∫ 2𝜆 − 1 𝑘 + 2𝜂2 1 − 2𝜆 𝛼 𝑠 𝑑𝑠𝜏

0

𝐼2 = ∫ exp ∫ −𝐵1 𝑢 𝑑𝑢𝑠0 𝐵2 𝑠 𝑑𝑠𝜏

0

60

Page 61: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

𝑥 Solution

𝑥 𝑑 = 𝑘𝜃𝜂2

1 + 1 − 𝛾exp 2𝑘

1−𝛾 𝑇−𝑡 −1

1+ 1− 21− 1−𝛾 exp 2𝑘

1−𝛾 𝑇−𝑡

61

Page 62: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Solving 𝑔 𝑔𝑡 =𝑔 −𝑘𝑥𝜃 − 1

2𝜂2𝑥2 − 𝜂2𝛼 + 𝜆

𝜂2𝑘2𝜃2 + 𝜆𝜂2𝑥2 + 2𝜆𝑘𝑥𝜃

With𝛼 and 𝑥 solved, we are now ready to solve 𝑔𝑡. 𝑔𝑡𝑔

= 𝐺 𝑑

𝑑𝑑𝑠

log𝑔𝑡 = 𝑔𝑡𝑔

= 𝐺

log𝑔𝑡 = ∫𝐺𝑑𝑠 + 𝐶

𝑔𝑡 = 𝐶exp ∫𝐺𝑑𝑑 = exp −∫ 𝐺𝑑𝑠𝑇0 exp ∫ 𝐺𝑑𝑠𝑡

0

𝑔𝑡 = exp −∫ 𝐺𝑑𝑠𝑇𝑡

62

Page 63: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Computing the Optimal Position

ℎ 𝑑 ∗ = −𝐺𝑉 𝑘 𝜃−𝜕𝑡 +𝐺𝑉𝑉𝜂2

𝐺𝑉𝑉𝜂2

= −𝛾𝑉𝛾−1𝜕 𝑘 𝜃−𝜕𝑡 +𝛾𝑉𝛾−1𝜕𝑉𝜂2

𝛾 𝛾−1 𝑉𝛾−2𝜕𝜂2

= −𝑉𝜕 𝑘 𝜃−𝜕𝑡 +𝑉𝜕𝑉𝜂2

𝛾−1 𝜕𝜂2

= − 𝑉𝛾−1 𝜂2

𝜕 𝑘 𝜃−𝜕𝑡 +𝜕𝑉𝜂2

𝜕

= − 𝑉𝛾−1 𝜂2

𝑘 𝜃 − 𝑥𝑡 + 𝜕𝑉𝜕𝜂2

= 𝑉1−𝛾 𝜂2

𝑘 𝜃 − 𝑥𝑡 + 𝜂2 𝑥 + 2𝛼𝑥

= 𝑉1−𝛾

− 𝑘𝜂2

𝑥𝑡 − 𝜃 + 2𝛼𝑥 + 𝑥

63

Page 64: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

The Optimal Position

ℎ 𝑑 ∗ = 𝑉𝑡1−𝛾

− 𝑘𝜂2

𝑥𝑡 − 𝜃 + 2𝛼 𝑑 𝑥𝑡 + 𝑥 𝑑

ℎ 𝑑 ∗~ − 𝑘𝜂2

𝑥𝑡 − 𝜃

64

Page 65: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

P&L for Simulated Data

The portfolio increases from $1000 to $4625 in one year.

65

Page 66: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Parameter Estimation Can be done using Maximum Likelihood. Evaluation of parameter sensitivity can be done by

Monte Carlo simulation. In real trading, it is better to be conservative about the

parameters. Better underestimate the mean-reverting speed Better overestimate the noise

To account for parameter regime changes, we can use: a hidden Markov chain model moving calibration window

66

Page 67: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Trend Following Trading

67

Page 68: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Two-State Markov Model

68

𝑑𝑆𝑟 = 𝑆𝑟 𝜇 𝛼𝑟 𝑑𝑟 + 𝜎𝑑𝐵𝑟

𝛼𝑟 = 0 DOWN TREND

𝛼𝑟 = 1 UP TREND q p

1-q

1-p

Page 69: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Buying and Selling Decisions

69

𝑑 ≤ 𝜏10 ≤ 𝜈10 ≤ 𝜏20 ≤ 𝜈20 ≤ ⋯ ≤ 𝜏𝑛0 ≤ 𝜈𝑛0 ≤ ⋯ ≤ 𝑇

Page 70: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Optimal Trend Following Strategy

70

Page 71: Optimal Trading Strategies Stochastic Controlnumericalmethod.com/papers/course2/lecture5.pdf · Optimal Trading Strategies . Stochastic Control . Haksun Li . haksun.li@numericalmethod.com

Trading SSE 2001 – 2011

71