implementation of mean-variance and tail optimization

44
Implementation of mean-variance and tail optimization based portfolio choice on risky assets ERIK BR ¨ OTE AND YOUNES DJEHICHE Stockholm May 20, 2016 Bachelor’s Thesis Mathematical Statistics Royal Institute of Technology, KTH [email protected], [email protected]

Upload: others

Post on 23-Feb-2022

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Implementation of mean-variance and tail optimization

Implementation of mean-variance and tailoptimization based portfolio choice on

risky assets

ERIK BROTE AND YOUNES DJEHICHE

StockholmMay 20, 2016

Bachelor’s ThesisMathematical Statistics

Royal Institute of Technology, KTH

[email protected], [email protected]

Page 2: Implementation of mean-variance and tail optimization

Abstract

An asset manager’s goal is to provide a high return relative the risk taken, and thus faces thechallenge of how to choose an optimal portfolio. Many mathematical methods have been developedto achieve a good balance between these attributes and using different risk measures. In thisthesis, we test the use of a relatively simple and common approach: the Markowitz mean-variancemethod, and a more quantitatively demanding approach: the tail optimization method. Using afictive portfolio based on data provided by the Swedish fund management company Enter Fonderwe implement these approaches and compare the results. We analyze how each method weighs theunderlying assets in order to get an optimal portfolio.

i

Page 3: Implementation of mean-variance and tail optimization

Acknowledgements

Special thanks to Henrik Lindquist, Mohammed Farahani and John Bornstein at Enter FonderAB for their help and guidance. We would also like to thank Henrik Hult and Thomas Onskog atKTH for their feedback.

ii

Page 4: Implementation of mean-variance and tail optimization

Contents

Abstract i

List of figures v

List of tables v

1 Introduction 1

2 Theoretical background 32.1 Portfolio construction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2.1.1 Assumptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42.2 Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

2.2.1 Multivariate student’s t-distribution . . . . . . . . . . . . . . . . . . . . . . 42.2.2 The t-copula . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52.2.3 The meta t-distribution . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

3 Data 7

4 Markowitz portfolio optimization 104.1 Problem formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.2 Solution of the MMV problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104.3 Efficient frontier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114.4 Minimum variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.4.1 Problem formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124.4.2 Solution of the MV problem . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

4.5 Implementation on data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 134.5.1 Efficent Frontier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

5 Tail optimization 165.1 Formulation of the tail-optimization problem . . . . . . . . . . . . . . . . . . . . . 165.2 Finding the appropriate distribution of the vector X . . . . . . . . . . . . . . . . . 165.3 Student’s t-distribution with the same degrees of freedom ν . . . . . . . . . . . . . 17

5.3.1 Estimation of the dispersion matrix Ω from the data . . . . . . . . . . . . . 175.3.2 Estimating the degree of freedom ν from the data . . . . . . . . . . . . . . 18

5.4 Student’s t-distribution with different degrees of freedom ν . . . . . . . . . . . . . 185.4.1 Estimating the t-copula CtR,ν . . . . . . . . . . . . . . . . . . . . . . . . . . 18

5.5 Solving the optimization problem . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195.6 VaR efficient frontier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225.7 Results from implementation on data . . . . . . . . . . . . . . . . . . . . . . . . . . 23

5.7.1 Data processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 235.7.2 Minimum VaR portfolio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

6 Analysis 266.1 Comparison of the expected returns . . . . . . . . . . . . . . . . . . . . . . . . . . 266.2 Comparison of the weights with respect to asset allocation . . . . . . . . . . . . . . 266.3 Performance analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266.4 Excess return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

7 Conclusions 29

References 30

iii

Page 5: Implementation of mean-variance and tail optimization

Appendix 31

A Mathematical Proofs 31A.1 Positive Definitive Matrix A . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

B MATLAB 31B.1 Data processing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31B.2 Data visualization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32B.3 Markowitz mean-variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34B.4 Tail optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35B.5 Portfolio analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

iv

Page 6: Implementation of mean-variance and tail optimization

List of figures

1 Normalized historical daily prices of the assets 1, . . . , 5. . . . . . . . . . . . . . . . . 72 Historical daily returns X1, . . . , X5 of the assets 1, . . . , 5. . . . . . . . . . . . . . . . 73 Historical weekly returns X1, . . . , X5 of the assets 1, . . . , 5. . . . . . . . . . . . . . . 84 Normalized historical weekly prices of the assets 1, . . . , 5. . . . . . . . . . . . . . . . 85 Normalized future daily prices of the assets 1, . . . , 5. . . . . . . . . . . . . . . . . . 96 Future weekly returns X1, . . . , X5 of the assets 1, . . . , 5. . . . . . . . . . . . . . . . 97 Normalized portfolio weekly returnXP compared to normalized asset returnsX1, . . . , X5

during the future time period. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 Normalized portfolio value Pp compared to normalized asset prices P1, . . . , P5 during

the future time period. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 Mean variance efficient frontier of portfolios consiting of the assets 1, . . . , 5, the red

risk-return profile corresponds to the minimum variance portfolio calculated in (37). 1510 Example of a qq-plot of standard Student’s t-distribution with six degrees of freedom. 1711 Tail optimization methodology summarized in a flowchart. . . . . . . . . . . . . . . 1912 Fitting the marginal distributions to t-distribution using qq-plot technique. . . . . 2313 The efficient frontier curves for the VaR-framework at levels α = (0.1, 0.05, 0.025, 0.01) 2514 Realized prices Pto and Pmv. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2715 Difference in daily returns Xto −Xmv during future time period. . . . . . . . . . . 2716 Difference in weekly returns Xto −Xmv during future time period. . . . . . . . . . 2817 Excess returns during future time period. . . . . . . . . . . . . . . . . . . . . . . . 28

List of tables

1 The quantiles for some t-distributions at different levels α [1]. . . . . . . . . . . . . 202 The weights of the minimum VaR portfolio at different levels α. . . . . . . . . . . . 253 Weights of the VaR and mean variance portfolios, their corresponding degrees of

freedom and variances . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

v

Page 7: Implementation of mean-variance and tail optimization

1 Introduction

Investors have different preferences; some are risk-seekers and aim for high expected return re-gardless of the risk taken, while others are risk averse. Consequently, asset managers must takeinvestors’ risk preferences into account in their design of the optimal portfolio so that it reflectsthe risk tolerance of the investors given the market’s conditions. Standard deviation of returnsis widely used to quantify risk, but the last series of the financial markets crashes suggest thattail-risk should be taken into account. For portfolio managers the ultimate challenge is to find theright balance between risk and return.

Several frameworks have been suggested to construct portfolios with subjectively optimal risk-return trade-offs. In 1952, Harry Markowitz introduced modern portfolio theory (MPT) for whichhe was awarded the Nobel Memorial Prize in Economics in 1990 [2]. MPT, based on Markowitzmean variance portfolio optimization, assumes that investors are risk averse and provides a setof corresponding optimal risks (standard deviation) and returns, known as the efficient frontier.Under the Markowitz theory, no portfolios exist with the more attractive risk-return profiles. It isup to the asset manager to choose a portfolio from the efficient frontier that provides an acceptablerisk-return trade-off (quantitative methods have been developed to simplify this choice). TheMarkowitz mean variance portfolio is still widely used today due to its simplicity, but, in recentyears, it has been criticized for not accurately reflecting financial markets and investor preferences.It assumes utility functions are quadratic; that investors only care about risk and return and noton other factors such as extreme losses. Also, MPT uses the covariance matrix of asset returns tocalculate risk. It has repeatedly been shown that it does not adequately quantify the underlyingrisk. The apparent shortfalls of Markowitz mean variance based portfolio choice have led to theneed for more rigorous methods that take e.g. tail-events into consideration.

Tail-events represent the least likely outcomes. They are by definition events that are on the farleft or right of the distribution. An asset with fatter right tail than the normal distribution is likelyto generate very high returns. On the other hand, an asset with fatter left tail than the normaldistribution is likely to generate very high losses. A tail-risk is the risk of higher losses due totail-events. Informed investors who put safety above any other goal should strive to understandand even quantify tail-risk. The variance measures the average deviation of the return from itsexpected value; it is thus a risk measure that targets the center (or mean) of the distribution ofthe returns. In particular, it does not account for tail-events, meaning that large losses from aleft-tailed return distributions cannot be detected.

Tail-risk based portfolio optimization maximizes the expected return of the portfolio given thatthe tail-event occurs with a very small probability. A typical example of such a constrainedoptimization problem is to maximize the expected return given that the probability of losses largerthat a given value L i.e. the total portfolio return falls below a certain threshold −L(L ≥ 0) e.g.the probability of losses is less than 0.01.

Fund managers and analysts are always looking for systematic risk optimization methods for theirportfolios. In this project, we suggest safety-first optimization techniques that achieve a satisfactorybalance between risk and return using statistical tools. We focus on two methods:

• Markowitz mean variance (MMV): minimizing the variance for a fixed level of expectedreturn;

• Tail optimization (TO): maximizing return using a tail probability constraint.

The methods reviewed in this thesis are built on two key assumptions. The first is that theassets are inherently risky, meaning that no assets have a guaranteed level of return. Portfoliooptimization with a risk-free asset is more realistic as portfolio managers have access to nearlyrisk-free assets such as government bonds. We also focus on safety-first optimization, meaningthat the asset manager seeks to minimize the risk as a first priority.

1

Page 8: Implementation of mean-variance and tail optimization

