trading basket construction mean reversion...

93
Trading Basket Construction Mean Reversion Trading Haksun Li [email protected] www.numericalmethod.com

Upload: vandiep

Post on 03-Apr-2018

227 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Trading Basket Construction

Mean Reversion Trading

Haksun Li [email protected]

www.numericalmethod.com

Page 2: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading 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: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

References Pairs Trading: A Cointegration Approach. Arlen David

Schmidt. University of Sydney. Finance Honours Thesis. November 2008.

Likelihood-Based Inference in Cointegrated Vector Autoregressive Models. Soren Johansen. Oxford University Press, USA. February 1, 1996.

Pairs Trading. Elliot, van der Hoek, and Malcolm. 2005. Identifying Small Mean Reverting Portfolios. A.

d'Aspremont. 2008. High-frequency Trading. Stanford University. Jonathan

Chiu, Daniel Wijaya Lukman, Kourosh Modarresi, Avinayan Senthi Velayutham. 2011.

3

Page 4: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Paris Trading

4

Page 5: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Pairs Trading Intuition: The thousands of market instruments are

not independent. For two closely related assets, they tend to β€œmove together” (common trend). We want to buy the cheap one and sell the expensive one. Exploit short term deviation from long term equilibrium.

Definition: trade one asset (or basket) against another asset (or basket) Long one and short the other

Try to make money from β€œspread”.

5

Page 6: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

FOMC announcements

6

Rate cut! Bonds react. FX react. Stocks react. All act!

Page 7: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

GLD vs. SLV

7

Page 8: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Hows

8

How to construct a pair? How to trade a pair?

Page 9: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Sample Pairs Trading Strategy

9

Page 10: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Spread 𝑍 = 𝑋 βˆ’ π›½π‘Œ 𝛽 hedge ratio Cointegration coefficient

How do you trade spread? How much X to buy/sell? How much Y to buy/sell?

10

Page 11: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Log-Spread

11

𝑍 = log𝑋 βˆ’ 𝛽 logπ‘Œ How do you trade log-spread? How much X to buy/sell? How much Y to buy/sell?

Page 12: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Dollar Neutral Hedge Suppose ES (S&P500 E-mini future) is at 1220 and each

point worth $50, its dollar value is about $61,000. Suppose NQ (Nasdaq 100 E-mini future) is at 1634 and each point worth $20, its dollar value is $32,680.

𝛽 = 6100032680

= 1.87.

𝑍 = 𝐸𝐸 βˆ’ 1.87 Γ— 𝑁𝑁 Buy Z = Buy 10 ES contracts and Sell 19 NQ contracts. Sell Z = Sell 10 ES contracts and Buy 19 NQ contracts.

12

Page 13: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Market Neutral Hedge Suppose ES has a market beta of 1.25, NQ 1.11.

We use 𝛽 = 1.251.11

= 1.13

13

Page 14: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Dynamic Hedge 𝛽 changes with time, covariance, market conditions,

etc. Periodic recalibration.

14

Page 15: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Distance Method The distance between two time series: 𝑑 = βˆ‘ π‘₯𝑖 βˆ’ 𝑦𝑗

2

π‘₯𝑖, 𝑦𝑗 are the normalized prices. We choose a pair of stocks among a collection with the

smallest distance, 𝑑.

15

Page 16: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Distance Trading Strategy Sell Z if Z is too expensive. Buy Z if Z is too cheap. How do we do the evaluation?

16

Page 17: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Z Transform We normalize Z. The normalized value is called z-score.

𝑧 = π‘₯βˆ’οΏ½Μ…οΏ½πœŽπ‘₯

Other forms:

𝑧 = π‘₯βˆ’π‘€Γ—οΏ½Μ…οΏ½π‘†Γ—πœŽπ‘₯

M, S are proprietary functions for forecasting.

17

Page 18: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

A Very Simple Distance Pairs Trading Sell Z when z > 2 (standard deviations). Sell 10 ES contracts and Buy 19 NQ contracts.

Buy Z when z < -2 (standard deviations). Buy 10 ES contracts and Sell 19 NQ contracts.

18

Page 19: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Pros of the Distance Model Model free. No mis-specification. No mis-estimation. Distance measure intuitively captures the Law of One

Price (LOP) idea.

19

Page 20: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Cons of the Distance Model There is no reason why the model will work (or not).

There is no assumption to check against the current market conditions.

The model is difficult to analyze mathematically. Cannot predict the convergence time (expected holding

time). The model ignores the dynamic nature of the spread

process, essentially treating the spread as i.i.d. Using more strict criterions may work for equities. In

FX trading, we don’t have the luxury of throwing away many pairs.

20

Page 21: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Risks in Pairs Trading Long term equilibrium does not hold. E.g., the company that you long goes bankrupt but the

other leg does not move (one company wins over the other). Systematic market risk. Firm specific risk. Liquidity.

21

Page 22: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Cointegration

22

Page 23: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Stationarity These ad-hoc 𝛽calibration does not guarantee the

