Chapter 2.ppt of macroeconomics by mankiw 9th edition
Β
Intro to Quant Trading Strategies (Lecture 7 of 10)
1. Introduction to Algorithmic Trading Strategies
Lecture 7
Small Mean Reverting Portfolio
Haksun Li
haksun.li@numericalmethod.com
www.numericalmethod.com
2. References
ο½ A dβAspremont. Identifying Small Mean Reverting
Portfolios. Stanford University. 2008.
ο½ Box, G. E. & Tiao, G. C. βA canonical analysis of
multiple time seriesβ, Biometrika 64(2), 355. 1977.
ο½ Dattorro, J. βExample 4.6.0.0.12, Semidefinite
programming," Convex Optimization & Euclidean
Distance Geometry. 2010.
ο½ Efron, B., Hastie, T., Johnstone, I., Tibshirani, R. Least
Angle Regression. The annuals of Statistics, Vol. 32,
No. 2, 407-499. 2004.
2
6. Shortcomings
6
ο½ Dense
ο½ Hard to execute; need to trade all assets all at the same
time.
ο½ Big transaction costs.
ο½ Hard to interpret the significance of the relationship.
ο½ Cointegration
ο½ It gives an βYesβ/βNoβ answer. Not sure what to do if the
cointegration relationship is not stable, especially after
entering a position.
7. As a Maximization Problem
7
ο½ Find the portfolio weights π₯π such that the portfolio
ππ‘ = β π₯π ππ‘π
π‘
π=1 is most mean reverting meaning that if
πππ‘ = π ποΏ½ β ππ‘ ππ + ππππ‘ then π is maximized.
ο½ Sparsity: no more than π non-zeros in x, trading at most k
assets.
ο½ Note that unlike cointegration, this approach always
give you a mean reverting portfolio and tells how mean
reverting it is.
8. VAR(1)
8
ο½ Assume that the prices follow a stationary VAR(1)
process.
ο½ ππ‘ = ππ‘β1 πΉ + ππ‘
ο½ ππ‘ is π 0, Ξ£
ο½ Canonical Analysis
ο½ π = 1
ο½ E ππ‘ = E ππ‘β1 πΉ + E ππ‘
ο½ ππ‘
2
= ππ‘β1
2
πΉ2 + Ξ£
9. Estimation of F
9
ο½ Regress ππ‘ on ππ‘β1.
ο½ πΉοΏ½ = ππ‘β1
β²
ππ‘β1
β1
ππ‘β1
β²
ππ‘
ο½ But this πΉοΏ½ is dense. It does not highlight the dependence
relationship between ππ‘ and ππ‘β1.
ο½ Sparse πΉοΏ½.
ο½ Penalized Least Squares estimation, column by
column.
ο½ ππ = argmin
π₯βπ π
πππ β ππ‘β1 π₯ 2 + πΎ π₯ 1
ο½ πΎ control the sparsity of π₯ and hence ππ and hence πΉοΏ½.
10. Least Absolute Shrinkage and Selection Operator
(LASSO)
10
ο½ It is an automatic model building problem, a factor/model
selection problem.
ο½ minβ ππ β β πππ π½π
π
π=1
2
+ π β π½π
π
π=1
π
π=1
ο½ Minimizing the L1 norm of π½ drives some π½π to zero.
ο½ Forward Stagewise Linear Regression
ο½ Pick the covariate xj1 with the biggest correlation with y.
ο½ Compute the residual π1 = π¦ β π½1 π₯ππ.
ο½ Pick the covariate xj2 with the biggest correlation with r1.
Compute the residual. Repeat this step until k covariates are
found.
ο½ Build a k-parameter linear model in the usual way, e.g., ordinary
least squares.
ο½ This is a greedy search that may eliminate useful covariate in the
2nd step.
11. Least Angle Regression (LARS) algorithm
11
ο½ Problem
ο½ min β ππ β β πππ π½π
π
π=1
2π
π=1 s.t., β π½π
π
π=1 β€ π‘
12. Covariance Selection
12
ο½ Covariance matrix represents relation between all
variables while inverse covariance shows the relation
of element with their neighbors.
ο½ Zeros in X corresponds to conditionally independent
variables, discovering structure in the model.
ο½ We want zeros in X to highlight the conditional
independence of the assets.
ο½ max π log det π β Tr Ξ£π β π Card π
ο½ π: the inverse covariance matrix
ο½ Solution: Graphical LASSO or LASSO.
13. Covariance Selection
Robust and sparse estimation of the covariance matrix
developed by Dempster (1972)
Maximum-likelihood penalized by the cardinality of X
ί³ ΰͺ±
12
)Card()(Trdetlogmax XXX
x
Οβββ
in the variable X ί³ Sn, where ΰͺ± is the sample covariance
matrix, Card(X) is the number of nonzero coefficients in X and
ΰ«>0 controls the trade-off between log-likelihood and sparsity
Hard to solve numerically. DβAspremont, Banerjee & El
Ghaoui (2006) replaces the penalty by the l1 norm
x
||)(Trdetlogmax
1,
β=
βββ
n
ji
ij
x
XXX Ο
14. Covariance Selection β Dual Problem
Block-coordinate descent gradient method
The dual problem is given by
in the variable U ί³ Sn
13
njiU
nU
ij ,,1,,||tosubject
)(detlogmin
K=β€
β+ββ
Ο
ί³
We can decompose the matrices in blocks as follows
where V is fixed, A ί³ S(n-1), u,b ί³ R(n-1) and w,c ί³ R
u represents the variables, i.e. the rows and columns we are
updating at each iteration.
ο£·ο£·
ο£Έ
ο£Ά

ο£

=βο£·ο£·
ο£Έ
ο£Ά

ο£

=
cb
bA
wu
uV
U TT
and
15. Covariance Selection β Dual Problem
Block-coordinate descent gradient method
The dual problem in blocks becomes
At each iteration, the main step is then a box
14
njiuw
nubVAubcwVA
ij
T
,,1,,||,||tosubject
)]()()()log[()(detlogmin 1
K=β€β€
β+++β+β+β β
ΟΟ
At each iteration, the main step is then a box
constrained quadratic program of the form
can be solved using SeDuMi by Sturm (1999)
njiu
ubVAub
ij
T
,,1,,||tosubject
)()()(min 1
K=β€
+++ β
Ο
16. Block-coordinate descent gradient method
Algorithm
Pick the row and colum to update;
Compute (A + V)-1;
Update the row and column previously picked with the
solution of the box constrained QP
After each step, check the folowing convergence
15
After each step, check the folowing convergence
condition
Matlab code available on dβAspremontβs website
Ξ΅Ο β€+ββ β=
n
ji
ijXnX
1,
)(Tr
17. Covariance Selection
Example
Each component equal to 0 in the inverse covariance
matrix represents two variables that are conditionally
independent
Financial meaning of the inverse covariance matrix:
idiosyncratic components of asset prices dynamics
16
Example
15 currencies vs. USD
daily data from Jan 2008 to Dec 2009
graphs done using Cytoscape
21. Clusters
13
ο½ Select the right financial instruments
ο½ Based on conditional dependence (inversecovariance)
ο½ The chosen instruments should be conditional dependent on each other,
but conditional independent to the rest.
ο½ Identify clusters in the inverse covariance matrix
22. Predictability
14
ο½ π =
ππ‘β1
2 πΉ2
ππ‘
2
ο½ π small ο variance of ππ‘β1 is shadowed by the
contribution from Ξ£ ο ππ‘ is mostly noise, not
predictable
ο½ π big ο variance of ππ‘β1 dominates that of ππ‘ and the
contribution from Ξ£ is small ο ππ‘ is more predictable
ο½ Hence π is a good measure for mean reversion (low
predictability), and is a good proxy for π.
25. Greedy Search
17
ο½ πΌ π = π β 1, π | π₯π β 0 , the set of non-zero indices.
ο½ When π = 1, all but one index of π₯π is empty, π₯π
β²
π΄π₯π = π΄ππ.
ο½ πΌ1 = argmin
πβ 1,π
π΄ππ/π΅ππ.
ο½ Recursion. Given πΌ π, find πΌ π+1.
ο½ For each index i not in πΌ π, solve the minimization problem.
ο½ With a fixed set of indices,
ο¨ Find z the vector corresponding to the smallest eigenvalue in
Ξβ1/2
π΄ π
Ξπ΄Ξβ1/2
.
ο¨ π₯ = Ξβ1/2
π§.
ο½ Add the index i of the smallest objective value to πΌ π.
ο½ Simple.
ο½ Solution not optimal.
26. Primal SDP Problem
18
ο½ min
π
Tr πΆπΆ
ο½ s.t.,
ο½ Tr π΄π π = ππ
ο½ π β½ 0
ο½ C, X, Ai are all symmetric matrices of n-by-n.
ο½ Convex set: pick any two points and draw a line. The
line lies entirely inside the set. No dents in the
perimeter.
ο½ Convex cone πΎ: π₯ β πΎ implies that Ξ±π₯ β πΎ for any
scalar Ξ± β₯ 0.
27. Linear Programming
19
ο½ Linear Programming is a special case.
ο½ C, Ai are diagonal matrices.
ο½ min
π₯
πβ² π₯
ο½ s.t.,
ο½ π΄π΄ = π
ο½ π₯ β₯ 0
ο½ Note: Quadratic Programming is another special case
of SDP.
31. Relaxed SDP Problem Problems
23
ο½ Need to transform πβ² πΏ π β€ π into the standard form.
ο½ The transformation will introduce π π + 1
constraints.
ο½ The relaxation may return an X that has a bigger rank
and/or cardinality, violating the constraints.
32. Equivalent SDP Problem
24
ο½ min
πβπ π
Tr π΄π΄
ο½ s.t.,
ο½ π 0 β€ π
ο½ Tr π΅π = 1
ο½ π β½ 0
ο½ Rank of Y = 1
ο½ Change of variable
ο½ π =
π
Tr π΅π΅
33. Handling Rank and Cardinality
25
ο½ Iteratively solve this system of three equations, starting with
ο½ π = π· = 0
ο½ min
πβπ π
ππ π΄π΄ β π€1 ππ ππ β π€2 ππ(π·π·)
ο½ Tr π΅π΅ = 1
ο½ π β½ 0
ο½ min
πβπ π
ππ(ππβ
)
ο½ 0 β€ π β€ πΌ
ο½ π‘π‘ π = π β 1
ο½ Can be solved analytically.
ο½ min
π·βπ·π·π·π·π·π·π·π·
ππ(π·πβ
)
ο½ 0 β€ π· β€ πΌ
ο½ ππ π· = π β π
ο½ Can be solved analytically.
34. Optimal Weights
26
ο½ Even if the assets are correctly chosen, without the
correct weights, the portfolio is still not mean
reverting.
Determine
optimal
weights
Semidefinite
programming
35. Utilize Mean Reverting Portfolio in Trading
27
ο½ Given the portfolio can be modelled as a mean
reverting OU process, dynamic spread trading is a
stochastic optimal control problem.
ο½ Objectives:
ο½ Given a fixed amount of capital, dynamically allocate
capital over a risky mean reverting portfolioand a risk-free
asset over a finite time horizon to maximize a general
constant relative risk aversion (CRRA) utility function of
the terminal wealth
ο½ Allocate capital amongst several mean reverting portfolios
36. Utilize Mean Reverting Portfolio in Trading
28
ο½ Given the portfolio can be modelled as a mean
reverting OU process, dynamic spread trading is a
stochastic optimal control problem.
ο½ Mathematics involved:
ο½ Ornstein-Uhlenbeck (OU) estimation
ο½ Hamilton-Jacobi-Bellman (HJB) equation
ο½ ODE (Riccatti differential equations)
ο½ Portfolio allocation (mean variance analysis)
37. Proposed Procedure
ο½ Step 1: Split a large pool of risky assets into sufficiently
small clusters;
ο½ Step 2: Search each of the clusters for optimal small
mean reverting portfolios;
ο½ Step 3: For each portfolio identified in Step 2,
determine the optimal pairs trading strategy;
ο½ Step 4: Dynamically allocate money among mean
reverting portfolios.
29
38. Case Study β S&P 500 Stocks
ο½ Trading periods
ο½ From 2010-Jan-01 to 2014-Dec-31, 10 sub-trading period,
length of every sub-period is 6 month;
ο½ Re-select the portfolio before each sub-trading period
begins;
ο½ For every sub-trading period, 2 years stock data are used to
select the portfolio.
ο½ Once portfolio is chosen, the weights of stocks are
unchanged within the 6 month period
ο½ Rebalance when the difference between current portfolio
price and last trade price is larger than a certain threshold.
39. Case Study β S&P 500 Stocks
ο½ Assumptions
ο½ Margin requirement
ο½ For short selling, 50% of the short selling value needs to be
deposited into the margin account.
ο½ 50% of values of stocks in long position can be used as collateral
for short margin account.
ο½ Cost
ο½ Transactioncost: 0.2% per transaction
ο½ Borrowing cost: 8% p.a. (short selling)
ο½ Risk-free rate: 0.55% p.a. (1-year LIBOR)
40. Case Study β S&P 500 Stocks
ο½ An example, the last sub-trading period, 2014/07/02 -
2014/12/31:
ο½ In-sample fitting
ο½ 2004/07/01-2014/07/01 Identify the largest cluster: 69 stocks are
selected from S&P 500 stocks (covariance selection);
ο½ 2012/07/01-2014/07/01 Calculate the optimal combination of stocks: 5
stocks are selected from the largest cluster and their weights are
optimized (LASSO, semidefinite programming) ;
ο½ Fit an OU model to the portfolio constructed (OU estimation);
ο½ Out-of-sample trading (2014/07/02-2014/12/31)
ο½ Calibration frequency: rebalance when state changes more than 1
unit, state is (current price - mean)/s.d.;
ο½ Determine the optimal capital to be allocated to the portfolio and the
risk-free asset (ODE solving, portfolio optimization);
41. Case Study β S&P 500 Stocks
ο½ Optimal portfolio
ο½ The portfolio price is volume weighted average price
ο½ If we want to buy N shares of the portfolio, we need to buy 0.13N shares of
CSX, buy 0.07N shares of DHI, buy 0.98N shares of FTR, sell 0.04N shares of
GPS and sell 0.11 shares of MAR.
ο½ Although the weight of FTR seems to be large, it is only because the price of
FTR is significantly lower than other stocks. Total value of FTR does not
dominate values of other stocks.
Stock Sector Weigh
t
Avg.
price
CSX Corp. Industrials 0.13 24.1
D. R. Horton Consumer Discretionary 0.07 21.1
Frontier
Communications
Telecommunications
Services
0.98 4.1
Gap (The) Consumer Discretionary -0.04 36.7
Marriott Int'l. Consumer Discretionary -0.11 43.5