The background section contains a review of the framework needed to use these models. Afterdescribing each technique in depth and the portfolios dictated by each method, we apply them to afictive portfolio. Enter Fonder, a Swedish fund manger, has provided us with market data in orderto construct a suitable fictive portfolio on which we implement these methods using MATLAB.The code is provided in Appendix B. We compare the performance of each portfolio out-of-sample.We explain why each portfolio performs as it does. We do not determine a particular method to besuperior to the other simply because this depends on the asset managers risk aversion and otherpreferences.

2

Page 9: Implementation of mean-variance and tail optimization

2 Theoretical background

2.1 Portfolio construction

Using the portfolio framework described by Berk [3] and Armerin [4] among others, we considerthe assets i = 1, . . . , n, with the normalized prices Pi(t) so that Pi(0) = 1. The correspondingreturn of each asset i is given by

Xi(t+ 1) =Pi(t+ 1)− Pi(t)

Pi(t), (1)

where t = 0, . . . , T. This can be reformulated as

Pi(t+ 1) = Pi(t)(1 +Xi(t)). (2)

Although portfolio returns are naturally time dependent, we consider only a one-period modelbetween two consecutive instants such as days or weeks. Thus, in the sequel we will omit thedependence on the time parameter in our notation.

We consider a portfolio composed of the assets 1, . . . , n with returns Xi and respective weights ui.The weights ui are defined as

ui :=Value of investment i

Total value of portfolio.

They describe how the total value is allocated between the constituents; they can be either pro-portions that sum to one or simply amounts. In this study we will use proportions meaning theyhave a sum-to-one constraint

n∑i=1

ui = uᵀ1 = 1uᵀ = 1. (3)

We note that the weights can be negative, which implies that an asset has been short sold.

The return of the portfolio at time t, Xp, is given by

Xp :=

n∑i=1

uiXi = uᵀX = Xᵀu, (4)

where uᵀ denotes the transpose of the vector

u := (u1, . . . , un)ᵀ (5)

and X denotes the vector of assets’ returns

X := (X1, . . . , Xn)ᵀ. (6)

Letµ := (µ1, . . . , µn) (7)

denote the mean vector of X i.e. E(Xi) = µi for i = 1, . . . , n. The expected return of the totalportfolio is

µp = E(Xp) = E[uᵀX] = uᵀE[X] = uᵀµ = µᵀu. (8)

The variance σ2p := V ar(Xp) of the portfolio is

σ2p := V ar(Xp) = V ar(uᵀX) = uᵀV u, (9)

3

Page 10: Implementation of mean-variance and tail optimization

where V is the covariance matrix of the returns:

V =

σ2

1 σ12 . . . σ1n

σ21 σ22 . . . σ2n

......

. . ....

σn1 σn2 . . . σ2n

(10)

where σij denote the returns’ covariances.

σij = cov(Xi, Xj) = E[(Xi − E[Xi])(Xj − E[Xj ])], i, j = 1, . . . , n

Note that V is symmetric by definition (σ2ij = σ2

ji) and positive-semidefinite, in the sense that

uᵀV u ≥ 0, ∀ u 6= 0.

This follows from the fact that uᵀV u = V ar(uᵀX) = V ar(Xp) ≥ 0.

2.1.1 Assumptions

This portfolio framework is based on a few assumptions:

• The portfolio exists in a frictionless market, a theoretical model in which there are no trans-action costs associated with or restrictions on trading. i.e. there are no transaction cost ortaxes, as well as no limits on short selling.

• Risky assets. This formulation of the problem does not apply to portfolios containing risk-freeassets, which is a slightly more complex problem. For further details, see [4, 5].

• The expected return Xi and variance σ2i of each asset i are finite. This, in turn, means that

all possible covariances between assets are finite, thanks to the Cauchy-Schwarz inequality[4].

• The covariance matrix V is positive-definite, in the sense that

uᵀV u > 0, ∀ u 6= 0.

• The assets do not all have the same expected returns µi. Mathematically this means thatthe vector of expected returns µ is not proportional to 1 (a vector of ones of length n).

2.2 Statistics

2.2.1 Multivariate student’s t-distribution

The n-dimensional vector X = (X1, . . . , Xn) is said to have a multivariate t-distribution withν degrees of freedom, mean vector µ and a positive-definite dispersion matrix Ω, denoted X ∼tn(ν, µ,Ω), if its density is given as (see e.g. [6])

f(x) =Γ(ν+n

2 )

Γ(ν2 )√

(πν)ndet(Ω))

(1 +

(x− µ)ᵀΩ−1(x− µ)

ν

)− (ν+n)2

. (11)

The dispersion matrix Ω = (Ωij)ij may be written as

Ω = diagonal(s(1), . . . , s(n)) R diagonal(s(1), . . . , s(n)), (12)

where an estimator of the standard deviation

s(i) =

√√√√ 1

m− 1

m∑j=1

(xji − xi)2

4

Page 11: Implementation of mean-variance and tail optimization

are dispersion measures of the marginals and xji are the outcomes of the marginals Xi [1]. Thelinear correlation parameter R = (Rij) is given by

Rij := Ωij/√

ΩiiΩjj . (13)

The covariance matrix of X is only defined if ν > 2 and can be expressed in terms of the dispersionmatrix Ω by the formula (see e.g [5])

cov(X) =ν

ν − 2Ω = V. (14)

When ν ≤ 2 the covariance matrix is not defined. For example, for ν = 1 the one-dimensionalt-distribution coincides with the Cauchy distribution which has infinite variance.

The definition of the t-distribution through its probability density (11) is derived from the followingconstruction: Let A be the Cholesky decomposition of R. Write

Y =

√ν√SAZ, (15)

where S ∼ χ2ν and Z = (Z1, . . . , Zn) with Z1, . . . , Zn being independent and N(0, 1)-distributed.

Then, X = (X1, . . . , Xn) where, Xi = µi + s(i)Yi has the probability density (11) [7].

2.2.2 The t-copula

Let (U1, U2) be a uniformly distributed random vector over [0, 1]× [0, 1] with joint density

f(U1,U2)(u1, u2) =

1, if (u1, u2) ∈ [0, 1]× [0, 1],0, otherwise.

The corresponding joint distribution function defined by

C(y1, y2) := P (U1 ≤ y1, U2 ≤ y2) =

∫ y1

0

∫ y2

0

f(U1,U2)(u1, u2)du1du2

is called a 2-dimensional copula. More generally, an n-dimensional copula C is an n-dimensionaldistribution function with standard uniform marginal distributions on the unit interval [0, 1].

Based on the fact that if FX denotes the distribution function of random variable X, then therandom variable U := FX(X) is uniformly distributed over the unit interval [0, 1]. A result ofSklar [8] states that every distribution function F with marginals F1, . . . , Fn can be written as

F (x1, . . . , xn) = C(F1(x1), . . . , Fn(xn)), (16)

for some copula C, where each Fi(xi) ∈ [0, 1] is an outcome of the uniformly distributed randomvariable Ui := Fi(Xi).

From (16) we conclude that a copula C may be used to join any collection of univariate distributionfunctions Fi, . . . , Fn i.e. it represents an interdependence structure that links all the marginals toform a joint distribution of random variables (see e.g. [6]).

In our case, the density of a t-copula associated with a correlation matrix R has the following form

ctR,ν(u1, . . . , un) =1√

det (R)

Γ(ν+n2 )Γ(ν2 )n−1

Γ(ν+12 )n

∏nk=1

(1 +

y2kν

) ν+12

(1 + yᵀR−1y

ν

) ν+n2

, (17)

where y = (y1, . . . , yn) with yk = t−1ν (uk), uk ∈ [0, 1] and tν(x) denotes the zero-mean probability

distribution function of the student t-distribution with ν degrees of freedom.

The t-copula is then given by (see [7])

CtR,ν(u) =

∫ t−1ν (u1)

−∞

∫ t−1ν (u2)

−∞· · ·∫ t−1

ν (un)

−∞cᵀR,ν(y1, . . . , yn) dy1 . . . dyn. (18)

5

Page 12: Implementation of mean-variance and tail optimization

2.2.3 The meta t-distribution

Invoking Sklar’s result, if we start with copula C and marginal distributions F1, . . . , Fn, then

F (x1, . . . , xn) := C(F1(x1), . . . , Fn(xn))

defines a multivariate distribution function with marginals F1, . . . , Fn. This distribution functionis sometimes called meta-distribution. Given t-distributed marginals with different degrees offreedom νi, the vector X is meta t-distributed with probability distribution function given as

F (x1, . . . , xn) = CR,ν(tν1(x1), . . . , tνn(xn)). (19)

6

Page 13: Implementation of mean-variance and tail optimization

3 Data

We collaborated with Enter Fonder, a Stockholm-based fund management company, to constructa fictive portfolio so that our implementation would be as realistic as possible. The suggestedportfolio has a low to medium risk profile. The portfolio consists of five assets: 1, 2, 3, 4 and 5,for which we have 1582 daily price data points each. All five are equities listed on the NASDAQStockholm exchange, operating in different sectors.

We will implement the optimization methods on the data points from the time period [T0, . . . T1250],which we will call historical data. This leaves the remaining 331 data points as our future data, onwhich we will test the performance of the portfolio optimization methods. Figure 1 displays thehistorical normalized prices.

Figure 1: Normalized historical daily prices of the assets 1, . . . , 5.

In order to implement the methods on the data, we need to convert the data from prices to returnsusing formula (1), resulting in 1250 data points. Figure 2 displays the historical daily returns.

Figure 2: Historical daily returns X1, . . . , X5 of the assets 1, . . . , 5.

7

Page 14: Implementation of mean-variance and tail optimization

As seen in Figure 2, significant volatility can be observed in the daily returns. Therefore, we adjustthe data frequency from day to week in order to get more signal and less noise. This means that wetake every fifth data-point, resulting in 317 ”weekly” data-points. Figure 3 displays the historicalweekly returns.

Figure 3: Historical weekly returns X1, . . . , X5 of the assets 1, . . . , 5.

Figure 4 shows the price curves of each asset when the data is limited to weekly prices. Theseprice curves are naturally quite similar to the ones shown in Figure 1 and will hence be suitablefor our analysis.

Figure 4: Normalized historical weekly prices of the assets 1, . . . , 5.

The last 67 weeks of our data will represent the future price points in our analysis. Figure 5displays the daily prices of each asset. It is clear that this is more volatile than the historical datapresented in Figure 1. This will provide a good data set to analyze the effects of each method onour analysis. Note that the trends in the future data are not as clear as those in the historicaldata.

8

Page 15: Implementation of mean-variance and tail optimization

Figure 5: Normalized future daily prices of the assets 1, . . . , 5.

The future daily returns, shown in Figure 5, seem to be of the same order of magnitude as thehistorical daily returns in Figure 1.

Figure 6: Future weekly returns X1, . . . , X5 of the assets 1, . . . , 5.

MATLAB code for to convert from prices to returns, as well as for visualizing the data are includedin Appendix B.1 and B.2.

9

Page 16: Implementation of mean-variance and tail optimization

4 Markowitz portfolio optimization

Markowitz [2] introducted MPT in terms of mean variance portfolio optimization. Markowitz meanvariance (MMV) aims to construct a portfolio so that the risk is minimized given a certain levelof the expected return µp. The variance σ2

p of the portfolio is used to quantify the level of risk.

4.1 Problem formulation

The Markowitz mean variance problem is formulated as follows:

(MMV)

minu

12u

ᵀV u

s.t uᵀµ = µp,

uᵀ1 = 1,

(20)

where the first constraints reflects the fact the expected portfolio return is fixed to µp. The secondconstraint means that the weights are regarded as the proportion of the total portfolio containedin each asset, this criterion was discussed in Section 2.1.

Remark 1 MMV is a special formulation of the trade-off (quadratic utility) function:maxu

uᵀµ− 12γu

ᵀV u

s.t uᵀ1 = 1.(21)

The asset manager seeks to maximize the utility function given by U = uᵀµ − 12γu

ᵀV u. The firstterm in the function is the expected return µp of the portfolio, γ is the risk aversion parameterwhich is a measure of the asset managers satisfaction of the returns’ level compared to risk. A lowγ means that the manager is risk averse, while a high γ corresponds to a risk-seeking manager whoprioritizes returns over risk.

In the Minimum Variance formulation of the MMV problem the asset manager seeks only to min-imize risk. This mean that γ → 0. Problem (21) then becomes equivalent with the MMV problem(20).

4.2 Solution of the MMV problem

The problem (20) can be solved using the Lagrange multiplier method. Armerin [4] describes thesolution rather well, therefore we follow his method. In this problem the Lagrangian function is

L(u, λ1, λ2) =1

2uᵀV u+ λ1(µp − uᵀµ) + λ2(1− uᵀ1). (22)

The Lagrange multiplier method yields

∂L∂u

= 0,∂L∂λ1

= 0,∂L∂λ2

= 0.

From the first equation we derive the portfolio optimal weights:

V u− λ1µ− λ21 = 0

oru = V −1(λ1µ + λ21).

We now derive the multipliers λ1 and λ2. Multiplying this equation with µ and 1 we obtain thesystem below, if we apply the constraints (20).

µᵀu = µp = µᵀV −1(λ1µ + λ21),

1ᵀu = 1 = 1ᵀV −1(λ1µ + λ21).

10

Page 17: Implementation of mean-variance and tail optimization

This can be rewritten in matrix form as follows:[µᵀV −1µ µᵀV −11µᵀV −11 1ᵀV −11

] [λ1

λ2

]=

[µp1

].

We define the matrix A, the vector λ, and the variables a, b, c, and d as follows:

A =

[µᵀV −1µ µᵀV −11µᵀV −11 1ᵀV −11

]:=

[a bb c

], d := ac− b2, λ :=

[λ1

λ2

]. (23)

Since by (2.1.1), we assumed that V positive-definite, we have the following claim

Claim 2 The matrix A is positive-definite. Hence, it is invertible.

Refer to Appendix A.1 for a proof of this claim.

The inverse of A is therefore:

A−1 =1

d

[c −b−b a

].

We can now derive the Lagrangian multipliers.

λ = A−1

[µp1

]=

1

d

[c −b−b a

] [µp1

]=

1

d

[cµp − b−bµp + a

]which we will use to determine the optimal weights as follows:

u = V −1[µ 1

]A−1

[µp1

]=

1

dV −1((cµp − b)µ + (a− bµp)1). (24)

The variance of the expected portfolio can now be computed using (24).

V ar(Xp) = σ2p = uᵀV u =

cµ2p − 2bµp + a

d. (25)

Proposition 3 The optimal weights of the MMV problem (20) are

ummv =1

dV −1((cµp − b)µ + (a− bµp)1). (26)

The corresponding variance is

σ2mmv(µp) =

cµ2p − 2bµp + a

d. (27)

In the next section we will describe the set of all optimal portfolios and the relationship betweenrisk and return in terms of the so-called efficient frontier.

4.3 Efficient frontier

The solution to the MMV problem presents an interesting problem for the portfolio manager. Theportfolio risk (25) is solely dependent upon the expected return. This means that the portfolio willminimize the variance given the return. The points (σp, µp) is referred to as the efficient frontier.The set of all efficient portfolios are shown in the efficient frontier (see Figure 9). This clearlydisplays the choice that the asset manager must make between risk (σp) and return (µp). Anefficient portfolio maximizes returns given a level of risk (represented by the standard deviation).All portfolios (σp, µp) to the left of the efficient frontier are possible, but not optimal. Using the

11

Page 18: Implementation of mean-variance and tail optimization

portfolio variance and the definition of d we can reformulate equation (25) in order to obtain anequation for the efficient frontier equation.

σ2p =

cµ2p − 2bµp + a

d=cµ2p − 2bµp + d/c+ b2/c

d

multiplying each side with c and simplifying yields:

cσ2p = c2

µ2p − 2bµp/c+ d/c2 + b2/c2

d= c2

(µ2p − b/c)2

d+ 1

Reformulating this results in the equation:

cσ2p − c2

(µ2p − b/c)2

d= 1.

This is clearly the equation for a hyperbola whose center lies in the point (0, bc ), and two asymptotesgiven by

µp =b

c±√d

cσp. (28)

4.4 Minimum variance

An asset manager may want to minimize the portfolios risk, σ2p = uᵀV u, regardless of the expected

return. This problem is similar to the Mean-Variance problem in (20), but in this case the expectedportfolio’s return level is not specified.

4.4.1 Problem formulation

This problem can be expressed formally as:

(MV)

minu

12u

ᵀV u,

s.t. uᵀ1 = 1.(29)

The MV portfolio optimization method does not take into account the expected return, and mayeven result in negative returns.

4.4.2 Solution of the MV problem

Similarly to the mean variance problem solved in Section 4.2, we use the Lagrange multipliermethod. The Lagrangian is

L(u, λ) =1

2uᵀV u+ λ(1− uᵀ1).

The Lagrange multiplier method yields

∂L∂u

= 0,∂L∂λ

= 0, =⇒

V u+ 1λ = 0,

1ᵀu = 1.(30)

The solution to the first equation isu = V −11λ.

Inserting u in the second equation of (30), we obtain

1ᵀV −11λ = 1 =⇒ λ =1

1ᵀV −11=

1

c,

12

Page 19: Implementation of mean-variance and tail optimization

where, by (23), c := 1ᵀV −11. We can now derive the optimal portfolio weights.

u =V −11

c. (31)

The corresponding variance is

σ2 = uᵀV u = ((V −11)ᵀ

c)V (

V −11

c) =

1

c21ᵀ(V −1)ᵀV V −11 =

1

c21ᵀ(V −1)ᵀ1 =

1

c2c =

1

c. (32)

and the expected return is given by

µp = µᵀu = µᵀV−11

c=b

c. (33)

We summarize the solution to the MV problem in the following proposition.

Proposition 4 The minimum variance problem (MV) formulated as in (29) has the followingoptimal weights, variance and expected return:

ummv =V −11

1ᵀV −11, σ2

mmv =1

1ᵀV −11, µmmv =

µᵀV −11

1ᵀV −11. (34)

Remark 5 The minimum variance portfolio is the one that minimizes the variance as a function(27):

dσ(µp)

dµp=

√cµ2p − 2bµp + a

d= 0.

4.5 Implementation on data

We will now display how this method can be implemented on the assets 1, 2, 3, 4, 5 described inSection 3. All calculations were done in MATLAB; the code for this portfolio optimization can befound in Appendix B.3. First, we compute the covariance matrix

V = 10−5

5.166 0.952 1.503 1.811 1.2960.952 3.391 0.769 1.000 0.7411.503 0.0769 5.298 1.467 1.0311.811 1.000 1.467 6.143 0.9541.296 0.741 1.031 0.954 6.010

. (35)

The respective return of the assets 1, . . . , 5 is calculated as the mean return:

µ = 10−3(1.695 0.9670 0.0793 −0.421 2.217

)ᵀ. (36)

The minimum variance portfolio, described in Proposition 4 is solved using the same covariancematrix (35). The MATLAB code used to implement the minimum variance can be found inAppendix B.3. The optimal portfolio weights are therefore the following:

umvmin =(0.1364 0.4920 0.1329 0.0897 0.1491

)ᵀ. (37)

As all the weights are positive, meaning that no short selling takes place. It is clear that theportfolio prefers asset 2, which is 49.20% to the other assets which have similar weight between9% and 15%. Referring back to Figure 5, which displays the price of the in data section, it seemsthat asset 2 is less volatile than the others during the first 250 weeks, hence MV should prefer it.

13

Page 20: Implementation of mean-variance and tail optimization

The corresponding portfolio variance and expected return are:

σ2mv = 8.3591 · 10−5, µmvp,min = 1.0115 · 10−3. (38)

Corresponding expected yearly return is µyear = (1 + µmvp,min)52 − 1 = 5.40% (assuming 52 weeksper year).

Figure 7: Normalized portfolio weekly return XP compared to normalized asset returns X1, . . . , X5 during the future timeperiod.

We will now test this portfolio on future data. Figure 7 and 8 display the weekly returns of theportfolio and the normalized price of the portfolio, respectively. The total portfolio seems lessvolatile than the individual assets and its realized total return is 18.5% during that period. Thisis significantly higher than what the expected return suggest for a period of that length.

14

Page 21: Implementation of mean-variance and tail optimization

Figure 8: Normalized portfolio value Pp compared to normalized asset prices P1, . . . , P5 during the future time period.

4.5.1 Efficent Frontier

Using equation (28) we can obtain the efficient frontier for the given data. Implementing this inMATLAB, we obtain Figure 9. It is clear that the portfolio (37) minimizes the variance as thereare no other risk-return profiles to its left.

Figure 9: Mean variance efficient frontier of portfolios consiting of the assets 1, . . . , 5, the red risk-return profile correspondsto the minimum variance portfolio calculated in (37).

15

Page 22: Implementation of mean-variance and tail optimization

5 Tail optimization

We have seen in Section 4 that the Markowitz portfolio choice bases its risk measure on the varianceV ar(Xp) = uᵀV u. Tail optimization based portfolio uses the (left)-tail probability P(Xp ≤ −L)as a measure of risk. This results in an asset allocation that accounts for the tail-risk i.e. theevents that happen in the left tail, as opposed to the variance which is concentrated on the eventsaround the mean and thus is blind to tail events.

In this section we optimize a portfolio using Value-at-Risk (VaR) as the risk measure, meaningwe maximize the expected return µp given a certain amount of tail-risk. This risk is in fact the(1− α)-level VaR, which is defined as

P(Xp ≤ −Lα) = α,

where Lα is the VaR with confidence level 1− α.

5.1 Formulation of the tail-optimization problem

The optimization problem we want to solve is

(TO)

max µp

s.t P(Xp ≤ −Lα) = α,

uᵀ1 = 1.

(39)

Solving this problem will produce a relation between µp and Lα, which is called the VaR- efficientfrontier.

AsP(Xp ≤ −L) = FXp(−L),

the solvability of problem (39) relies on our ability of assess the correct probability distributionFYp of the portfolio’s return Xp. To find FXp , we need to fit the distribution of X := (X1, . . . , Xn)of the constituents of the portfolio, meaning that we have to find the joint distribution of the Xi’s.

5.2 Finding the appropriate distribution of the vector X

In order to determine the best method to proceed based on our data, we need to find the appropriatejoint distribution of the vector X that best fits our data. This is done by fitting the marginaldistributions to known distributions using the so-called quantile-quantile (qq)-plots [5]. By plottingthe quantiles of the set of data to the quantiles of a known distribution we can easily determinea suitable distribution. A good distribution to fit the marginals to is the Student’s t-distributionbecause it is characterized by only one parameter, the degree of freedom ν, which is easier to fitcompared with other distributions which are characterized by more than one parameter, such asthe normal distribution which is characterized by its mean and standard deviation. Moreover, byvarying ν, we obtain most of the standard distributions. For example, ν = 1 corresponds to theCauchy distribution and ν =∞ corresponds to the normal distribution [6].

Using qq-plots, we fit the distribution of eachXi to a t-distribution with a certain degree of freedom,νi, qualitatively selected (tuned) so that the points in the qq-plot lie close to the 45o-slope. If thedegrees of freedom νi’s are approximately the same, we can safely assume that the fit

X ∼ tn(ν, µ,Ω), (40)

is plausible. However, if this is not the case and νi 6= νj , we then need to find the meta t-distributionthat we describe in Section 5.4.

16

Page 23: Implementation of mean-variance and tail optimization

Figure 10: Example of a qq-plot of standard Student’s t-distribution with six degrees of freedom.

5.3 Student’s t-distribution with the same degrees of freedom ν

If the νi of the marginals Xi are the same (or approximately the same), we make the importantassumption (40) that X is Student’s t-distributed. This entails that the portfolio return Xp isStudent’s t-distributed

Xp ∼ t1(ν, uᵀµ, uᵀΩu). (41)

In order to verify that the suggested fit is correct, we need to estimate ν from our data set X. Thisis done by

• estimating the dispersion matrix Ω,

• estimating the degree of freedom ν.

5.3.1 Estimation of the dispersion matrix Ω from the data

Following Hult et al. [5], the best method to obtain the linear correlation matrix R = (Rij) isperhaps through Kendall’s tau rank-correlation matrix, K = (Kij), using the formula

Rij = sin(π

2Kij). (42)

As opposed to the standard correlation, it does not change if the entries are subject to a monotonetransformation, such as multiplication by a positive or negative constant, or by considering thesquare of some entries.

An estimator of the dispersion matrix is obtained through

Ω = diagonal(s(1), . . . , s(n))R diagonal(s(1), . . . , s(n)), (43)

where an estimator of the standard deviation [1]

s(i) =

√√√√ 1

m− 1

m∑j=1

(xji − xi)2

17

Page 24: Implementation of mean-variance and tail optimization

are dispersion measures of the marginals. The xji ’s are the outcomes of the marginals Xi and

xi =1

m

m∑j=1

xji

is the arithmetic mean of Xi where m is the number of observations.

5.3.2 Estimating the degree of freedom ν from the data

Using the maximum likelihood method (ML), we estimate the degree of freedom ν of the mul-tivariate t-distribution (40) given the correlation matrix R. By maximizing the ”log-likelihood”function [5]

log L(ν,Ω;x.,1, . . . , x.,n) =

m∑j=1

log f((xj,1, . . . , xj,m)), (44)

we get the estimate of ν. Here, f is the density function (11) and x.,i are the column vectors ofthe outcomes of the marginals Xi.

5.4 Student’s t-distribution with different degrees of freedom ν

If the degrees of freedom νi of the marginals Xi are different, the assumption (40) may not besatisfactory. The most appropriate way to fit the joint distribution of the vector X is to estimatethe dependence structure with the t-copula CR,ν as defined in (16). The resulting joint distribution,the meta t-distribution, will not be analytically tractable. This means that the problem (39) willnot be analytically solvable and we need to allocate the assets by hand (scenario-based), by makinga large number of simulations from the meta t-distribution. We don’t find this approach reliableand systematic, thus it is beyond the scope of our thesis work.

In order to verify that our ν is correct, we need to estimate ν from our data set X. This is doneby

• Estimating the linear correlation matrix R,

• Estimating the t-copula CtR,ν .

The estimation of the linear correlation matrix R is done in the same way as in (42).

5.4.1 Estimating the t-copula CtR,ν

Using the maximum likelihood method (ML), we estimate the degree of freedom ν of the t-copula(16) given the correlation matrix R, by maximizing the ”log-likelihood” function

log L(ν,R; U.,1, . . . , U.,n) =

m∑j=1

log ctR,ν((Uj,1, . . . , Uj,n)), (45)

where ctR,ν is the density function (17) and U.,i are the column vectors of the outcomes of theuniform distribution variable Ui.

18

Page 25: Implementation of mean-variance and tail optimization

Figure 11: Tail optimization methodology summarized in a flowchart.

5.5 Solving the optimization problem

Knowing the distribution of the portfolio’s return, we can now proceed to solve the optimizationproblem (39). In order to do so, we need rewrite the constraint in the problem (39) to include theµp = uᵀµ as follows.

P(Xp ≤ −Lα) = α if and only if P

(Xp − µpωp

≤ −Lα − µpωp

)= α, (46)

where ω2p = uᵀΩu.

Noting that

T :=Xp − µpωp

∼ t1(ν, 0, 1),

is the standard centered symmetric t-distribution, the quantile kα of T at level α satisfies

P(T ≤ kα) = α,

Therefore, (46) yields

19

Page 26: Implementation of mean-variance and tail optimization

α = 0.1 α = 0.05 α = 0.025, α = 0.001kα kα kα kα

Student-t(5) -1.4759 -2,0150 -2.5706 -3.3649Student-t(8) -1.3968 -1.8595 -2.3060 -2.8965Student-t(10) -1.3722 -1.8125 -2.2281 -2.7638

Table 1: The quantiles for some t-distributions at different levels α [1].

−Lα − µpωp

= κα,

orµp = −Lα − καωp.

This leads to the following formulation of problem (39):

max µp s.t. µp = −Lα − καωp, 1ᵀu = 1. (47)

We solve this problem by applying the methods of convex optimization presented in Sasane andSvanberg [9].

Remark 6

1. The formulation (47) is similar to that of the Markowitz portfolio (20) when the covarianceof the vector X exists (ν > 2). The solutions should thus have the same mathematical formand features. Nevertheless, when the degree of freedom ν ≤ 2, the vector X has no covariancematrix, but the dispersion matrix Ω exists. This means that we cannot use the Markowitzportfolio, but tail optimization is still valid.

2. Even when both methods can be applied and the solutions have the same mathematical formand features, the portfolios provide different asset allocations with regards to risk, as we willshow in Table 3 in Section 6. This is due to the presence of the quantile term κα in (47).

The constraint in (47) can be transformed to µp = −Lα − καωp which implies that (µp + Lα)2 =κ2αω

2p. Setting δ := µ+ Lα1, we may write the last equation as

uᵀ(δδᵀ − κ2αΩ)u = 0,

which givesuᵀ((µ+ L1)(µ+ L1)ᵀ − κ2

αΩ)u = 0. (48)

SettingG := (µ+ L1)(µ+ L1)ᵀ − κ2

αΩ

and noting that it is a symmetric matrix, the problem (39) reads

max µp s.t. uᵀGu = 0, uᵀ1 = 1, (49)

which is a convex optimization problem. We have two constraints, which means we will have twomultipliers λ1 and λ2 in the following Lagrange function

L(u, λ1, λ2) = uᵀµ+ λ1uᵀGu+ λ2(uᵀ1− 1). (50)

The Lagrange multiplier method yields

∂L∂u

= 0,∂L∂λ1

= 0,∂L∂λ2

= 0,

20

Page 27: Implementation of mean-variance and tail optimization

that is, upon expanding the matrix G and defining

Φ := µµᵀ − κ2αΩ,

we get µ+ 2λ1(Lαµ+ Φu) + λ21

ᵀ = 0,

L2α + 2Lαu

ᵀµ+ uᵀΦu = 0,

uᵀ1− 1 = 0.

(51)

If λ1 = 0 then µ = −λ21 = −(λ2, . . . , λ2). However, the µi’s are not necessarily equal, whichmeans λ1 6= 0. Thus, (51) yields

2λ1Φu = (1 + 2λ1Lα)µ+ λ21. (52)

Assuming Φ−1 exists, then, setting β1 := − 12λ1

and β2 := − λ2

2λ1, we get

u = (β1 − Lα)Φ−1µ+ β2Φ−11. (53)

Settinga := µᵀΦ−1µ, b := 1ᵀΦ−1µ, c := 1ᵀΦ−11, d := ac− b2, (54)

and using uᵀ1 = 1, we obtain

β2 =1

c

(1 + (Lα − β1)b

). (55)

From the third equation in (51) we get,

uᵀGu =[β1(µᵀ − b

c1ᵀ) + 1+bLα

c 1ᵀ − Lαµᵀ]G−1

[β1(µ− b

c1) + 1+bLαc 1− Lαµ

]= 0.

Expanding the product givesβ2

1 = Λ2, (56)

where

Λ2 =1

d

((d− c)L2

α − 2bLα − 1). (57)

This equation admits two roots

β1 =

β−1 := −Λ,

β+1 := Λ,

(58)

provided thatΛ2 > 0. (59)

Inserting (58) in (55) we get

β2 =

β−2 := 1

c (1 + (Lα + Λ)b),

β+2 := 1

c (1 + (Lα − Λ)b).(60)

The weights and the returns corresponding to each of the pairs (β−1 , β−2 ) and (β+

1 , β+2 ) are, respec-

tively,

u1 = (Λ− Lα) Φ−1µ+1

c

(1 + (Lα − Λ)b

)Φ−11, µ1

p = µᵀu1 =d

c(Λ− Lα) +

b

c,

and

u2 := (−Λ− Lα) Φ−1µ+1

c

(1 + (Lα + Λ)b

)Φ−11, µ2

p = µᵀu2 = − dc

(Λ + Lα) +b

c.

21

Page 28: Implementation of mean-variance and tail optimization

We have

µ1p − µ2

p =2d

cΛ.

Depending on the sign of dcΛ, we get different optimal weights. For example, if this ratio is negative,we obtain µ1

p ≤ µ2p, from which it follows that u2 is the optimal weight and vice versa.

In conclusion,

Proposition 7 Assume thatd

cΛ < 0. (61)

Then the optimal weights of the tail-optimization portfolio are

u2 := (−Λ− Lα) Φ−1µ+1

c

(1 + (Lα + Λ)b

)Φ−11, (62)

and the corresponding maximum return is

µ2p = µᵀu2 = − d

c(Λ + Lα) +

b

c. (63)

5.6 VaR efficient frontier

The efficient frontier is the curve that exhibits all efficient portfolios in a mean-variance (orMarkowitz) framework. In our setting, an efficient portfolio maximizes the expected return givena probability α that the portfolio return Xp is below −Lα (a level of Value-at-Risk). An informed(or rational) investor will always favor investing in an efficient portfolio.

Using (63), Problem (47) is explicitly solved through the mean-VaR efficient frontier equation:

Lα = −µp +

√1

d

((d− c)µ2

p + 2bµp − a). (64)

In particular, by equation (64), the minimum VaR portfolio is the one that minimizes the VaR asa function of µp. The minimum value is the one for which the derivative of Lα with regard to µpis zero:

∂Lα∂µp

= −1 +(d− c)µp + b√

d(

(d− c)µ2p + 2bµp − a

) = 0.

This equation yields the minimum VaR expected return

µtomin =

b

c− d+

d

c(c− d)

√c(a− 1), (65)

provided thatc(a− 1) ≥ 0.

The minimum VaR, is the value of Lα in equation (64) at µtop,min:

Ltoα,min =

b− cµtop,min

d. (66)

Given (65) and (66), equation (62) yields the weights utomin of the minimum VaR portfolio:

utomin =

cµtop,min − bd

(Φ−1µ− d

cΦ−11

)+

1

cΦ−11. (67)

22

Page 29: Implementation of mean-variance and tail optimization

5.7 Results from implementation on data

5.7.1 Data processing

The following qq-plots are acquired when applying the method on the assets 1-5:

(a) qq-plot of asset 1 (b) qq-plot of asset 2

(c) qq-plot of asset 3

(d) qq-plot of asset 4 (e) qq-plot of asset 5

Figure 12: Fitting the marginal distributions to t-distribution using qq-plot technique.

This results in the following degrees of freedom:

ν1 = 6, ν2 = 8, ν3 = 6, ν4 = 5, ν5 = 6.

We can also use the Maximum Likelihood (ML) method to determine the νi’s, which results in:

ν1 = 5.2022, ν2 = 5.1029, ν3 = 5.8191, ν4 = 4.3467, ν5 = 4.3398

23

Page 30: Implementation of mean-variance and tail optimization

The difference between the values of the degrees of freedom lies in the fact that while the qq-plotonly focuses on fitting the left tail, the ML methods considers the whole distribution. While bothmethods gave comparable degrees of freedom for our data, the value ν2 = 5.1029 of the degreeof freedom of the second asset gives a skewed fit compared to the value ν2 = 8 obtained by theqq-plot.

The expected return µ is

µ = 10−3(1.695 0.9670 0.0793 −0.421 2.217

)ᵀ. (68)

The rank-correlation matrix of our data is

K =

1 0.1370 0.1984 0.2040 0.1446

0.1370 1 0.1179 0.1996 0.09700.1984 0.1179 1 0.1490 0.14320.2040 0.1996 0.1490 1 0.10130.1446 0.0970 0.1432 0.1013 1

.

From formula (42) we get

R =

1 0.2135 0.3066 0.3149 0.2251

0.2135 1 0.1842 0.3084 0.15170.3066 0.1842 1 0.2319 0.22310.3149 0.3084 0.1490 1 0.15840.2251 0.1517 0.1432 0.1584 1

.

Thus the corresponding dispersion matrix Ω, given by (43), is

Ω = 10−5

7.009 1.631 4.291 1.952 1.9801.631 8.319 2.808 2.083 1.4544.291 2.808 27.94 2.870 3.9171.952 2.083 2.870 5.482 0.1581.980 1.454 3.917 1.232 11.03

.

Using (44), the ML estimate of ν yields

ν = 10.1416 ≈ 10, (69)

which means that our data-set X ∼ t5(10, µ,Ω).

We havea = −0.0585, b = −15.4, c = −1.709 · 104, d = 7.617 · 102, Λ = 0.0171

Thus, the ratio (61) dcΛ = −0.7640 < 0. Hence, Proposition 7 is in force. Using the function (64),

we get the efficient frontier curves for the VaR-framework at levels α = (0.1, 0.05, 0.025, 0.01) asshown in Figure 13.

24

Page 31: Implementation of mean-variance and tail optimization

5.7.2 Minimum VaR portfolio

Figure 13: The efficient frontier curves for the VaR-framework at levels α = (0.1, 0.05, 0.025, 0.01)

The resulting weights u, given by equation (67) for the minimum VaR portfolio at levels α =(0.1, 0.05, 0.025, 0.01) is shown below in Table 2.

Asset α = 0.1 α = 0.05 α = 0.025, α = 0.011 0.3338 0.3140 0.3028 0.29342 0.2230 0.2248 0.2218 0.21933 -0.0298 -0.0248 -0.0220 -0.01204 0.2346 0.2687 0.2881 0.30435 0.2315 0.2173 0.2092 0.2025