single most important statistical property in trading: stationarity.

Strong stationarity: the joint probability distribution of π‘₯𝑑 does not change over time.

Weak stationarity: the first and second moments do not change over time. Covariance stationarity

23

Page 24: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Mean Reversion

24

A stationary stochastic process is mean-reverting. Long when the spread/portfolio/basket falls

sufficiently below a long term equilibrium. Short when the spread/portfolio/basket rises

sufficiently above a long term equilibrium.

Page 25: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Test for Stationarity An augmented Dickey–Fuller test (ADF) is a test for a unit

root in a time series sample. It is an augmented version of the Dickey–Fuller test for a

larger and more complicated set of time series models. Intuition: if the series 𝑦𝑑 is stationary, then it has a tendency to return to a

constant mean. Therefore large values will tend to be followed by smaller values, and small values by larger values. Accordingly, the level of the series will be a significant predictor of next period's change, and will have a negative coefficient.

If, on the other hand, the series is integrated, then positive changes and negative changes will occur with probabilities that do not depend on the current level of the series.

In a random walk, where you are now does not affect which way you will go next.

25

Page 26: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

ADF Math Δ𝑦𝑑 = 𝛼 + 𝛽𝛽 + π›Ύπ‘¦π‘‘βˆ’1 + βˆ‘ Ξ”π‘¦π‘‘βˆ’π‘–

π‘βˆ’1𝑖=1 + πœ–π‘‘

Null hypothesis 𝐻0: 𝛾 = 0. (𝑦𝑑 non-stationary) 𝛼 = 0,𝛽 = 0 models a random walk. 𝛽 = 0 models a random walk with drift.

Test statistics = π›ΎοΏ½πœŽ 𝛾�

, the more negative, the more reason to reject 𝐻0 (hence 𝑦𝑑 stationary).

SuanShu: AugmentedDickeyFuller.java

26

Page 27: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Cointegration Cointegration: select a linear combination of assets to

construct an (approximately) stationary portfolio.

27

Page 28: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Objective Given two I(1) price series, we want to find a linear

combination such that: 𝑧𝑑 = π‘₯𝑑 βˆ’ 𝛽𝑦𝑑 = πœ‡ + πœ€π‘‘

πœ€π‘‘ is I(0), a stationary residue. πœ‡ is the long term equilibrium. Long when 𝑧𝑑 < πœ‡ βˆ’ Ξ”. Sell when 𝑧𝑑 > πœ‡ + Ξ”.

28

Page 29: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Stocks from the Same Industry Reduce market risk, esp., in bear market. Stocks from the same industry are likely to be subject to the

same systematic risk. Give some theoretical unpinning to the pairs trading. Stocks from the same industry are likely to be driven by the

same fundamental factors (common trends).

29

Page 30: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Cointegration Definition 𝑋𝑑~CI 𝑑, 𝑏 if All components of 𝑋𝑑 are integrated of same order 𝑑. There exists a 𝛽𝑑 such that the linear combination, 𝛽𝑑𝑋𝑑 = 𝛽1𝑋1𝑑 + 𝛽2𝑋2𝑑 + β‹―+ 𝛽𝑛𝑋𝑛𝑑, is integrated of order 𝑑 βˆ’ 𝑏 ,𝑏 > 0.

𝛽 is the cointegrating vector, not unique.

30

Page 31: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Illustration for Trading Suppose we have two assets, both reasonably I(1), we

want to find 𝛽 such that 𝑍 = 𝑋 + π›½π‘Œ is I(0), i.e., stationary.

In this case, we have 𝑑 = 1, 𝑏 = 1.

31

Page 32: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

A Simple VAR Example 𝑦𝑑 = π‘Ž11π‘¦π‘‘βˆ’1 + π‘Ž12π‘§π‘‘βˆ’1 + πœ€π‘¦π‘‘ 𝑧𝑑 = π‘Ž21π‘¦π‘‘βˆ’1 + π‘Ž22π‘§π‘‘βˆ’1 + πœ€π‘§π‘‘ Theorem 4.2, Johansen, places certain restrictions on

the coefficients for the VAR to be cointegrated. The roots of the characteristics equation lie on or outside

the unit disc.

32

Page 33: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Coefficient Restrictions

π‘Ž11 = 1βˆ’π‘Ž22 βˆ’π‘Ž12π‘Ž211βˆ’π‘Ž22

π‘Ž22 > βˆ’1 π‘Ž12π‘Ž21 + π‘Ž22 < 1

33

Page 34: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

VECM (1) Taking differences 𝑦𝑑 βˆ’ π‘¦π‘‘βˆ’1 = π‘Ž11 βˆ’ 1 π‘¦π‘‘βˆ’1 + π‘Ž12π‘§π‘‘βˆ’1 + πœ€π‘¦π‘‘ 𝑧𝑑 βˆ’ π‘§π‘‘βˆ’1 = π‘Ž21π‘¦π‘‘βˆ’1 + π‘Ž22 βˆ’ 1 π‘§π‘‘βˆ’1 + πœ€π‘§π‘‘

