Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

optimalPortfolio

Optimal portfolio


Description

Function wich computes the optimal portfolio's weights.

Usage

optimalPortfolio(Sigma, mu = NULL, semiDev = NULL, control = list())

Arguments

Sigma

a (N x N) covariance matrix.

mu

a (N x 1) vector of expected returns. Default: mu = NULL.

semiDev

a vector (N x 1) of semideviations. Default: semiDev = NULL.

control

control parameters (see *Details*).

Details

The argument control is a list that can supply any of the following components:

  • type method used to compute the optimal portfolio, among 'mv', 'minvol', 'invvol', 'erc', 'maxdiv', 'riskeff' and 'maxdec' where:

    'mv' is used to compute the weights of the mean-variance portfolio. The weights are computed following this equation:

    w = 1 / γ Σ^{-1} μ

    .

    'minvol' is used to compute the weights of the minimum variance portfolio.

    'invvol' is the inverse volatility portfolio.

    'erc' is used to compute the weights of the equal-risk-contribution portfolio. For a portfolio w, the percentage volatility risk contribution of the i-th asset in the portfolio is given by:

    RC_i = w_i[Σ w]_i / (w' Σ w)

    . Then we compute the optimal portfolio by solving the following optimization problem:

    argmin { ∑_{i=1}^{N} (RC_i - 1/N)^2}

    .

    'maxdiv' is used to compute the weights of the maximum diversification portfolio where:

    DR(w) = (w' σ)/(√(w' Σ w)) ≥ 1

    is used in the optimization problem.

    'riskeff' is used to compute the weights of the risk-efficient portfolio:

    w = argmax ( w'J ξ)√(w'Σ w)

    where J is a (N x 10) matrix of zeros whose (i,j)-th element is one if the semi-deviation of stock i belongs to decile j,ξ = (ξ_1,…,ξ_{10})'.

    'maxdec' is used to compute the weights of the maximum-decorrelation portfolio:

    w = argmax {1- √(w' R w)}

    where R is the correlation matrix.

    Default: type = 'mv'.

    These portfolios are summarized in Ardia and Boudt (2015) and Ardia et al. (2017). Below we list the various references.

  • constraint constraint used for the optimization, among 'none', 'lo', 'gross' and 'user', where: 'none' is used to compute the unconstraint portfolio, 'lo' is the long-only constraints (non-negative weighted), 'gross' is the gross exposure constraint, and 'user' is the set of user constraints (typically lower and upper boundaries. Default: constraint = 'none'. Note that the summability constraint is always imposed.

  • LB lower boundary for the weights. Default: LB = NULL.

  • UB lower boundary for the weights. Default: UB = NULL.

  • w0 starting value for the optimizer. Default: w0 = NULL takes the equally-weighted portfolio as a starting value. When LB and UB are provided, it is set to mid-point of the bounds.

  • gross.c gross exposure constraint. Default: gross.c = 1.6.

  • gamma risk aversion parameter. Default: gamma = 0.89.

  • ctr.slsqp list with control parameters for slsqp function.

Value

A (N x 1) vector of optimal portfolio weights.

Author(s)

David Ardia, Kris Boudt and Jean-Philippe Gagnon Fleury.

References

Amenc, N., Goltz, F., Martellini, L., Retowsky, P. (2011). Efficient indexation: An alternatice to cap-weightes indices. Journal of Investment Management 9(4), pp.1-23.

Ardia, D., Boudt, K. (2015). Implied expected returns and the choice of a mean-variance efficient portfolio proxy. Journal of Portfolio Management 41(4), pp.66-81.

Ardia, D., Bolliger, G., Boudt, K., Gagnon-Fleury, J.-P. (2017). The Impact of covariance misspecification in risk-based portfolios. Annals of Operations Research 254(1-2), pp.1-16. doi: 10.1007/s10479-017-2474-7

Choueifaty, Y., Coignard, Y. (2008). Toward maximum diversification. Journal of Portfolio Management 35(1), pp.40-51.

Choueifaty, Y., Froidure, T., Reynier, J. (2013). Properties of the most diversified portfolio. Journal of Investment Strategies 2(2), pp.49-70.

Das, S., Markowitz, H., Scheid, J., Statman, M. (2010). Portfolio optimization with mental accounts. Journal of Financial and Quantitative Analysis 45(2), pp.311-334.

DeMiguel, V., Garlappi, L., Uppal, R. (2009). Optimal versus naive diversification: How inefficient is the 1/n portfolio strategy. Review of Financial Studies 22(5), pp.1915-1953.

Fan, J., Zhang, J., Yu, K. (2012). Vast portfolio selection with gross-exposure constraints. Journal of the American Statistical Association 107(498), pp.592-606.

Maillard, S., Roncalli, T., Teiletche, J. (2010). The properties of equally weighted risk contribution portfolios. Journal of Portfolio Management 36(4), pp.60-70.

Martellini, L. (2008). Towards the design of better equity benchmarks. Journal of Portfolio Management 34(4), Summer,pp.34-41.

Examples

# Load returns of assets or portfolios
data("Industry_10")
rets = Industry_10

# Mean estimation
mu = meanEstimation(rets)

# Covariance estimation
Sigma = covEstimation(rets)

# Semi-deviation estimation
semiDev = semidevEstimation(rets)

# Mean-variance portfolio without constraint and gamma = 0.89
optimalPortfolio(mu = mu, Sigma = Sigma)

# Mean-variance portfolio without constraint and gamma = 1
optimalPortfolio(mu = mu, Sigma = Sigma, 
  control = list(gamma = 1))

# Mean-variance portfolio without constraint and gamma = 0.89
optimalPortfolio(mu = mu, Sigma = Sigma, 
  control = list(type = 'mv'))

# Mean-variance portfolio without constraint and gamma = 0.89
optimalPortfolio(mu = mu, Sigma = Sigma, 
  control = list(type = 'mv', constraint = 'none'))

# Mean-variance portfolio with the long-only constraint and gamma = 0.89
optimalPortfolio(mu = mu, Sigma = Sigma, 
  control = list(type = 'mv', constraint = 'lo'))

# Mean-variance portfolio with LB and UB constraints
optimalPortfolio(mu = mu, Sigma = Sigma, 
  control = list(type = 'mv', constraint = 'user', LB = rep(0.02, 10), UB = rep(0.8, 10)))

# Mean-variance portfolio with the gross constraint, 
# gross constraint parameter = 1.6 and gamma = 0.89
optimalPortfolio(mu = mu, Sigma = Sigma, 
  control = list(type = 'mv', constraint = 'gross'))

# Mean-variance portfolio with the gross constraint, 
# gross constraint parameter = 1.2 and gamma = 0.89
optimalPortfolio(mu = mu, Sigma = Sigma, 
  control = list(type = 'mv', constraint = 'gross', gross.c = 1.2))

# Minimum volatility portfolio without constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'minvol'))

# Minimum volatility portfolio without constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'minvol', constraint = 'none'))

# Minimim volatility portfolio with the long-only constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'minvol', constraint = 'lo'))
  
# Minimim volatility portfolio with LB and UB constraints
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'minvol', constraint = 'user', LB = rep(0.02, 10), UB = rep(0.8, 10)))

# Minimum volatility portfolio with the gross constraint 
# and the gross constraint parameter = 1.6
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'minvol', constraint = 'gross'))