Table 2: The weights of the minimum VaR portfolio at different levels α.

These weights correspond to the following µtop,min values

µtop,min = (1.2008 1.1170 1.0692 1.0293) · 10−3. (70)

And from the Figure 13, we get the following Ltoα,min for each of weights in Table 2

Ltoα,min = (6.6688 9.1759 11.525 14.537) · 10−3.

25

Page 32: Implementation of mean-variance and tail optimization

6 Analysis

In this section, we compare the minimum variance and VaR portfolios’ expected returns and com-pare the portfolios’ weights with respect to asset allocation. Moreover, we analyze the performanceof the portfolios’ out-of-sample and inspect the excess returns. We set the confidence level usedin the tail optimization portfolio to 90% (α = 0.1). A similar analysis can be performed for otherlevels of confidence.

6.1 Comparison of the expected returns

As presented in (38), the expected return of the minimum variance portfolio is

µmvp,min = 1.0115 · 10−3,

and from (70), the expected return of the minimum VaR portfolio is

µtop,min = 1.2008 · 10−3.

The minimum VaR portfolio generated a larger expected return. This suggests that it was worth-while to take the tail events into consideration.

6.2 Comparison of the weights with respect to asset allocation

We now use formulas (26) and (62) to extract the weights that correspond to a given expectedreturn µp. In order to identify which assets contributed the most to µp, we select a value relativelyclose to the minimum expected returns.

Setting µp = 2 · 10−3, results in the following weights:

Asset νi utoopt umvopt σ2 · 10−5

1 6 0.1623 0.3276 5.1662 8 0.1848 0.5361 3.3913 6 0.0135 -0.0247 5.2984 5 0.5310 -0.2160 6.1435 6 0.1083 0.3770 6.010

Table 3: Weights of the VaR and mean variance portfolios, their corresponding degrees of freedom and variances

The VaR portfolio looks more balanced with regard to the distribution of the degrees of freedom inthe sense that it suggests a long-only (buy) asset allocation, while the Markowitz portfolio suggestsa long-short strategy.

6.3 Performance analysis

Figure 14 is a plot of the performance of the minimum variance and minimum VaR portfoliosrealized over the ”future” time period defined in Section 3.

26

Page 33: Implementation of mean-variance and tail optimization

Figure 14: Realized prices Pto and Pmv.

Setting Xmv as benchmark, we plot the difference in returns Xto−Xmv each day in Figure 15 andcompute the number of times we get positive vs negative difference. This may be indicative of theperformance of the minimum VaR portfolio compared to the minimum variance portfolio.

Figure 15: Difference in daily returns Xto −Xmv during future time period.

The number of times we get a positive difference is 165 and negative difference is 166. Using weeklydata, displayed in Figure 16, the observed phenomenon is similar. The resulting number of positivedifferences is 33 and the number of negative differences is 34.

27

Page 34: Implementation of mean-variance and tail optimization

Figure 16: Difference in weekly returns Xto −Xmv during future time period.

6.4 Excess return

Excess return is defined as the difference between the realized return and the expected return. Wecompute the difference between the realized weekly returns and the expected weekly returns forboth portfolios and plot them

Figure 17: Excess returns during future time period.

28

Page 35: Implementation of mean-variance and tail optimization

7 Conclusions

In this thesis, we have implemented two methods of portfolio choice with focus on safety-firstoptimization, meaning that both maximize expected return given some restriction on risk. Thefirst method, Markowitz mean-variance, uses the variance as risk measure. The second method,tail optimization, uses the probability of left-tail events as risk measure. There are significantdifferences between the level of knowledge and skills required for each model; the Markowitz mean-variance is relatively simple compared to tail optimization.

When applied to a portfolio with relatively low to medium risk, the minimum VaR portfolio resultedin a larger expected return µp,min in-sample, which suggests that the tail optimization is worthwhileas tail-events may have had a significant impact. When tested out-of-sample, the minimum varianceand minimum VaR portfolios gave similar expected and realized returns, meaning that the tailoptimization method was not beneficial as tail-events may not have had a major impact. This isan indication of an important aspect of portfolio choice based on historical data of which assetmanagers should be aware; they do not always reflect future market conditions.

While our study is not a complete analysis, it suggests that it may not always be necessary forasset managers to perform complex methods to construct optimal portfolios for low to mediumrisk assets. Further studies can be conducted on larger, more complex portfolios with high riskprofiles and also include risk-free assets.

It is also important to understand how to best apply portfolio optimization techniques in practice.An asset manager would not continuously re-balance their portfolios as no market is frictionless.Such a portfolio would have extraordinarily high transaction fees and would most likely not beprofitable. They are therefore continuously faced with a dilemma: re-balance their portfolio basedon new data and pay transaction fees, or utilize the old portfolio. A possible solution could bethat the asset manager could define a set of acceptable risk-return profiles and only re-balance ifthe portfolio falls outside it.

The methods outlined in this study are interesting from a theoretical point of view, but not asmuch in application. Most asset managers do not aim only to minimize risk or to maximize return;they seek a risk-return profile that suits their preferences. Asset managers should carefully considerwhether or not to apply minimum risk methods as they may not result in positive expected returns.

29

Page 36: Implementation of mean-variance and tail optimization

References

[1] Bloom G, Enger J, Englund G, Grandell J, Holst L. Sannolikhetsteori och statistikteori medtillampningarn. Springer Finance. Studentlitteratur; 2004.

[2] Markowitz H. Portfolio Selection. The Journal of Finance. 1952;7(1).

[3] Berk JB, DeMarzo PM. Corporate Finance. Pearson Custom Business Resources. PearsonAddison Wesley; 2007.

[4] Armerin F. An Introduction to the Theory of Risky Investments. Lecture Notes. KTH Math-ematics; 2004.

[5] Hult H, Lindskog F, Hammarlid O, Rehn CJ. Risk and Portfolio Analysis: Principles andMethods. Springer Series in Operations Research and Financial Engineering. Springer NewYork; 2012.

[6] Meucci A. Risk and Asset Allocation. Springer Finance. Springer Berlin Heidelberg; 2007.

[7] Dual S, De Giorgi E, Lindskog F, McNeil A. The grouped t-copula with an application tocredit risk. RISK. 2003;16(11).

[8] Sklar M. Fonctions de Repartition A N Dimensions Et Leurs Marges. Universite Paris 8; 1959.

[9] Sasane A, Svanberg K. Optimization. KTH Mathematics; 2015.

30

Page 37: Implementation of mean-variance and tail optimization

Appendix

A Mathematical Proofs

A.1 Positive Definitive Matrix A

Claim 8 The matrix A is positive definite under the assumption that the covariance matrix V ispositive definite.

A =

[µᵀV −1µ µᵀV −11µᵀV −11 1ᵀV −11

](71)

Proof. We begin by reviewing the definition of a positive definite matrix.

Definition 9 In linear algebra, a square matrix, M is said to be positive definite if it fulfills thefollowing criterion:

xᵀMx > 0, ∀x =

[x1

x2

]∈ R2 | x 6= 0. (72)

In our case, the matrix A can be rewritten as:

A =

[µᵀ

1ᵀ

]V −1

[µ 1

].

We can now analyze whether or not A fulfills the definition of a positive definite matrix, (72).

xᵀAx =[x1 x2

] [µᵀ

1ᵀ

]V −1

[µ 1

] [x1

x2

]= [x1µ + x21]ᵀV −1x1µ + x21]

The covariance matrix V −1 is positive definite under the assumption that V is positive definite. µis ”assumed not to be proportional to 1 meaning that x1µ + x21 6= 0”. So:

xᵀAx = [x1µ + x21]ᵀV −1[x1µ + x21] > 0.

B MATLAB

B.1 Data processing

This function is used to convert asset prices into data used in portfolio analysis.

1 %% Data processing %%2 function [prices, returns, weekly_prices, weekly_returns,...3 h_weekly_prices, h_weekly_returns,...4 f_weekly_prices, f_weekly_returns,...5 h_daily_prices, h_daily_returns,...6 f_daily_prices, f_daily_returns, ...7 norm_h_daily_prices, norm_h_weekly_prices,...8 norm_f_daily_prices, norm_f_weekly_prices] = data_processing9

10 % --- Read data from file ---11 fileID = fopen(’prices.csv’);12 prices = csvread(’prices.csv’,1,1);13 fclose(fileID);14

15 % --- Convert prices into returns ---16 returns = prices(2:end,:)./prices((1:end-1),:) - 1;17

18 % --- Thin data: daily -> weekly ---

31

Page 38: Implementation of mean-variance and tail optimization

19 weekly_prices = prices(2:5:end+1, :);20 weekly_returns = returns(1:5:end, :);21

22 % --- Set returns for time period T_start, ..., T_now = 1, ..., 250 ---23 N = 250; % Number of weeks in historical data24 T = size(weekly_prices,1) - N;25 h_weekly_prices = weekly_prices(1:end-T, :);26 h_weekly_returns = weekly_returns(1:end-T, :); % Historical data27 h_daily_prices = prices(1:N*5+1,:);28 h_daily_returns = returns(1:N*5, :);29

30 % --- Set returns for time period T_now, ..., T_end = 251, ..., 317 ---31 f_weekly_prices = weekly_prices(end-T+1:end,:);32 f_weekly_returns = weekly_returns(end-T+1:end,:); % "Future" data33 f_daily_prices = prices(N*5+2:end,:);34 f_daily_returns = returns(N*5+1:end, :);35