Δ𝑦𝑑Δ𝑧𝑑

= π‘Ž11 βˆ’ 1 π‘Ž12π‘Ž21 π‘Ž22 βˆ’ 1

π‘¦π‘‘βˆ’1π‘§π‘‘βˆ’1 +

πœ€π‘¦π‘‘πœ€π‘§π‘‘

Substitution of π‘Ž11

Δ𝑦𝑑Δ𝑧𝑑

=βˆ’π‘Ž12π‘Ž211βˆ’π‘Ž22

π‘Ž12π‘Ž21 π‘Ž22 βˆ’ 1

π‘¦π‘‘βˆ’1π‘§π‘‘βˆ’1 +

πœ€π‘¦π‘‘πœ€π‘§π‘‘

34

Page 35: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

VECM (2) Δ𝑦𝑑 = 𝛼𝑦 π‘¦π‘‘βˆ’1 βˆ’ π›½π‘§π‘‘βˆ’1 + πœ–π‘¦π‘‘ Δ𝑧𝑑 = 𝛼𝑧 π‘¦π‘‘βˆ’1 βˆ’ π›½π‘§π‘‘βˆ’1 + πœ–π‘§π‘‘ 𝛼𝑦 = βˆ’π‘Ž12π‘Ž21

1βˆ’π‘Ž22

𝛼𝑧 = π‘Ž21

𝛽 = 1βˆ’π‘Ž22π‘Ž21

, the cointegrating coefficient

π‘¦π‘‘βˆ’1 βˆ’ π›½π‘§π‘‘βˆ’1 is the long run equilibrium, I(0). 𝛼𝑦, 𝛼𝑧 are the speed of adjustment parameters.

35

Page 36: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Interpretation Suppose the long run equilibrium is 0, Δ𝑦𝑑, Δ𝑧𝑑 responds only to shocks.

Suppose 𝛼𝑦 < 0, 𝛼𝑧 > 0, 𝑦𝑑 decreases in response to a +ve deviation. 𝑧𝑑 increases in response to a +ve deviation.

36

Page 37: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Granger Representation Theorem If 𝑋𝑑 is cointegrated, an VECM form exists. The increments can be expressed as a functions of the

dis-equilibrium, and the lagged increments. Δ𝑋𝑑 = π›Όπ›½β€²π‘‹π‘‘βˆ’1 + βˆ‘π‘π‘‘Ξ”π‘‹π‘‘βˆ’1 + πœ€π‘‘ In our simple example, we have

Δ𝑦𝑑Δ𝑧𝑑

=𝛼𝑦𝛼𝑧

1 βˆ’π›½π‘¦π‘‘βˆ’1π‘§π‘‘βˆ’1 +

πœ€π‘¦π‘‘πœ€π‘§π‘‘

37

Page 38: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Granger Causality 𝑧𝑑 does not Granger Cause 𝑦𝑑 if lagged values of Ξ”π‘§π‘‘βˆ’π‘– do not enter the Δ𝑦𝑑 equation.

𝑦𝑑 does not Granger Cause 𝑧𝑑 if lagged values of Ξ”π‘¦π‘‘βˆ’π‘– do not enter the Δ𝑧𝑑 equation.

38

Page 39: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Engle-Granger Two Step Approach Estimate either 𝑦𝑑 = 𝛽10 + 𝛽11𝑧𝑑 + 𝑒1𝑑 𝑧𝑑 = 𝛽20 + 𝛽21𝑦𝑑 + 𝑒2𝑑 As the sample size increase indefinitely, asymptotically a

test for a unit root in 𝑒1𝑑 and 𝑒2𝑑 are equivalent, but not for small sample sizes.

Test for unit root using ADF on either 𝑒1𝑑 and 𝑒2𝑑 . If 𝑦𝑑 and 𝑧𝑑 are cointegrated, 𝛽 super converges.

39

Page 40: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Engle-Granger Pros and Cons Pros: simple

Cons: This approach is subject to twice the estimation errors. Any

errors introduced in the first step carry over to the second step.

Work only for two I(1) time series.

40

Page 41: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Testing for Cointegration Note that in the VECM, the rows in the coefficient, Ξ ,

are NOT linearly independent.

Δ𝑦𝑑Δ𝑧𝑑

=βˆ’π‘Ž12π‘Ž211βˆ’π‘Ž22

π‘Ž12π‘Ž21 π‘Ž22 βˆ’ 1

π‘¦π‘‘βˆ’1π‘§π‘‘βˆ’1 +

πœ€π‘¦π‘‘πœ€π‘§π‘‘

βˆ’π‘Ž12π‘Ž211βˆ’π‘Ž22

π‘Ž12 Γ— βˆ’ 1βˆ’π‘Ž22π‘Ž12

= π‘Ž21 π‘Ž22 βˆ’ 1

