Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems
Optimization Techniques in Finance 5. Convex optimization. II
Andrew Lesniewski
Baruch College New York
Fall 2019
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Outline
1 Portfolio optimization problems
2 Numerical methods: unconstrained problems
3 Numerical methods: equality constrained problems
4 Numerical methods: inequality constrained problems
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
Our second group of examples of applications of convex optimization methods to financial problems is in the area of portfolio management.
Consider a portfolio of risky assets S1,..., Sn, and let (i) ri denote the return on asset Si , (ii) µi = E(ri ) denote the expected return on Si , p (iii) σi = Var(ri ) denote the standard deviation of returns on Si , (iv) ρij denotes the correlation among the returns of Si and Sj , (v) C ∈ Matn (R) denotes the covariance matrix of returns on the assets, Cij = ρij σi σj . Pn (vi) wi denotes the weight of asset Si in the portfolio, i=1 wi = 1.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
In the Markowitz mean variance portfolio problem, we are concerned with the question of allocating the assets in such a way, so that the variance of returns of the portfolio returns is minimal, while the expected return is at least a certain target level r. Additionally, one imposes other inequality and equality constraints which reflect the portfolio manager’s (PM) mandate and views. For example, if the portfolio is long only, part of the inequality constraints will read wi ≥ 0.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
In other words, the Markowitz mean variance optimization problem is formulated as the following convex optimization problem:
µTw ≥ r, 1 min σ2 = w TCw subject to Aw = b, (1) 2 Bw ≥ c.
Let λr , λE , λI denote the Lagrange multipliers corresponding to the three constraints above. The Lagrange function reads:
1 T T T T L(w, λr , λE , λI ) = w Cw − λr (µ w − r) − λ (Aw − b) − λ (Bw − c). (2) 2 E I
Note that the signs of the Lagrange multipliers are consistent with our conventions explained in Lecture Notes #2.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
The first order KKT conditions read:
T T Cw = λr µ + A λE + B λI , µTw ≥ r, Aw = b, Bw ≥ c, (3) T λr (µ w − r) = 0,
λI (Bw − c) = 0,
λr ≥ 0,
λI ≥ 0.
Whether these conditions have a solution or not, and what is the optimal value, depends on the values of the parameters in the constraints.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
In particular, there is only a certain range r ∈ [rmin, rmax ] of target expected portfolio returns, for which the problem has a solution. The curve representing the expected return r as a function of the optimal standard deviation σ of portfolio returns is called the efficient frontier.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
It is apparent that the solution of the optimality conditions (3) involves inverting the covariance matrix C. For this reason, it is very important that the estimated covariance matrix is well conditioned and has a well behaved inverse. As discussed earlier, a great deal of effort has been put into developing methodologies for covariance matrix estimation, especially for large portfolios. Without additional measures, (unconstrained) Markowitz MV optimization typically leads to highly unintuitive extreme portfolios, in which outsized long positions in some assets are offset by outsized short positions in other assets. Such portfolios, even though mathematically feasible, are practically totally unrealistic. Frequently (and IMHO incorrectly) this phenomenon is attributed to estimation errors of the “true” covariance matrix. These errors are supposed to be remediated by the regularization techniques discussed earlier.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
Assume now that the portfolio contains a riskless asset with deterministic rate of return is rf . It is natural to expect that rf < r. We allocate a fraction 0 ≤ η ≤ 1 of the portfolio into the riskless asset. Risk / return profiles for different values of η can be represented as a straight line, a capital allocation line (CAL), in the standard deviation / mean return plane.
The optimal CAL lies below all the other CALs with r > rf , since the corresponding portfolios have the lowest σ for any given value of r > rf .
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Mean variance optimization
It follows that the optimal CAL goes through a point on the efficient frontier and never goes above a point on the efficient frontier. In other words, the slope of the optimal CAL is the derivative of the function r(σ) that defines the efficient frontier, and so the optimal CAL is tangent to the efficient frontier. The point where the optimal CAL touches the efficient frontier corresponds to the optimal risky portfolio.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Maximizing the Sharpe ratio
Alternatively, one can think of the optimal CAL as the one with the smallest slope. This is the portfolio that maximizes the Sharpe ratio:
µTw − r SR(w) = √ f . (4) w TCw
The corresponding optimization problem
( µTw − r Aw = b, max √ f subject to (5) w TCw Bw ≥ c
is not concave, and it is hard to solve. It can be replaced with an equivalent convex quadratic problem as follows.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Maximizing the Sharpe ratio
The feasible set of (5), P = {w ∈ Rn : Aw = b, Bw ≥ c}, is a polyhedron. Define the convex set
P+ = {(y, κ) ∈ Rn+1 : κ > 0, and y/κ ∈ P} ∪ (0, 0).
Then the portfolio w ∗ optimizing (5) is of the form w ∗ = y ∗/κ∗, where the pair (y ∗, κ∗) is the solution to the following convex quadratic problem:
( + T (y, κ) ∈ P , min y Cy subject to T (6) (µ − rf ) y = 1.
In order to see the equivalence of the two problems, we substitute in (6):
1 κ = , T (µ − rf ) y y = κw.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Benchmark tracking
In quantitative asset management environments, portfolios are frequently selected with respect to a particular benchmark in mind. The benchmark may be a standard market index, such as S&P 500, or a customized index. The PM’s mandate may be, for example, to closely track the benchmark, or outperform it by a certain amount. The tracking error (or excess return) of a portfolio with a given benchmark is the difference between the returns of the portfolio and the benchmark. It is defined as: T T T r w − r wbench = r (w − wbench), (7) T where r is the vector of returns of the assets and wbench is the vector of weights of the assets in the benchmark. The ex ante (predicted) tracking error is defined as
p T (w) = (w − wbench) C(w − wbench) (8)
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Benchmark tracking
The PM whose mandate is to track the benchmark with maximum ex ante tracking error faces the following convex optimization problem:
T 2 w Cw ≤ σ , T 2 T (w − wbench) C(w − wbench) ≤ , max r (w − wbench) subject to (9) w Aw = b, Bw ≥ c.
Unlike the Markowitz problem (1) that has linear constraints only, it is not in standard quadratic programming (the constraint limiting the portfolio tracking error is quadratic), which makes it harder to solve. The tracking error constraint is, however, a convex quadratic function and, as discussed in Lecture Notes #4, we can rewrite this constraint in conic form. The resulting problem is a second-order cone optimization problem.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Benchmark tracking
Since C is positive definite, there is a non-singular R ∈ Matn (R) such that C = RRT. We introduce the variables:
y0 = σ, y = RTw, (10) z0 = , T z = R (w − wbench).
With these definitions, the first two constraints in (9) say that the points n+1 n+1 (y0, y) ∈ R and (z0, z) ∈ R are elements of the second-order cone Kn in Rn+1.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Benchmark tracking
The benchmark tracking problem can be formulated as the following SOCP:
Aw = b, Bw ≥ c, T R w − y = 0 T T T R w − z = R wbench max r (w − wbench) subject to (11) w y0 = σ, z = , 0 (y0, y) ∈ Cn, (z0, z) ∈ Cn.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Unconstrained convex problems
We now move to discuss some of the algorithms used to solve convex optimization problems. We consider first an unconstrained convex optimization problem:
min f (x), (12)
where f (x) is convex, twice continuously differentiable. As usual, by x∗ we denote its solution, and by f ∗ = f (x∗) its optimal value. From the analysis presented in Lecture Notes #4, the necessary and sufficient condition for x∗ is ∇f (x∗) = 0. (13)
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Unconstrained strong convex problems
As in the case of general nonlinear optimization problems, the solution methods
are iterative, and start with an initial guess x0 such that (i) x0 ∈ dom(f ), (ii) the sublevel set S = {x ∈ dom(f ): f (x) ≤ f (x0)} is closed. The second condition is usually hard to verify. Cases when it is true include: (i) if dom(f ) = Rn, (ii) if f (x) → ∞, as x approaches the boundary of dom(f ).
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Unconstrained strong convex problems
A function f (x) is strongly convex on C, if there exists µ > 0 such that
∇2f (x) ≥ µI, for all x ∈ C. (14)
An implication of strong convexity is:
1 f (y) ≥ f (x) + ∇f (x)T(y − x) + µky − xk2, for all x, y ∈ C. (15) 2
Indeed, from Taylor’s theorem, there is a z on the line segment connecting x and y such that
1 f (y) = f (x) + ∇f (x)T(y − x) + (y − x)T∇2f (z)(y − x), 2
which, together with (14), implies (15).
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Unconstrained strong convex problems
Examples: 1 T (i) The function f (x) = 2 x Px, where P is positive definite, is strongly convex. In this case, we can take µ to be the smallest eigenvalue of P. (ii) The Kullback-Leibler divergence f (p) = KL(pkq) is strongly convex with µ = 1. (iii) The function f (x) = − log(x) is convex but not strongly convex on R+.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Unconstrained strong convex problems
We infer from (15) that 1 f ∗ ≥ f (x) − k∇f (x)k2. (16) 2µ To see this, we note that the RHS of (15) has a minimum in y for y¯ = x − ∇f (x)/µ, and the minimum value is equal to f (x) − k∇f (x)k2/2µ. This inequality allows us to formulate the following exit criterion for the search: in order to be within ε from f ∗, f ∗ − f (x) ≤ ε, we terminate the search when
p k∇f (x)k ≤ 2µε.
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Descent methods
A descent method consists in constructing a sequence
xk+1 = xk + tk ∆xk , (17)
n where the search direction ∆xk ∈ R and step size tk > 0 are chosen so that
f (xk+1) < f (xk ). (18)
From convexity, ∆xk must satisfy T ∇f (xk ) ∆xk < 0, (19)
i.e. ∇f (xk ) and ∆xk cannot be perpendicular to each other. General descent method: Choose an initial guess x0 and iterate the following steps:
while( stopping criterion not satisfied )
determine a descent direction ∆xk
choose a step size tk
update xk+1 = xk + tk ∆xk
A. Lesniewski Optimization Techniques in Finance Portfolio optimization problems Numerical methods: unconstrained problems Numerical methods: equality constrained problems Numerical methods: inequality constrained problems Backtracking line search
The second step of the algorithm, the line search, determines where on the ray
{x + t∆x : t > 0} (20)
the next iterate will be. We choose t to minimize the objective function along the ray (20):
t = arg min f (x + s∆x). (21) s>0
It is usually sufficient to solve this problem approximately. A very simple and quite effective inexact line search method is the backtracking line search. It depends on two parameters α ∈ (0, 1/2) and β ∈ (0, 1).
Given a descent direction ∆x and t0 = 1, iterate the following steps: