Trading Basket Construction Mean Reversion...
Transcript of Trading Basket Construction Mean Reversion...
![Page 1: Trading Basket Construction Mean Reversion Tradingnumericalmethod.com/papers/course2/lecture3.pdfTrading Basket Construction Mean Reversion Trading Haksun Li haksun.li@numericalmethod.com](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/1.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/2.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/3.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/4.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/5.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/6.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/7.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/8.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/9.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/10.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/11.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/12.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/13.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/14.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/15.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/16.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/17.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/18.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/19.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/20.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/21.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/22.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/23.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/24.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/25.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/26.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/27.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/28.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/29.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/30.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/31.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/32.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/33.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/34.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/35.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/36.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/37.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/38.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/39.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/40.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/41.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/42.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/43.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/44.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/45.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/46.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/47.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/48.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/49.jpg)
π½ 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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/50.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/51.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/52.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/53.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/54.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/55.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/56.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/57.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/58.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/59.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/60.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/61.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/62.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/63.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/64.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/65.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/66.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/67.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/68.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/69.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/70.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/71.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/72.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/73.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/74.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/75.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/76.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/77.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/78.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/79.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/80.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/81.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/82.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/83.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/84.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/85.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/86.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/87.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/88.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/89.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/90.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/91.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/92.jpg)
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](https://reader031.fdocuments.us/reader031/viewer/2022022006/5ac2c5857f8b9a1c768e6739/html5/thumbnails/93.jpg)
Results (3)
93