The rank of Ξ  determine whether the two assets 𝑦𝑑 and 𝑧𝑑 are cointegrated.

41

Page 42: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

VAR & VECM In general, we can write convert a VAR to an VECM. VAR (from numerical estimation by, e.g., OLS): 𝑋𝑑 = βˆ‘ π΄π‘–π‘‹π‘‘βˆ’π‘– + πœ€π‘‘

𝑝𝑖=1

Transitory form of VECM (reduced form) Δ𝑋𝑑 = Ξ π‘‹π‘‘βˆ’1 + βˆ‘ Ξ“π‘–Ξ”π‘‹π‘‘βˆ’π‘– + πœ€π‘‘

π‘βˆ’1𝑖=1

Long run form of VECM Δ𝑋𝑑 = βˆ‘ Ξ₯π‘–Ξ”π‘‹π‘‘βˆ’π‘–

π‘βˆ’1𝑖=1 + Ξ π‘‹π‘‘βˆ’π‘ + πœ€π‘‘

42

Page 43: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

The Ξ  Matrix Rank(Ξ ) = n, full rank The system is already stationary; a standard VAR model in

levels. Rank(Ξ ) = 0 There exists NO cointegrating relations among the time

series. 0 < Rank(Ξ ) < n Ξ  = 𝛼𝛽′ 𝛽 is the cointegrating vector 𝛼 is the speed of adjustment.

43

Page 44: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Rank Determination Determining the rank of Ξ  is amount to determining

the number of non-zero eigenvalues of Ξ . Ξ  is usually obtained from (numerical VAR) estimation. Eigenvalues are computed using a numerical procedure.

44

Page 45: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Trace Statistics Suppose the eigenvalues of Ξ  are:πœ†1 > πœ†2 > β‹― > πœ†π‘›. For the 0 eigenvalues, ln 1 βˆ’ πœ†π‘– = 0. For the (big) non-zero eigenvalues, ln 1 βˆ’ πœ†π‘– is (very

negative). The likelihood ratio test statistics 𝑁 𝐻 π‘Ÿ |𝐻 𝑛 = βˆ’π‘‡βˆ‘ log 1 βˆ’ πœ†π‘–

𝑝𝑖=π‘Ÿ+1

H0: rank ≀ r; there are at most r cointegrating Ξ².

45

Page 46: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Test Procedure int r = 0;//rank for (; r <= n; ++r) { // loop until the null is accepted compute Q = 𝑁 𝐻 π‘Ÿ |𝐻 𝑛 ; If (Q > c.v.) { // compare against a critical value

break; // fail to reject the null hypothesis; rank found }

} r is the rank found

46

Page 47: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Decomposing Ξ  Suppose the rank of Ξ  = π‘Ÿ. Ξ  = 𝛼𝛽′. Ξ  is 𝑛 Γ— 𝑛. 𝛼 is 𝑛 Γ— π‘Ÿ. 𝛽′is r Γ— 𝑛.

47

Page 48: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Estimating 𝛽 𝛽 can estimated by maximizing the log-likelihood

function in Chapter 6, Johansen. logL Ξ¨,𝛼,𝛽,Ξ©

Theorem 6.1, Johansen: 𝛽 is found by solving the following eigenvalue problem: πœ†πΈ11 βˆ’ 𝐸10𝐸00βˆ’1𝐸01 = 0

48

Page 49: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

𝛽 Each non-zero eigenvalue Ξ» corresponds to a

cointegrating vector, which is its eigenvector. 𝛽 = 𝑣1, 𝑣2,β‹― , π‘£π‘Ÿ 𝛽 spans the cointegrating space. For two cointegrating asset, there are only one 𝛽 (𝑣1)

so it is unequivocal. When there are multiple 𝛽, we need to add economic

restrictions to identify 𝛽.

49

Page 50: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Trading the Pairs Given a space of (liquid) assets, we compute the

pairwise cointegrating relationships. For each pair, we validate stationarity by performing

the ADF test. For the strongly mean-reverting pairs, we can design

trading strategies around them.

50

Page 51: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Problems with Using Cointegration

51

The assets may be cointegrated sometimes but not always. What do you do when it is not cointegrated but you are

already in the market? Cointegration creates a dense basket – it includes

every asset in the time series analyzed. Incur huge transaction cost. Reduce the significance of the structural relationships.

Optimal mean reverting portfolios behave like noise and vary well inside the bid-ask spreads, hence not meaningful statistical arbitrage opportunities. What about not so optimal ones?

Page 52: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Stochastic Spread

52

Page 53: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Ornstein–Uhlenbeck Process

53

𝑧𝑑 = π‘₯𝑑 βˆ’ 𝛽𝑦𝑑 𝑑𝑧𝑑 = πœƒ πœ‡ βˆ’ 𝑧𝑑 𝑑𝛽 + πœŽπ‘‘π‘Šπ‘‘

