Mean-Conditional Value at Risk Optimization
The Conditional Value at Risk (CVaR) is the average loss in the worst alpha share of the periods, the expected shortfall. Rockafellar and Uryasev (2000) showed that its minimization over the weights is a linear programme over the historical returns, which accounts for skewed and fat-tailed returns without a model of their distribution. Its maximum ratio portfolio is the maximum STARR (stable tail adjusted return ratio) portfolio of Martin, Rachev and Siboulet (2003), the maximum Sharpe ratio portfolio with the tail loss in place of the volatility.
The formula for the Conditional Value at Risk starts from the return \(X_{t}\) of the portfolio in each of the T periods, with \(w_{i}\) the weight and \(r_{i , t}\) the return of asset i of the N assets, and takes, with alpha the tail probability, the value of the expression below at the \(\zeta_{0}\) that minimizes it, which is the Value at Risk:
\[X_{t} = \sum_{i=1}^{N} w_{i} \cdot r_{i,t}\] \[\text{CVaR} = \zeta_{0} + \frac{\sum_{t=1}^{T} \max\left(0, -X_{t} - \zeta_{0}\right)}{\alpha \cdot T}\]It only looks at the losses in the tail, which makes it a coherent measure of risk that rewards diversification, but with \(\alpha = 0.05\) it rests on one period in twenty, so the weights move more from one sample to the next than those of the minimum variance portfolio.
It is the portfolio with the lowest risk, the lowest risk at a target return, or the highest ratio of the average excess return to the risk. Mean-variance analysis measures risk by the variance; the mean-risk portfolios keep its trade-off between expected return and risk and measure the risk of the historical portfolio returns in another way. Measures that only count losses leave upside swings unpenalized, the dispersion measures count deviations in proportion to their size rather than their square, and the drawdown measures penalize deep and long falls, which are what investors feel and what ends strategies.
There are two objectives. The minimum risk portfolio minimizes the risk measure, at a target expected return when one is given. The maximum ratio portfolio maximizes the expected excess return over the risk measure, with the transformation of Charnes and Cooper (1962) that turns the ratio into a problem of the same kind as the minimum risk one; with the volatility as the measure, it would be the maximum Sharpe ratio portfolio.
Also known as: CVaR, expected shortfall, minimum CVaR weights, mean-CVaR, tail risk optimization, maximum CVaR ratio weights, maximum STARR, stable tail adjusted return ratio, mean-CVaR tangency portfolio.
In the Finance Toolkit this is get_mean_risk_weights with risk_measure="cvar", the same function as Mean-Risk Weights.
Example · AAPL, MSFT, JNJ, XOM · 2021 to 2025
Install the Finance Toolkit with pip install financetoolkit -U, then call get_mean_risk_weights:
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "JNJ", "XOM"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.portfolio.get_mean_risk_weights(
risk_measure="cvar", objective="maximum_ratio"
)[["Weight", "Expected Return", "CVaR", "CVaR Ratio"]]
| Parameter | Type | Description | Example |
|---|---|---|---|
risk_measure | str | The risk measure. Options are: “mad” (Mean Absolute Deviation, Konno and Yamazaki, 1991), “semideviation” (Semideviation, below the minimum acceptable return), “lower_partial_moment” (Lower Partial Moment, first order), “worst_realization” (Worst Realization, the worst return), “gini_mean_difference” (Gini Mean Difference, Yitzhaki, 1982), “tail_gini” (Tail Gini, Furman et al., 2017), “range” (Range, the best minus the worst return), “cvar_range” (Conditional Value at Risk Range, of the losses and of the gains), “tail_gini_range” (Tail Gini Range, of the losses and of the gains), “ulcer_index” (Ulcer Index, of the uncompounded cumulative return), “cvar” (Conditional Value at Risk, Rockafellar and Uryasev, 2002), “cdar” (Conditional Drawdown at Risk, Chekhlov et al., 2005), “maximum_drawdown” (Maximum Drawdown, of the uncompounded cumulative return), “average_drawdown” (Average Drawdown, of the uncompounded cumulative return). Defaults to “mad”. | "mad" |
objective | str | Options are: “minimum_risk” (the lowest risk), “maximum_ratio” (the highest average excess return per unit of risk). Defaults to “minimum_risk”. | "minimum_risk" |
target_return | float | None | The annualized expected return the minimum risk portfolio must have, e.g. 0.12 for 12%, with the cash of a net exposure other than one at the risk free rate. Defaults to None, no target. | None, no target |
alpha | float | The tail probability of the CVaR, the CVaR range, the CDaR and the Tail Gini measures, e.g. 0.05 for the worst 5% of periods (or drawdowns). Defaults to 0.05. | 0.01 |
minimum_acceptable_return | float | str | The threshold of the semideviation and the lower partial moment, as a return per period of the chosen frequency (e.g. 0.0002 a day), or “mean” for each asset’s average return. Defaults to 0. | 0.001 |
period | str | The frequency of the returns. Options are: “daily” (daily returns), “weekly” (weekly returns), “monthly” (monthly returns), “quarterly” (quarterly returns), “yearly” (yearly returns). Defaults to “daily”. | "weekly" |
expected_returns | str | The estimator of the expected returns of the ratio and the target return. Options are: “mean” (the historical average), “geometric” (the compounded average), “exponential” (the exponentially weighted average, recent periods weigh most), “exponential_geometric” (that average compounded over a year), “capm” (the returns the Capital Asset Pricing Model implies from each asset’s beta to the benchmark, Sharpe, 1964), “bayes_stein” (the averages shrunk towards that of the minimum variance portfolio, Jorion, 1986), “james_stein” (the averages shrunk towards their grand mean, James and Stein, 1961), “bodnar_okhrin_parolya” (the averages and their grand mean combined with optimal weights, Bodnar, Okhrin and Parolya, 2019). Defaults to “mean”. | "mean" |
expected_returns_span | int | The span in periods of the exponentially weighted expected returns. Defaults to 180. | 180 |
minimum_weight | float | dict[str, float] | The lowest weight of every asset, or per asset, e.g. {“AAPL”: 0.05} (the others keep 0); a negative value allows short positions. Defaults to 0. | 0 |
maximum_weight | float | dict[str, float] | The highest weight of every asset, or per asset, e.g. {“AAPL”: 0.3} (the others keep 1). Defaults to 1. | 1 |
sector_bounds | dict[str, tuple[float, float]] | None | The minimum and maximum total weight per sector, e.g. {“Technology”: (0, 0.4)}, with the sector of each asset from its company profile. Defaults to None. | None |
country_bounds | dict[str, tuple[float, float]] | None | The minimum and maximum total weight per country, named in full or by its two-letter code, e.g. {“United States”: (0, 0.6)}, with the country of each asset from its company profile. Defaults to None. | None |
net_exposure | float | The sum of the weights: 1 for a fully invested portfolio, 0 for a market neutral one (which needs a negative minimum_weight). At 0 the portfolio with the lowest CVaR holds nothing, so all weights are 0, and for the drawdown measures a net exposure of 0 is refused, as holding nothing has no drawdown. The rest, 1 minus the net exposure, is a Cash row at the risk free rate (negative when borrowed above one), which the Portfolio’s Expected Return and Sharpe Ratio include. Defaults to 1. | 1 |
gross_exposure | float | None | The highest sum of the absolute weights, which limits the leverage of a long-short portfolio, e.g. 1.6 for a 130/30 portfolio. Defaults to None, no limit. | None, no limit |
current_weights | dict[str, float] | None | The weights held now, e.g. {“AAPL”: 0.5, “MSFT”: 0.5} (an asset left out is not held), which the turnover is measured from; they add a Turnover column, \(\vert w_{i} - w_{0,i} \vert\) per asset and its sum for the portfolio. Defaults to None, which uses the latest weights of the Portfolio the Toolkit came from when a maximum turnover needs them. | None, which uses the latest weights of the Portfolio the Toolkit came from when a maximum turnover needs them |
maximum_turnover | float | None | The highest turnover \(\sum \vert w_{i} - w_{0,i} \vert\) from the current weights, e.g. 0.2 to trade at most 10% of the portfolio each way. Defaults to None, no limit. | None, no limit |
include_benchmark | bool | Whether to include the benchmark as an asset. Defaults to False. | True |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding. | 2 |
show_columns | str | list[str] | None | The columns to keep, a name or a list of names, matched on every column level, or the rows when no column has those names (such as the line items of a financial statement). Names that do not exist are logged, and when none exist the result is returned in full. Defaults to None, which keeps every column. | None, which keeps every column |
Which returns:
| Item | Weight | Expected Return | CVaR | CVaR Ratio |
|---|---|---|---|---|
| AAPL | 0.0000 | 0.1932 | 0.0390 | 0.0162 |
| MSFT | 0.2779 | 0.2017 | 0.0356 | 0.0187 |
| JNJ | 0.1921 | 0.0977 | 0.0227 | 0.0112 |
| XOM | 0.5299 | 0.2911 | 0.0373 | 0.0274 |
| Portfolio | 1.0000 | 0.2291 | 0.0238 | 0.0326 |
5 rows
References
- Paper Charnes, A. and Cooper, W. W. (1962). “Programming with Linear Fractional Functionals.” Naval Research Logistics Quarterly, 9(3-4), 181-186.
- Paper Rockafellar, R. T. and Uryasev, S. (2000). “Optimization of Conditional Value-at-Risk.” Journal of Risk, 2(3), 21-41.
- Paper Martin, R. D., Rachev, S. T. and Siboulet, F. (2003). “Phi-Alpha Optimal Portfolios and Extreme Risk Management.” Wilmott Magazine, November, 70-83.