Details on Portfolio Optimization

JULY 19, 2023
Here we detail the implementation and analytical details for the different types of optimization supported within the target portfolio construction module. Three different optimizers are defined for this module. These are minimum variance optimizer, maximum return optimizer, and minimum CVaR (Conditional Value at Risk) optimizer. We also detail the different constraints for assets within the scope of these optimizers.
This write-up is organized as follows. The first section is on simple optimizers. These are generally known as mean-variance optimizers. Within this section, we also note the necessary regularizations that are required to control the output of mean-variance optimizers. In a subsequent section, we detail the various asset specific constraints and how they must be specified. Next, we detail how we can expand the application of these optimizers to sets of assets (more commonly known as model portfolios). Finally, we describe how the minimization of CVaR can be transformed into a convex optimization problem.
Notation
Simple Optimizers
The two simple optimizers that we discuss first are the maximum return and minimum variance optimizers. For a given set of N assets, we have the following problems. The first problem seeks to maximize the total return of the portfolio while keeping the total risk, computed as the variance of the portfolio less than some pre-defined threshold, .
(Max. Return)
The second problem is complementary to the Maximum Return Problem. In this second
problem, we seek to minimize the overall variance of the portfolio but with the guarantee of a portfolio return of at least
.
(Min. Variance)
In their basic forms both (Max. Return) and (Min. Variance) are unstable. This happens
in the following sense: for the maximum return problem, the optimization can often result
with weights concentrated in a few position. This can typically occur if the expected return
of an asset (or group of assets) is significantly higher than those of other assets. Then the
optimizer simply puts most of the weight of the portfolio into this limited subset. Such a
situation is not good for diversification.
To remedy such a situation, we amend the objective functions for these problems. For
both these problems, we apply L2 regularization. This involes the addition of a penalty term
proportional to the L2 (or Euclidean) norm of the vector we want to optimize for. The (Max. Return) problem is amended to the following form:
Note: A typical value of works wells and produces robust for both these problems.
Asset Constraints
The use case for target portfolio construction also involves imposing constraints on the as-
set allocation and other kinds of exposures. These constraints can be differentiated into multiple categories: generic constraints, asset attribute constraints, factor-derived constraints, and individual asset constraints. We discuss each kind of constraint briefly.
Generic Constraints
These are constraints that apply to all the assets equally in the portfolio. These take the
simple form:
(Generic Constraints)
These constraints imply that all asset weights should have weights between .
Asset Attribute Constraints
These are constraints that apply to a subset of assets within a portfolio. The subset is deter-
mined by selecting assets which have a given attribute. The typical form of the constraint is to limit the total weight of this subset of assets to lie between certain bounds.
Suppose we have M attributes. These M attributes can be used to construct M partitions such that
. Then the attribute restriction for any
:
(Asset Attribute Constraints)
where and
are the respective upper and lower bounds for the sum of weights for attribute
.
Factor Derived Constraints
These are constraints that are related to bounds on exposures of the portfolio. These exposures are related to sector and geographical constraints. For any given asset, we have factor exposures encoded in the exposure matrix .
However, for sector and region constraints, we use aggregated exposures. This aggregation is performed to have a limited set of sectors or geographical regions. Hence, we aggregate the sector exposures to 11 sectors. These 11 sectors correspond to the 11 sectors at the highest level of the GICS taxonomy. Similarly for regional exposures, we aggregate into 5 large geographical regions.
The expression for the constraints is very similar to the (Asset Attribute Constraints), with the small change of the sum being weighted by the relevant exposures. Suppose we have the subset of the exposures for each of the eleven sectors within the matrix . Then the weighted sector exposures are given by
(Sector Exposures)
Then for any sector , with upper and lower bounds
and
we have the constraint:
(Sector Exposure Constraints)
Normalizing Exposures
For multi-asset funds, there is a need to normalize the exposures Xsectors so that for any
asset, especially ETFs with a mix of asset classes, the sum of the sector exposures is equal
to 1. In both equations (Sector Exposures) and (Sector Exposure Constraints), we assume
that the exposures have been normalized.
Optimization with Model Portfolios
We now discuss we can perform portfolio optimization with model portfolios, rather than individual assets. Model portfolios are portfolios constructed for particular mandates. The objective then is to construct a portfolio using only a set of models: rather than finding a set
of weights for individual assets, we must now determine a set of weights for the individual model portfolios. An extra constraint then is to maintain the relative weighting of the individual assets within any given model portfolio. We detail this below.
Let us say that we have multiple model portfolios indexed by . For any asset i, its weight within model portfolio is denoted by
. This weight is a constant, since it is specified by the model. We then have
(Model Weight Definition)
The weight is a known value, so we can generate a constraint on the actual in-portfolio weight
.
(Model Weight Constraint)
Here we have defined as the sum of the weights of all the other assets in the model p. We call this the model sub-weight.
With this extra constraint on the weights , we can now extend the portfolio construction exercise to model portfolios. All the other constraints such as (Asset Attribute Constraints), (Generic Constraints), and other factor exposure constraints can be added as required.
However, note that because there is an extra constraint on the weights of the assets within models, we must be careful about specifying other constraints (asset attribute or sector/region constraints).
Optimizing for CVaR
We now focus on the optimization for CVaR or Conditional Value-at-Risk. We first define Value-at-Risk or VaR. The VaR at a given level can be understood as follows: the probability of a given portfolio suffering a loss greater than VaR is 1−
. The conditional VaR then tell us the average of the losses in a portfolio, that are greater than the level of the VaR itself. Said differently, this is the average of the portfolio losses in the worst 1 −
of the cases.
Suppose that the returns of a portfolio ⃗r is distributed according to some probability
distribution . For a given portfolio with weights ⃗w, we can write a ”loss” function
which quantifies the loss that can be suffered by the portfolio. We also denote the VaR at
level as
. Then
(CVaR Definition)
Optimizing for CVaR using this integral definition is cumbersome. However, we can trans-
form the problem into a convex optimization problem. Let us assume that the loss function takes a simple linear form
. We then define an auxiliary CVaR function:
(Auxiliary CVaR Function)
The change that has been made here is that rather than integrating over all values of the
loss greater that the VaR, we are integrating over all values greater than μ. It can be shown
that
1) is a convex function of μ.
2) The minimum value of is
.
3) Minimizing gives us
, i.e.
We can minimize the (Auxiliary CVaR Function) by replacing the integral with a sum over
the vector of returns ⃗. The bounds of the integral can be taken into account by adding an
extra constraint. Within CVXPY, the minimization of (Auxiliary CVaR Function) can be done
as follows:
(Auxiliary CVaR Minimization)
Here the index t runs over the historical returns of the assets. For a factor model, we can
perform the optimization over the set of factor returns ⃗. Using the exposure matrix X and
the factor returns, we can get the asset returns, and perform the optimization.
We can extend the minimization problem above to include simulated returns as well.
Note that the (Auxiliary CVaR Function) is defined over the probability distribution . Hence for a numerical implementation we can sample from this distribution as well. In which case, the sum in (Auxiliary CVaR Minimization) runs over the time index t but also the index of
samples.
We can now implement the CVaR minimization as a convex optimization problem, and
all other relevant constraints can also be included. More details, and proofs of the properties
of the function can be found in Rockafellar, R. Tyrrell, and Stanislav Uryasev. Optimization of conditional value-at-risk, Journal of risk 2 (2000): 21-42.
Extending CVaR Minimization to Simulated Returns
The previous discussion on the minimization of the Conditional Value at Risk (CVaR) relied upon the knowledge of the historical asset returns. This poses a number of challenges primary among which is the lack of sufficient data to have enough points in the tail of the distribution. Without sufficient knowledge of the tail of the distribution, our estimations of the tail risk, and hence the ensuing CVaR minimization, will understate the actual risk of the portfolio.
To get around this limitation, we can use simulated returns. The auxiliary function defined in (Auxiliary CVaR Function) makes use of the probability distribution of the returns
. This probability distribution can be replaced with an empirical distribution (as was done in Equation Auxiliary CVaR Minimization) or with a simulated distribution (via Monte-Carlo draws).
Within the Fabric framework, we define forward-looking simulations through specific
scenarios. These scenarios simulate the behavior of a given portfolio under pre-specified
adverse market conditions. This suggests that if we have draws for the asset returns under
a given scenario s, then we can replace :
(Simulated Returns)
Here, we have an extra index which stands for a particular path of the scenario. However, the question arises: do we need to perform the minimization in Equation Auxiliary CVaR Minimization sample by sample or can we use the complete distribution of the paths (i.e. summed over all paths) to perform this minimization?
We address that question below and investigate things numerically. We take two scenarios — baseline and recession — to illustrate the tradeoffs involved in the two approaches. The universe of assets we used are shown in Table 1.
Table 1: List of assets used for CVaR minimization tests
Using this set of assets, we solve two minimization problems:
1) Minimize CVaR for each sample m in the simulated scenario. This is similar to
Equation Auxiliary CVaR Minimization, but we reproduce it here for completeness:
(CVaR Minimization per sample)
We add the index m to each of the key variables to make clear that this minimization
is being done on a path by path basis.
2) Minimize CVaR over the complete distribution of the paths. Here, the variables
get the index M. The problem is then:
(CVaR Minimization per sample)
The difference between the two minimization problems is subtle but worth noting. In Figure 1, we show the distributions of key metrics for the simulated returns under the baseline scenario. The metrics plotted are:
1) Distribution of CVaR: this is value of the CVaR at the end of the optimization
2) Distribution of Expected Returns: this is the value of the expected returns for the optimal portfolio. We use standard capital market assumptions.
3) Distribution of Historical Vol: this is the value of the volatility computed from the asset
covariance (derived from the factor covariance) and the specific variance.
4) Distribution of Empirical Vol: this is the value of the volatility computed from the standard deviations of the returns of the portfolio using the simulated returns for the scenario.
5) Distribution of Portfolio Turnover: this is a measure of the difference between the optimal portfolio retrieved after performing the optimization in Equation CVaR Minimization Overall and each of the optimal portfolios ⃗ retrieved from the optimization in Equation CVaR Minimization per sample. The turnover is defined as :
(Portfolio Turnover)
In Figure 1, we observe that the distributions for the metrics are fairly narrow and the
value of the metrics for the optimal portfolio fromEquation CVaR Minimization Overall is well
within the distribution of the m samples. However, the turnover of the portfolios is spread
between 0% and 15%. Such a wide distribution suggests that the optimal portfolio depends
on the sample m of the scenario, with a substantial difference between the allocations from
one optimal portfolio to the other. A similar situation is observed for the recession scenario,
shown in Figure 2.
Figure 1: Distribution of key metrics under baseline scenario. In each subplot, the vertical red line denotes the value of the metric under the optimization in Equation CVaR Minimization Overall.
Figure 2: Distribution of key metrics under recession scenario. In each subplot, the vertical red line denotes the value of the metric under the optimization in Equation CVaR Minimization Overall.
Note on Regularization for Mean-Variance Portfolios
Naive mean-variance optimization can suffer from a number of problems, including:
• Sensitivity to the assumptions on expected returns and the covariance matrix. The results of naive mean-variance optimization are extremely sensitive to the assumptions on expected returns and the covariance matrix used for estimating risk. This can lead to portfolios that are not robust to changes in these assumptions.
• Lack of diversification: Naive mean-variance optimization can often lead to portfolios that are too concentrated in a small number of assets. This can increase the risk of the portfolio and make it more volatile.
• Inability to handle constraints: Naive mean-variance optimization cannot handle constraints, such as limits on the number of assets in the portfolio or the maximum weight that can be allocated to any single asset.
To address these problems, we can add regularization to the mean-variance optimization problem. Regularization is a technique that adds additional terms to the objective function in order to penalize certain behaviors. In the case of mean-variance optimization, we can use regularization to:
1) Prevent the portfolio from becoming too concentrated: We can add a penalty term
to the objective function that penalizes portfolios with high weights in any single asset.
This will help to ensure that the portfolio is diversified.
2) Make the portfolio more robust to changes in the assumptions on expected returns and the covariance matrix: We can add a penalty term to the objective function that penalizes portfolios that are sensitive to changes in these assumptions. This will help to ensure that the portfolio is not too heavily influenced by any one set of assumptions.
3) Handle constraints: We can add constraints directly to the mean-variance optimization problem. This will ensure that the portfolio meets the desired constraints.
There are a number of different ways to add regularization to the mean-variance optimization problem. The specific approach that you choose will depend on the specific needs of your portfolio.
Adding Asset-Weight Constraints
One way to regularize the mean-variance optimization problem is to add asset-weight constraints. Asset-weight constraints limit the amount of weight that can be allocated to any single asset or group of assets. This can help to prevent the portfolio from becoming too concentrated and can also make the portfolio more robust to changes in the assumptions on expected returns and the covariance matrix.
There are a number of different ways to add asset-weight constraints. One common approach is to use a box constraint, which limits the weight of each asset to a specified range.
Another common approach is to use an upper bound constraint, which limits the weight of each asset to a specified maximum value.
Another method is to add weight constraints on a collection of assets. These constraints can be applied at the attribute level, such as Asset class. Or they can be applied at the level of specific exposures, such as sector and regional exposures.
Within our implementation of the optimizer, we allow the user to implement constraints at the individual asset level, the attribute level, or the exposure level. In addition, the user can also set minimum and maximum weights for all assets in order to further ensure that the portfolio is not too concentrated.
Adding Penalty Terms
Another way to regularize the mean-variance optimization problem is to add penalty terms to the objective function. Penalty terms penalize certain behaviors, such as high portfolio weights or sensitivity to changes in the assumptions on expected returns and the covariance matrix.
There are a number of different types of penalty terms that can be used. One common penalty term is the quadratic penalty term, which penalizes the square of the portfolio weights. Another common penalty term is the absolute penalty term, which penalizes the absolute value of the portfolio weights.
In our implementation of the mean-variance optimizer, we use a quadratic penalty term. This penalty term penalizes the square of the portfolio weights. This helps to ensure that the portfolio is not too heavily influenced by any one asset. It also helps to correct for the instability of the covariance matrix.
Access a better way to understand and work with risk, powered by MSCI’s factor model.

© 2022 Fabric Risk