Page 54: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Spread as a Mean-Reverting Process π‘₯π‘˜ βˆ’ π‘₯π‘˜βˆ’1 = π‘Ž βˆ’ 𝑏π‘₯π‘˜βˆ’1 𝜏 + 𝜎 πœπœ€π‘˜ = 𝑏 π‘Ž

π‘βˆ’ π‘₯π‘˜βˆ’1 𝜏 + 𝜎 πœπœ€π‘˜

The long term mean = π‘Žπ‘.

The rate of mean reversion = 𝑏.

54

Page 55: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Sum of Power Series We note that

= βˆ‘ π‘Žπ‘–π‘˜βˆ’1𝑖=0 = π‘Žπ‘˜βˆ’1

π‘Žβˆ’1

55

Page 56: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Unconditional Mean 𝐸 π‘₯π‘˜ = πœ‡π‘˜ = πœ‡π‘˜βˆ’1 + π‘Ž βˆ’ π‘πœ‡π‘˜βˆ’1 𝜏 = π‘Žπœ + 1 βˆ’ π‘πœ πœ‡π‘˜βˆ’1 = π‘Žπœ + 1 βˆ’ π‘πœ π‘Žπœ + 1 βˆ’ π‘πœ πœ‡π‘˜βˆ’2 = π‘Žπœ + 1 βˆ’ π‘πœ π‘Žπœ + 1 βˆ’ π‘πœ 2πœ‡π‘˜βˆ’2 = βˆ‘ 1 βˆ’ π‘πœ π‘–π‘˜βˆ’1

𝑖=0 π‘Žπœ + 1 βˆ’ π‘πœ π‘˜πœ‡0

= π‘Žπœ 1βˆ’ 1βˆ’π‘πœ π‘˜

1βˆ’ 1βˆ’π‘πœ+ 1 βˆ’ π‘πœ π‘˜πœ‡0

= π‘Žπœ 1βˆ’ 1βˆ’π‘πœ π‘˜

π‘πœ+ 1 βˆ’ π‘πœ π‘˜πœ‡0

= π‘Žπ‘βˆ’ π‘Ž

𝑏1 βˆ’ π‘πœ π‘˜ + 1 βˆ’ π‘πœ π‘˜πœ‡0

56

Page 57: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Long Term Mean π‘Žπ‘βˆ’ π‘Ž

𝑏1 βˆ’ π‘πœ π‘˜ + 1 βˆ’ π‘πœ π‘˜πœ‡0

β†’ π‘Žπ‘

57

Page 58: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Unconditional Variance Var π‘₯π‘˜ = πœŽπ‘˜2 = 1 βˆ’ π‘πœ 2πœŽπ‘˜βˆ’12 + 𝜎2𝜏 = 1 βˆ’ π‘πœ 2πœŽπ‘˜βˆ’12 + 𝜎2𝜏 = 1 βˆ’ π‘πœ 2 1 βˆ’ π‘πœ 2πœŽπ‘˜βˆ’22 + 𝜎2𝜏 + 𝜎2𝜏 = 𝜎2𝜏 βˆ‘ 1 βˆ’ π‘πœ 2π‘–π‘˜βˆ’1

𝑖=0 + 1 βˆ’ π‘πœ 2π‘˜ 𝜎02

= 𝜎2𝜏 1βˆ’ 1βˆ’π‘πœ 2π‘˜

1βˆ’ 1βˆ’π‘πœ 2 + 1 βˆ’ π‘πœ 2π‘˜ 𝜎02

58

Page 59: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Long Term Variance

𝜎2𝜏 1βˆ’ 1βˆ’π‘πœ 2π‘˜

1βˆ’ 1βˆ’π‘πœ 2 + 1 βˆ’ π‘πœ 2π‘˜ 𝜎02

β†’ 𝜎2𝜏1βˆ’ 1βˆ’π‘πœ 2

59

Page 60: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Observations and Hidden State Process The hidden state process is: π‘₯π‘˜ = π‘₯π‘˜βˆ’1 + π‘Ž βˆ’ 𝑏π‘₯π‘˜βˆ’1 𝜏 + 𝜎 πœπœ€π‘˜ = π‘Žπœ + 1 βˆ’ π‘πœ π‘₯π‘˜βˆ’1 + 𝜎 πœπœ€π‘˜ = 𝐴 + 𝐡π‘₯π‘˜βˆ’1 + πΆπœ€π‘˜ 𝐴 β‰₯ 0, 0 < 𝐡 < 1

The observations: π‘¦π‘˜ = π‘₯π‘˜ + π·πœ”π‘˜

We want to compute the expected state from observations. π‘₯οΏ½π‘˜ = π‘₯οΏ½π‘˜|π‘˜ = 𝐸 π‘₯π‘˜|π‘Œπ‘˜

60

Page 61: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Parameter Estimation We need to estimate the parameters πœ— = 𝐴,𝐡,𝐢,𝐷

from the observable data before we can use the Kalman filter model.

We need to write down the likelihood function in terms of πœ—, and then maximize w.r.t. πœ—.

61