# Minimum volatility portfolio with the gross constraint 
# and the gross parameter = 1.2
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'minvol', constraint = 'gross', gross.c = 1.2))
    
# Inverse volatility portfolio
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'invvol'))

# Equal-risk-contribution portfolio with the long-only constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'erc', constraint = 'lo'))
  
# Equal-risk-contribution portfolio with LB and UB constraints
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'erc', constraint = 'user', LB = rep(0.02, 10), UB = rep(0.8, 10)))

# Maximum diversification portfolio without constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'maxdiv'))

# Maximum diversification portoflio with the long-only constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'maxdiv', constraint = 'lo'))
  
# Maximum diversification portoflio with LB and UB constraints
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'maxdiv', constraint = 'user', LB = rep(0.02, 10), UB = rep(0.8, 10)))

# Risk-efficient portfolio without constraint
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, 
  control = list(type = 'riskeff'))

# Risk-efficient portfolio with the long-only constraint
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, 
  control = list(type = 'riskeff', constraint = 'lo'))
  
# Risk-efficient portfolio with LB and UB constraints
optimalPortfolio(Sigma = Sigma, semiDev = semiDev, 
  control = list(type = 'riskeff', constraint = 'user', LB = rep(0.02, 10), UB = rep(0.8, 10)))
  
# Maximum decorrelation portfolio without constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'maxdec'))

# Maximum decorrelation portoflio with the long-only constraint
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'maxdec', constraint = 'lo'))
  
# Maximum decorrelation portoflio with LB and UB constraints
optimalPortfolio(Sigma = Sigma, 
  control = list(type = 'maxdec', constraint = 'user', LB = rep(0.02, 10), UB = rep(0.8, 10)))

RiskPortfolios

Computation of Risk-Based Portfolios

v2.1.5
GPL (>= 2)
Authors
David Ardia [aut, cre, cph] (<https://orcid.org/0000-0003-2823-782X>), Kris Boudt [aut], Jean-Philippe Gagnon-Fleury [aut]
Initial release
2021-04-21

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.