36 % --- Normalize37 norm_h_daily_prices = []; norm_h_weekly_prices = [];38 norm_f_daily_prices = []; norm_f_weekly_prices = [];39 for j = 1:size(prices,2)40 norm_h_daily_prices = [norm_h_daily_prices h_daily_prices(:,j)./h_daily_prices

(1,j);];41 norm_h_weekly_prices = [norm_h_weekly_prices h_weekly_prices(:,j)./

h_weekly_prices(1,j);];42 norm_f_daily_prices = [norm_f_daily_prices f_daily_prices(:,j)./f_daily_prices

(1,j);];43 norm_f_weekly_prices = [norm_f_weekly_prices f_daily_prices(:,j)./f_daily_prices

(1,j);];44 end45 end

B.2 Data visualization

This code is used to visualize the asset prices. It results in the figures used in Section 3.

1 clear all; clc; clf; close all; format compact2

3 %% Data processing %%4 [prices, returns, weekly_prices, weekly_returns,...5 h_weekly_prices, h_weekly_returns,...6 f_weekly_prices, f_weekly_returns,...7 h_daily_prices, h_daily_returns,...8 f_daily_prices, f_daily_returns, ...9 norm_h_daily_prices, norm_h_weekly_prices,...

10 norm_f_daily_prices, norm_f_weekly_prices] = data_processing;11

12 %% Portfolio weights %%13 u_mv = [0.1364; 0.4920; 0.1329; 0.0897; 0.1491];14 u_to = [0.3338; 0.2230; -0.0298; 0.2346; 0.2315];15

16 %% Portfolio prices %%17 P_mv = u_mv’*norm_f_daily_prices’;18 P_to = u_to’*norm_f_daily_prices’;19

20 %% Portfolio returns %%21 X_mv = u_mv’*f_daily_returns’;22 X_to = u_to’*f_daily_returns’;23

24 %% Total portfolio returns %%25 X_mv_tot = P_mv(end)26 X_to_tot = P_to(end)27

28 %% Plot of portfolio prices during future time period %%29 figure30 plot(P_mv, ’b’), hold on31 plot(P_to, ’r’),

32

Page 39: Implementation of mean-variance and tail optimization

32 hleg = legend(’$P_mv$’,’$P_to$’, ’Location’,’northwest’);33 set(hleg,’Interpreter’,’latex’);34 set(hleg,’fontsize’,10)35 xlabel(’Time [days]’,’Interpreter’,’latex’)36 ylabel(’Normalized price’,’Interpreter’,’latex’)37 hold off;38 print(’res/f_prices_ports’, ’-dpng’, ’-r600’);39

40 %% Plot of portfolio return during future time period %%41 figure42 plot(X_mv, ’b’), hold on43 plot(X_to, ’r’),44 hleg = legend(’$X_mv$’,’$X_to$’, ’Location’,’southwest’);45 set(hleg,’Interpreter’,’latex’);46 set(hleg,’fontsize’,10)47 xlabel(’Time [days]’,’Interpreter’,’latex’)48 ylabel(’Return’, ’Interpreter’,’latex’)49 hold off;50 print(’res/f_returns_ports_daily’, ’-dpng’, ’-r600’);51

52 %% Plot the difference in returns $X_to - X_mv$ %%53 figure54 X_mv_w = u_mv’*f_weekly_returns’;55 X_to_w = u_to’*f_weekly_returns’;56 difference = X_to_w-X_mv_w;57 plot(difference, ’b’)58 xlabel(’Time [weeks]’,’Interpreter’,’latex’)59 ylabel(’$X_to-X_mv$’,’Interpreter’,’latex’)60 hold off;61 print(’res/f_difference_ports_weekly’, ’-dpng’, ’-r600’);62 neg = length(find ( difference < 0 ))63 pos = length(find ( difference > 0 ))64

65 figure66 X_mv_w = u_mv’*f_daily_returns’;67 X_to_w = u_to’*f_daily_returns’;68 difference = X_to_w-X_mv_w;69 plot(difference, ’b’)70 xlabel(’Time [days]’,’Interpreter’,’latex’)71 ylabel(’$X_to-X_mv$’,’Interpreter’,’latex’)72 hold off;73 print(’res/f_difference_ports_daily’, ’-dpng’, ’-r600’);74 neg = length(find ( difference < 0 ))75 pos = length(find ( difference > 0 ))76

77 %% Excess return %%78 figure79 mu_p_mv_min = 1.0115*10ˆ-3;80 mu_p_to_min = 1.2008*10ˆ-3;81

82 excess_mv = X_mv_w-mu_p_mv_min;83 excess_to = X_to_w-mu_p_to_min;84

85 plot(excess_mv, ’b’); hold on;86 plot(excess_to, ’r’); hold on;87 xlabel(’Time [week]’,’Interpreter’,’latex’)88 hleg = legend(’$X_mv-\muˆmv_p,min$’,’$X_to-\muˆto_p,min$’, ’Location’,’

southwest’);89 set(hleg,’Interpreter’,’latex’);90 set(hleg,’fontsize’,10)91 hold off;92 print(’res/f_excess_return’, ’-dpng’, ’-r600’);93 excess_mv(end)94 excess_to(end)

33

Page 40: Implementation of mean-variance and tail optimization

B.3 Markowitz mean-variance

This code is for the implementation of the Markowitz portfolio optimization and is based on thefunction B.1.

1 %% Data processing %%2 [prices, returns, weekly_prices, weekly_returns,...3 h_weekly_prices, h_weekly_returns,...4 f_weekly_prices, f_weekly_returns,...5 h_daily_prices, h_daily_returns,...6 f_daily_prices, f_daily_returns, ...7 norm_h_daily_prices, norm_h_weekly_prices,...8 norm_f_daily_prices, norm_f_weekly_prices] = data_processing;9

10 %% Defining Variables %%11 V = cov(h_weekly_returns); %Variance matrix12 my = mean(h_weekly_returns)’;%+1; %Mean asset returns, Var correct if +113 one = ones(5,1);14 a = my’*inv(V)*my;15 b = my’*inv(V)*one;16 c = one’*inv(V)*one;17 d = a*c-bˆ2;18

19 %% Minimum variance portfolio optimization %%20 u_mv = (1/c)*inv(V)*one %portfolio weights21 var_mv = 1/c %portfolio variance22 SD_mv = sqrt(var_mv); %portfolio standard deviation23 my_mv = b/c %portfolio return24

25 figure,26 pie(u_mv, ’1’,’2’,’3’,’4’,’5’) %Weights can be plotted as a piie-diagram as all are

postive27

28 %% Markowitz Mean-Variance Portfolio Optimization %%29 %example of MMV portfolio for a given expected return30 my_mmv = 0.002; %given expected return31

32 u_mmv = inv(V)*((a*one-b*my)+(c*my - b*one)*my_mmv)/d %MMV portfolio wieghts33 var_mmv = (c*my_mmvˆ2-2*b*my_mmv+a)/d %MMV portfolio variance34

35 %% Efficient frontier %%36 my_p = (-0.005: 10ˆ-5: 0.015);37 SD_p = sqrt((c*my_p.ˆ2-2*b*my_p+a)/d);38

39 figure40 plot(SD_p,my_p); hold on %Plot of efficient frontier41 plot(SD_mv, my_mv, ’r*’) %Minimum Variance portfolio42 xlabel(’\sigma_p’)43 ylabel(’\mu_p’)44

45 %% Plot of portfolio price during future time period %%46 P_mv = u_mv’*norm_f_daily_prices’; %Value of portfolio47

48 figure49 plot(norm_f_daily_prices), hold on50 plot(P_mv, ’k--’, ’LineWidth’,2) %plot normalized portfolio value51 legend(’P_1’, ’P_2’, ’P_3’, ’P_4’, ’P_5’,’P_p’, ’Location’,’northwest’)52 xlabel(’Time [days]’)53 ylabel(’Price [SEK]’)54 hold off;55

56 %% Plot of portfolio return during future time period %%57 X_mv = u_mv’*f_weekly_returns’;%Value of portfolio58 X_mv_tot = P_mv(end) - 1; %total return over entire period59

60 figure61 plot(f_weekly_returns), hold on62 plot(X_mv, ’k--’, ’LineWidth’,1) %plot normalized portfolio value

34

Page 41: Implementation of mean-variance and tail optimization

63 legend(’X_1’, ’X_2’, ’X_3’, ’X_4’, ’X_5’,’X_p’, ’Location’,’southwest’)64 xlabel(’Time [days]’)65 ylabel(’Price [SEK]’)66 hold off;

B.4 Tail optimization

The code below is for the implementation of the tail optimized portfolio and utilizes function B.1

1 %% Data processing %%2 [prices, returns, weekly_prices, weekly_returns,...3 h_weekly_prices, h_weekly_returns,...4 f_weekly_prices, f_weekly_returns,...5 h_daily_prices, h_daily_returns,...6 f_daily_prices, f_daily_returns, ...7 norm_h_daily_prices, norm_h_weekly_prices,...8 norm_f_daily_prices, norm_f_weekly_prices] = data_processing;9

10 h_data = h_weekly_returns;11 f_data = f_weekly_returns;12

13 h_rows = size(h_data,1);14 h_columns = size(h_data,2);15 f_rows = size(f_data,1);16 f_columns = size(f_data,2);17

18 %% Estimating dispersion matrix Omega %%19 % --- Estimating rank-correlation matrix K using Kendall’s tau ---20 K = corr(h_data,’type’,’Kendall’);21