Page 62: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Likelihood Function A likelihood function (often simply the likelihood) is a

function of the parameters of a statistical model, defined as follows: the likelihood of a set of parameter values given some observed outcomes is equal to the probability of those observed outcomes given those parameter values.

𝐿 πœ—;π‘Œ = 𝑝 π‘Œ|πœ—

62

Page 63: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Maximum Likelihood Estimate We find πœ— such that 𝐿 πœ—;π‘Œ is maximized given the

observation.

63

Page 64: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Example Using the Normal Distribution We want to estimate the mean of a sample of size 𝑁 drawn from a Normal distribution.

𝑓 𝑦 = 12πœ‹πœŽ2

exp βˆ’ π‘¦βˆ’πœ‡ 2

2𝜎2

πœ— = πœ‡,𝜎

𝐿𝑁 πœ—;π‘Œ = ∏ 12πœ‹πœŽ2

exp βˆ’ π‘¦π‘–βˆ’πœ‡ 2

2𝜎2𝑁𝑖=1

64

Page 65: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Log-Likelihood

log 𝐿𝑁 πœ—;π‘Œ = βˆ‘ log 12πœ‹πœŽ2

βˆ’ π‘¦π‘–βˆ’πœ‡ 2

2𝜎2𝑁𝑖=1

Maximizing the log-likelihood is equivalent to maximizing the following. βˆ’βˆ‘ 𝑦𝑖 βˆ’ πœ‡ 2𝑁

𝑖=1 First order condition w.r.t.,πœ‡ πœ‡ = 1

π‘βˆ‘ 𝑦𝑖𝑁𝑖=1

65

Page 66: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Nelder-Mead After we write down the likelihood function for the

Kalman model in terms of πœ— = 𝐴,𝐡,𝐢,𝐷 , we can run any multivariate optimization algorithm, e.g., Nelder-Mead, to search for πœ—. maπ‘₯

πœ—πΏ πœ—;π‘Œ

The disadvantage is that it may not converge well, hence not landing close to the optimal solution.

66

Page 67: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Marginal Likelihood For the set of hidden states, 𝑋𝑑 , we write 𝐿 πœ—;π‘Œ = 𝑝 π‘Œ|πœ— = βˆ‘ 𝑝 π‘Œ,𝑋|πœ—π‘‹

Assume we know the conditional distribution of 𝑋, we could instead maximize the following. maπ‘₯

πœ—E𝑋𝐿 πœ—|π‘Œ,𝑋 , or

maπ‘₯πœ—

E𝑋

log 𝐿 πœ—|π‘Œ,𝑋

The expectation is a weighted sum of the (log-) likelihoods weighted by the probability of the hidden states.

67

Page 68: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

The Q-Function Where do we get the conditional distribution of 𝑋𝑑

from? Suppose we somehow have an (initial) estimation of

the parameters, πœ—0. Then the model has no unknowns. We can compute the distribution of 𝑋𝑑 .

𝑁 πœ—|πœ— 𝑑 = E𝑋|π‘Œ,πœ—

log 𝐿 πœ—|π‘Œ,𝑋

68

Page 69: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

EM Intuition Suppose we know πœ—, we know completely about the

mode; we can find 𝑋. Suppose we know 𝑋, we can estimate πœ—, by, e.g.,

maximum likelihood. What do we do if we don’t know both πœ— and 𝑋?

69

Page 70: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Expectation-Maximization Algorithm Expectation step (E-step): compute the expected value

of the log-likelihood function, w.r.t., the conditional distribution of 𝑋 under π‘Œand πœ—. 𝑁 πœ—|πœ— 𝑑 = E

𝑋|π‘Œ,πœ—log 𝐿 πœ—|π‘Œ,𝑋

Maximization step (M-step): find the parameters, πœ—, that maximize the Q-value. πœ— 𝑑+1 = argmax

πœ—π‘ πœ—|πœ— 𝑑

70

Page 71: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

EM Algorithms for Kalman Filter Offline: Shumway and Stoffer smoother approach,

1982 Online: Elliott and Krishnamurthy filter approach,

1999

71

Page 72: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

First Passage Time Standardized Ornstein-Uhlenbeck process 𝑑𝑍 𝛽 = βˆ’π‘ 𝛽 𝑑𝛽 + 2π‘‘π‘Š 𝛽

First passage time 𝑇0,𝑐 = inf 𝛽 β‰₯ 0,𝑍 𝛽 = 0|𝑍 0 = 𝑐

The pdf of 𝑇0,𝑐 has a maximum value at

οΏ½Μ‚οΏ½ = 12

ln 1 + 12

𝑐2 βˆ’ 3 2 + 4𝑐2 + 𝑐2 βˆ’ 3

72

Page 73: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

A Sample Trading Strategy π‘₯π‘˜ = π‘₯π‘˜βˆ’1 + π‘Ž βˆ’ 𝑏π‘₯π‘˜βˆ’1 𝜏 + 𝜎 πœπœ€π‘˜ 𝑑𝑋 𝛽 = π‘Ž βˆ’ 𝑏𝑋 𝛽 𝑑𝛽 + πœŽπ‘‘π‘Š 𝛽

𝑋 0 = πœ‡ + 𝑐 𝜎2𝜌

, 𝑋 𝑇 = πœ‡

𝑇 = 1πœŒοΏ½Μ‚οΏ½

Buy when π‘¦π‘˜ < πœ‡ βˆ’ 𝑐 𝜎2𝜌

unwind after time 𝑇

Sell when π‘¦π‘˜ > πœ‡ + 𝑐 𝜎2𝜌

unwind after time 𝑇

73

Page 74: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Kalman Filter The Kalman filter is an efficient recursive filter that

estimates the state of a dynamic system from a series of incomplete and noisy measurements.

74

Page 75: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Conceptual Diagram

prediction at time t Update at time t+1

as new measurements come in

correct for better estimation

75

Page 76: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

A Linear Discrete System π‘₯π‘˜ = πΉπ‘˜π‘₯π‘˜βˆ’1 + π΅π‘˜π‘’π‘˜ + πœ”π‘˜ πΉπ‘˜: the state transition model applied to the previous

state π΅π‘˜: the control-input model applied to control vectors πœ”π‘˜~𝑁 0,π‘π‘˜ : the noise process drawn from

multivariate Normal distribution

76

Page 77: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Observations and Noises π‘§π‘˜ = π»π‘˜π‘₯π‘˜ + π‘£π‘˜ π»π‘˜: the observation model mapping the true states to

observations π‘£π‘˜~𝑁 0,π‘…π‘˜ : the observation noise

77

Page 78: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Discrete System Diagram

78

Page 79: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Prediction predicted a prior state estimate π‘₯οΏ½π‘˜|π‘˜βˆ’1 = πΉπ‘˜π‘₯οΏ½π‘˜βˆ’1|π‘˜βˆ’1 + π΅π‘˜π‘’π‘˜

predicted a prior estimate covariance π‘ƒπ‘˜|π‘˜βˆ’1 = πΉπ‘˜π‘ƒπ‘˜βˆ’1|π‘˜βˆ’1πΉπ‘˜π‘‡ + π‘π‘˜

79

Page 80: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Update measurement residual π‘¦οΏ½π‘˜ = π‘§π‘˜ βˆ’ π»π‘˜π‘₯οΏ½π‘˜|π‘˜βˆ’1

residual covariance πΈπ‘˜ = π»π‘˜π‘ƒπ‘˜|π‘˜βˆ’1π»π‘˜π‘‡ + π‘…π‘˜

optimal Kalman gain πΎπ‘˜ = π‘ƒπ‘˜|π‘˜βˆ’1π»π‘˜π‘‡πΈπ‘˜βˆ’1

updated a posteriori state estimate π‘₯οΏ½π‘˜|π‘˜ = π‘₯οΏ½π‘˜|π‘˜βˆ’1 + πΎπ‘˜π‘¦οΏ½π‘˜

updated a posteriori estimate covariance π‘ƒπ‘˜|π‘˜ = 𝐼 βˆ’ πΎπ‘˜π»π‘˜ π‘ƒπ‘˜|π‘˜βˆ’1

80

Page 81: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Computing the β€˜Best’ State Estimate Given 𝐴, 𝐡, 𝐢, 𝐷, we define the conditional variance π‘…π‘˜ = Ξ£π‘˜|π‘˜ ≑ E π‘₯π‘˜ βˆ’ π‘₯οΏ½π‘˜ 2|π‘Œπ‘˜

Start with π‘₯οΏ½0|0 = 𝑦0, 𝑅0 = 𝐷2.

81

Page 82: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Predicted (a Priori) State Estimation π‘₯οΏ½π‘˜+1|π‘˜ = E π‘₯π‘˜+1|π‘Œπ‘˜ = E 𝐴 + 𝐡π‘₯π‘˜ + πΆπœ€π‘˜+1|π‘Œπ‘˜ = E 𝐴 + 𝐡π‘₯π‘˜|π‘Œπ‘˜ = 𝐴 + 𝐡 E π‘₯π‘˜|π‘Œπ‘˜ = 𝐴 + 𝐡π‘₯οΏ½π‘˜|π‘˜

82

Page 83: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Predicted (a Priori) Variance Ξ£π‘˜+1|π‘˜ = E π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1 2|π‘Œπ‘˜ = E 𝐴 + 𝐡π‘₯π‘˜ + πΆπœ€π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1 2|π‘Œπ‘˜

= E 𝐴 + 𝐡π‘₯π‘˜ + πΆπœ€π‘˜+1 βˆ’ 𝐴 βˆ’ 𝐡π‘₯οΏ½π‘˜|π‘˜2|π‘Œπ‘˜

= E 𝐡π‘₯π‘˜ βˆ’ 𝐡π‘₯οΏ½π‘˜|π‘˜ + πΆπœ€π‘˜+12|π‘Œπ‘˜