22 % --- Correlation matrix R ---23 R = sin(0.5*pi*K);24

25 % --- Dispersion matrix ---26 s = zeros(1,h_columns);% Use standard deviation as measure of dispersion27 for i = 1:h_columns28 s(i) = std(h_data(i,:));29 end30 Omega = diag(s)*R*diag(s);31

32 %% Estimating dof v from dataset %%33 data = h_data’;34 N = numel(data(1,:)); % Number of simulations35 d = numel(data(:,1)); % Dimension36

37 % Specify an initial guess, any positive number. This is required by38 % the optimization algorithm fminsearch.39 init_guess = 10;40 % Function to optimize41 find_nu = @(nu) LikelihoodMultivar(nu,R,data);42 % Optimization that gives nu (optimal degree of freedom) and43 % max-likelihood (the corresponding likelihood).44 [nu, max_likelihood] = fminsearch(find_nu, init_guess)45

46 %% Calculating the weights %%47 mu = mean(h_data)’;48

49 alpha = [0.1 0.05 0.025 0.01];50 figure51 u_mins = []; L_alpha_mins = []; mu_mins = [];52 for i = 1:size(alpha, 2);53 kappa = tinv(alpha(:,i),nu);54

55 Phi = mu*mu’-kappaˆ2*Omega;56 one = ones(1, h_columns);57

58 a = mu’*inv(Phi)*mu;

35

Page 42: Implementation of mean-variance and tail optimization

59 b = one*inv(Phi)*mu;60 c = one*inv(Phi)*one’;61 d = a*c-bˆ2;62

63 mu_p = (-0.005: 10ˆ-5: 0.015);64

65 L_alpha = -mu_p + sqrt(1/d.* ((d-c).*mu_p.ˆ2 + 2.*b.*mu_p - a));66 plot(L_alpha, mu_p); hold on;67

68 mu_min = b/(c-d) + d/(c*(c-d))*sqrt(c*(a-1))69 L_alpha_min = (b-(c*mu_min))/d;70 u_min = (c*mu_min - b)/d * (inv(Phi)*mu - b/c*inv(Phi)*one’)+1/c*inv(Phi)*one’;71

72 u_mins = [u_mins u_min;];73 L_alpha_mins = [L_alpha_mins L_alpha_min;];74 mu_mins = [mu_mins mu_min;];75 end76 hleg = legend(’$\alpha = 0.1$’, ’$\alpha = 0.05$’, ’$\alpha = 0.025$’, ’$\alpha = 0.01$’

, ’Location’,’southeast’);77 set(hleg,’Interpreter’,’latex’);78 set(hleg,’fontsize’,10) ;79 xlabel(’L_\alpha’)80 ylabel(’\mu_p’)81 plot(L_alpha_mins, mu_mins, ’r*’)82 mu_mins*10ˆ383 L_alpha_mins*10ˆ384 mu_pa = 0.00285 kappa = tinv(0.1,nu);86 Phi = mu*mu’-kappaˆ2*Omega;87 a = mu’*inv(Phi)*mu;88 b = one*inv(Phi)*mu;89 c = one*inv(Phi)*one’;90 d = a*c-bˆ291 L_alpha = -mu_pa + sqrt(1/d* ((d-c)*mu_paˆ2 + 2*b*mu_pa - a))92 Lambda = sqrt(1/d*((d-c)*L_alphaˆ2 - 2*b*L_alpha -1))93 u_opt = (Lambda - L_alpha)*inv(Phi)*mu + 1/c*(1+(L_alpha -Lambda)*b)*inv(Phi)*one’94 check = d/c*Lambda*10ˆ395

96

97 %% Plot of portfolio price during future time period %%98 u_opt = u_mins(:,1);99 P_p = u_opt’*norm_f_daily_prices’; %Value of portfolio

100 P_p(end)-1101 figure102 plot(norm_f_daily_prices), hold on103 plot(P_p, ’k--’, ’LineWidth’,2) %plot normalized portfolio value104 hleg = legend(’$P_1$’, ’$P_2$’, ’$P_3$’, ’$P_4$’, ’$P_5$’,’$P_p$’, ’Location’,’southeast

’);105 set(hleg,’Interpreter’,’latex’);106 set(hleg,’fontsize’,10) ;107 xlabel(’Time [days]’, ’Interpreter’,’latex’)108 ylabel(’Normalized price ’, ’Interpreter’,’latex’)109 hold off;110

111 %% Plot of portfolio return during future time period %%112 u_opt = u_mins(:,1);113 X_p = u_opt’*f_daily_returns’;114 X_p(end)115 figure116 plot(f_daily_returns), hold on117 plot(X_p, ’k--’, ’LineWidth’,2) %plot normalized portfolio value118 hleg = legend(’$X_1$’, ’$X_2$’, ’$X_3$’, ’$X_4$’, ’$X_5$’,’$X_p$’, ’Location’,’southwest

’);119 set(hleg,’Interpreter’,’latex’);120 set(hleg,’fontsize’,10) ;121 xlabel(’Time [days]’, ’Interpreter’,’latex’)122 ylabel(’Normalized returns’, ’Interpreter’,’latex’)

36

Page 43: Implementation of mean-variance and tail optimization

123 hold off;

B.5 Portfolio analysis

The code below is for implementation of the analysis

1 clear all; clc; clf; close all; format compact2

3 %% Data processing %%4 [prices, returns, weekly_prices, weekly_returns,...5 h_weekly_prices, h_weekly_returns,...6 f_weekly_prices, f_weekly_returns,...7 h_daily_prices, h_daily_returns,...8 f_daily_prices, f_daily_returns, ...9 norm_h_daily_prices, norm_h_weekly_prices,...

10 norm_f_daily_prices, norm_f_weekly_prices] = data_processing;11

12 %% Portfolio weights %%13 u_mv = [0.1364; 0.4920; 0.1329; 0.0897; 0.1491];14 u_to = [0.3338; 0.2230; -0.0298; 0.2346; 0.2315];15

16 %% Portfolio prices %%17 P_mv = u_mv’*norm_f_daily_prices’;18 P_to = u_to’*norm_f_daily_prices’;19

20 %% Portfolio returns %%21 X_mv = u_mv’*f_daily_returns’;22 X_to = u_to’*f_daily_returns’;23

24 %% Total portfolio returns %%25 X_mv_tot = P_mv(end)26 X_to_tot = P_to(end)27

28 %% Plot of portfolio prices during future time period %%29 figure30 plot(P_mv, ’b’), hold on31 plot(P_to, ’r’),32 hleg = legend(’$P_mv$’,’$P_to$’, ’Location’,’northwest’);33 set(hleg,’Interpreter’,’latex’);34 set(hleg,’fontsize’,10)35 xlabel(’Time [days]’,’Interpreter’,’latex’)36 ylabel(’Normalized price’,’Interpreter’,’latex’)37 hold off;38 print(’res/f_prices_ports’, ’-dpng’, ’-r600’);39

40 %% Plot of portfolio return during future time period %%41 figure42 plot(X_mv, ’b’), hold on43 plot(X_to, ’r’),44 hleg = legend(’$X_mv$’,’$X_to$’, ’Location’,’southwest’);45 set(hleg,’Interpreter’,’latex’);46 set(hleg,’fontsize’,10)47 xlabel(’Time [days]’,’Interpreter’,’latex’)48 ylabel(’Return’, ’Interpreter’,’latex’)49 hold off;50 print(’res/f_returns_ports_daily’, ’-dpng’, ’-r600’);51

52 %% Plot the difference in returns $X_to - X_mv$ %%53 figure54 X_mv_w = u_mv’*f_weekly_returns’;55 X_to_w = u_to’*f_weekly_returns’;56 difference = X_to_w-X_mv_w;57 plot(difference, ’b’)58 xlabel(’Time [weeks]’,’Interpreter’,’latex’)59 ylabel(’$X_to-X_mv$’,’Interpreter’,’latex’)60 hold off;61 print(’res/f_difference_ports_weekly’, ’-dpng’, ’-r600’);

37

Page 44: Implementation of mean-variance and tail optimization

62 neg = length(find ( difference < 0 ))63 pos = length(find ( difference > 0 ))64

65 figure66 X_mv_w = u_mv’*f_daily_returns’;67 X_to_w = u_to’*f_daily_returns’;68 difference = X_to_w-X_mv_w;69 plot(difference, ’b’)70 xlabel(’Time [days]’,’Interpreter’,’latex’)71 ylabel(’$X_to-X_mv$’,’Interpreter’,’latex’)72 hold off;73 print(’res/f_difference_ports_daily’, ’-dpng’, ’-r600’);74 neg = length(find ( difference < 0 ))75 pos = length(find ( difference > 0 ))76

77 %% Excess return %%78 figure79 mu_p_mv_min = 1.0115*10ˆ-3;80 mu_p_to_min = 1.2008*10ˆ-3;81

82 excess_mv = X_mv_w-mu_p_mv_min;83 excess_to = X_to_w-mu_p_to_min;84

85 plot(excess_mv, ’b’); hold on;86 plot(excess_to, ’r’); hold on;87 xlabel(’Time [week]’,’Interpreter’,’latex’)88 hleg = legend(’$X_mv-\muˆmv_p,min$’,’$X_to-\muˆto_p,min$’, ’Location’,’

southwest’);89 set(hleg,’Interpreter’,’latex’);90 set(hleg,’fontsize’,10)91 hold off;92 print(’res/f_excess_return’, ’-dpng’, ’-r600’);93 excess_mv(end)94 excess_to(end)

38