= E 𝐡π‘₯π‘˜ βˆ’ 𝐡π‘₯οΏ½π‘˜|π‘˜2 + 𝐢2πœ€2π‘˜+1|π‘Œπ‘˜

= 𝐡2Ξ£π‘˜|π‘˜ + 𝐢2

83

Page 84: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Minimize Posteriori Variance Let the Kalman updating formula be π‘₯οΏ½π‘˜+1 = π‘₯οΏ½π‘˜+1|π‘˜+1 = π‘₯οΏ½π‘˜+1|π‘˜ + 𝐾 π‘¦π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜

We want to solve for K such that the conditional variance is minimized. Ξ£π‘˜+1|π‘˜ = E π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1 2|π‘Œπ‘˜

84

Page 85: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Solve for K E π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1 2|π‘Œπ‘˜

= E π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜ βˆ’ 𝐾 π‘¦π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜2|π‘Œπ‘˜

= E π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜ βˆ’ 𝐾 π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜ + π·πœ”π‘˜+12|π‘Œπ‘˜

= E 1 βˆ’ 𝐾 π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜ βˆ’ πΎπ·πœ”π‘˜+12|π‘Œπ‘˜

= 1 βˆ’ 𝐾 2 E π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜2|π‘Œπ‘˜ + 𝐾2𝐷2

= 1 βˆ’ 𝐾 2 Ξ£π‘˜+1|π‘˜ + 𝐾2𝐷2

85

Page 86: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

First Order Condition for k

𝑑𝑑𝐾

1 βˆ’ 𝐾 2 Ξ£π‘˜+1|π‘˜ + 𝐾2𝐷2

= 𝑑𝑑𝐾

1 βˆ’ 2𝐾 + 𝐾2 Ξ£π‘˜+1|π‘˜ + 𝐾2𝐷2

= βˆ’2 + 2𝐾 Ξ£π‘˜+1|π‘˜ + 2𝐾𝐷2 = 0

86

Page 87: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Optimal Kalman Filter

πΎπ‘˜+1 = Ξ£π‘˜+1|π‘˜

Ξ£π‘˜+1|π‘˜+𝐷2

87

Page 88: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Updated (a Posteriori) State Estimation So, we have the β€œoptimal” Kalman updating rule. π‘₯οΏ½π‘˜+1 = π‘₯οΏ½π‘˜+1|π‘˜+1 = π‘₯οΏ½π‘˜+1|π‘˜ + 𝐾 π‘¦π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜

= π‘₯οΏ½π‘˜+1|π‘˜ + Ξ£π‘˜+1|π‘˜

Ξ£π‘˜+1|π‘˜+𝐷2π‘¦π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1|π‘˜

88

Page 89: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Updated (a Posteriori) Variance π‘…π‘˜+1 = Ξ£π‘˜+1|π‘˜ = E π‘₯π‘˜+1 βˆ’ π‘₯οΏ½π‘˜+1 2|π‘Œπ‘˜+1 = 1 βˆ’ 𝐾 2 Ξ£π‘˜+1|π‘˜ + 𝐾2𝐷2

= 1 βˆ’ Ξ£π‘˜+1|π‘˜

Ξ£π‘˜+1|π‘˜+𝐷2

2Ξ£π‘˜+1|π‘˜ + Ξ£π‘˜+1|π‘˜

Ξ£π‘˜+1|π‘˜+𝐷2

2𝐷2

= 𝐷2

Ξ£π‘˜+1|π‘˜+𝐷2

2Ξ£π‘˜+1|π‘˜ + Ξ£π‘˜+1|π‘˜

Ξ£π‘˜+1|π‘˜+𝐷2

2𝐷2

= 𝐷4Ξ£π‘˜+1|π‘˜+𝐷2Ξ£π‘˜+1|π‘˜2

Ξ£π‘˜+1|π‘˜+𝐷22

= 𝐷4Ξ£π‘˜+1|π‘˜+𝐷2Ξ£π‘˜+1|π‘˜2

Ξ£π‘˜+1|π‘˜+𝐷22

= Ξ£π‘˜+1|π‘˜π·2 𝐷2+Ξ£π‘˜+1|π‘˜π·2

Ξ£π‘˜+1|π‘˜+𝐷22

= Ξ£π‘˜+1|π‘˜π·2

89

Page 90: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

A Trading Algorithm From 𝑦0, 𝑦1, …, 𝑦𝑁, we estimate οΏ½Μ‚οΏ½ 𝑁 . Decide whether to make a trade at 𝛽 = 𝑁, unwind at 𝛽 = 𝑁 + 1, or some time later, e.g., 𝛽 = 𝑁 + 𝑇.

As 𝑦𝑁+1arrives, estimate οΏ½Μ‚οΏ½ 𝑁 + 1 . Repeat.

90

Page 91: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Results (1)

91

Page 92: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Results (2)

92

Page 93: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com

Results (3)

93