Accelerating the pace of engineering and science

# Documentation Center

• Trial Software

# PortfolioCVaR class

Superclasses: AbstractPortfolio

PortfolioCVaR object for conditional value-at-risk portfolio optimization and analysis

## Description

The PortfolioCVaR object implements conditional value-at-risk (CVaR) portfolio optimization and is derived from the abstract portfolio optimization class AbstractPortfolio. This object implements all methods in the AbstractPortfolio class along with methods that are specific to CVaR portfolio optimization.

The main workflow for CVaR portfolio optimization is to create an instance of a PortfolioCVaR object that completely specifies a portfolio optimization problem and to operate on the PortfolioCVaR object to obtain and analyze efficient portfolios. A CVaR optimization problem is completely specified with these four elements:

• A universe of assets with scenarios of asset total returns for a period of interest, where scenarios comprise a collection of samples from the underlying probability distribution for asset total returns. This collection must be sufficiently large for asymptotic convergence of sample statistics. Note that asset return moments and related statistics are derived exclusively from the scenarios.

• A portfolio set that specifies the set of portfolio choices in terms of a collection of constraints.

• A model for portfolio return and risk proxies, which, for CVaR optimization, is either the gross or net mean of portfolio returns and the conditional value-at-risk of portfolio returns.

• A probability level that specifies the probability that a loss is less than or equal to the value-at-risk. Typical values are 0.9 and 0.95, which indicate 10% and 5% loss probabilities.

After these four elements have been specified in an unambiguous way, it is possible to solve and analyze CVaR portfolio optimization problems.

The simplest CVaR portfolio optimization problem has:

• Scenarios of asset total returns

• A requirement that all portfolios have nonnegative weights that sum to 1 (the summation constraint is known as a budget constraint)

• Built-in models for portfolio return and risk proxies that use scenarios of asset total returns

• A probability level of 0.95

Given scenarios of asset returns in the variable AssetScenarios, this problem is completely specified by:

```p = PortfolioCVaR('Scenarios', AssetScenarios, 'LowerBound', 0, 'Budget', 1, ...
'ProbabilityLevel', 0.95);
```

or equivalently by:

```p = PortfolioCVaR;
p = p.setScenarios(AssetScenarios);
p = p.setDefaultConstraints;
p = p.setProbabilityLevel(0.95);```

To confirm that this is a valid portfolio optimization problem, the following method determines whether the set of PortfolioCVaR choices is bounded (a necessary condition for portfolio optimization).

`[lb, ub, isbounded] = p.estimateBounds;`

Given the problem specified in the PortfolioCVaR object p, the efficient frontier for this problem can be displayed with:

`p.plotFrontier;`

and efficient portfolios can be obtained with:

`pwgt = p.estimateFrontier;`

## Construction

p = PortfolioCVaR constructs an empty PortfolioCVaR object for conditional value-at-risk portfolio optimization and analysis. You can then add elements to the PortfolioCVaR object using the supported add and set methods. For more information, see Constructing the PortfolioCVaR Object.

p = PortfolioCVaR(Name,Value) constructs a PortfolioCVaR object for conditional value-at-risk portfolio optimization and analysis with additional options specified by one or more Name,Value pair arguments. Name is a property name and Value is its corresponding value. Name must appear inside single quotes (''). You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

p = PortfolioCVaR(p,Name,Value) constructs a PortfolioCVaR object for conditional value-at-risk portfolio optimization and analysis using a previously constructed PortfolioCVaR object p with additional options specified by one or more Name,Value pair arguments.

### Input Arguments

 p (Optional) Previously constructed CVaR portfolio object (p).

#### Property Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

 'AInequality' Linear inequality constraint matrix ([] or [matrix]). Default: [] 'AssetList' Names or symbols of assets in the universe ([] or [vector cell of strings]). Default: [] 'bInequality' Linear inequality constraint vector ([] or [vector]). Default: [] 'BuyCost' Proportional purchase costs ([] or vector). Default: [] 'BuyTurnover' Turnover constraint on purchases ([] or [scalar]). Default: [] 'GroupA' Group A weights to be bounded by weights in group B ([] or [matrix]). Default: [] 'GroupB' Group B weights ([] or [matrix]). Default: [] 'GroupMatrix' Group membership matrix ([] or [matrix]). Default: [] 'InitPort' Initial portfolio ([] or vector). Default: [] 'LowerBudget' Lower-bound budget constraint ([] or [scalar]). Default: [] 'LowerGroup' Lower-bound group constraint ([] or [vector]). Default: [] 'LowerRatio' Minimum ratio of allocations between groups A and B ([] or [vector]). Default: [] 'Name' Name for instance of the PortfolioCVaR object ([] or [string]). Default: [] 'NumAssets' Number of assets in the universe ([] or [integer scalar]).Default: [] 'NumScenarios' Number of scenarios ([] or [integer scalar]).Default: [] 'ProbabilityLevel' Probability level which is 1 minus the probability of losses greater than the value-at-risk ([] or [scalar]). Default: [] 'RiskFreeRate' Risk-free rate ([] or scalar). Default: [] 'SellCost' Proportional sales costs ([] or vector). Default: [] 'SellTurnover' Turnover constraint on sales ([] or [scalar]). Default: [] 'Turnover' Turnover constraint ([] or [scalar]). Default: [] 'UpperBound' Upper-bound constraint ([] or [vector]). Default: [] 'UpperBudget' Upper-bound budget constraint ([] or [scalar]). Default: [] 'UpperGroup' Upper-bound group constraint ([] or [vector]). Default: [] 'UpperRatio' Maximum ratio of allocations between groups A and B ([] or [vector]). Default: []

## Properties

The following properties are from the PortfolioCVaR class.

Proportional purchase costs ([] or vector).

Attributes:

 SetAccess public GetAccess public

Turnover constraint on purchases ([] or [scalar]).

Attributes:

 SetAccess public GetAccess public

NumScenarios

Number of scenarios ([] or [integer scalar]).

Attributes:

 SetAccess private GetAccess public

ProbabilityLevel

Value-at-risk probability level which is 1 − (loss probability) ([] or [scalar]).

Attributes:

 SetAccess public GetAccess public

RiskFreeRate

Risk-free rate ([] or scalar).

Attributes:

 SetAccess public GetAccess public

SellCost

Proportional sales costs ([] or vector).

Attributes:

 SetAccess public GetAccess public

SellTurnover

Turnover constraint on sales ([] or [scalar]).

Attributes:

 SetAccess public GetAccess public

Turnover

Turnover constraint ([] or [scalar]).

Attributes:

 SetAccess public GetAccess public

## Properties

The following properties are inherited from the AbstractPortfolio class.

AEquality

Linear equality constraint matrix ([] or [matrix]).

Attributes:

 SetAccess public GetAccess public

AInequality

Linear inequality constraint matrix ([] or [matrix]).

Attributes:

 SetAccess public GetAccess public

AssetList

Names or symbols of assets in the universe ([] or [vector cell of strings]).

Attributes:

 SetAccess public GetAccess public

bEquality

Linear equality constraint vector ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

bInequality

Linear inequality constraint vector ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

GroupA

Group A weights to be bounded by group B ([] or [matrix]).

Attributes:

 SetAccess public GetAccess public

GroupB

Group B weights ([] or [matrix]).

Attributes:

 SetAccess public GetAccess public

GroupMatrix

Group membership matrix ([] or [matrix]).

Attributes:

 SetAccess public GetAccess public

InitPort

Initial portfolio ([] or vector).

Attributes:

 SetAccess public GetAccess public

LowerBound

Lower-bound constraint ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

LowerBudget

Lower-bound budget constraint ([] or [scalar]).

Attributes:

 SetAccess public GetAccess public

LowerGroup

Lower-bound group constraint ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

LowerRatio

Minimum ratio of allocations between groups A and B ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

Name

Name for instance of the PortfolioCVaR object ([] or [string]).

Attributes:

 SetAccess public GetAccess public

NumAssets

Number of assets in the universe ([] or [integer scalar]).

Attributes:

 SetAccess public GetAccess public

UpperBound

Upper-bound constraint ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

UpperBudget

Upper-bound budget constraint ([] or [scalar]).

Attributes:

 SetAccess public GetAccess public

UpperGroup

Upper-bound group constraint ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

UpperRatio

Maximum ratio of allocations between groups A and B ([] or [vector]).

Attributes:

 SetAccess public GetAccess public

## Inherited Methods

The following methods are inherited from the AbstractPortfolio class.

 addEquality Add equality constraints for portfolio weights to existing constraints. addGroupRatio Add group ratio constraints for portfolio weights to existing constraints. addGroups Add group constraints for portfolio weights to existing constraints. addInequality Add inequality constraints for portfolio weights to existing constraints. checkFeasibility Determine if portfolios are members of the set of feasible portfolios. estimateBounds Determine if set of feasible portfolios is nonempty and bounded. estimateFrontier Estimate portfolios on the entire efficient frontier. estimateFrontierByReturn Estimate portfolios on the efficient frontier with targeted returns or return proxies. estimateFrontierByRisk Estimate portfolios on the efficient frontier with targeted risks or risk proxies. estimateFrontierLimits Estimate portfolios at the extreme ends of the efficient frontier (minimum risk and maximum return). estimatePortReturn Estimate return or return proxy for specified portfolios. estimatePortRisk Estimate risk or risk proxy for specified portfolios. getBounds Get lower and upper bounds from the object. getBudget Get lower and upper budget constraints from the object. getEquality Get equality constraint matrix and vector from the object. getGroupRatio Get base matrix, comparison matrix, and lower and upper bounds for group ratio constraints from the object. getGroups Get group matrix and lower and upper bounds for group constraints from the object. getInequality Get inequality constraint matrix and vector from the object. plotFrontier Plot efficient frontier and optionally obtain risks and returns for portfolios on the efficient frontier. setAssetList Set up a list of asset names and symbols to be associated with assets in the universe. setBounds Set up lower and upper bounds for portfolio weights. setBudget Set up lower and upper budget constraints for portfolio weights. setDefaultConstraints Set up default constraints for portfolio weights (nonnegative weights that must sum to 1). setEquality Set up equality constraints for portfolio weights. setGroupRatio Set up group ratio constraints for portfolio weights. setGroups Set up group constraints for portfolio weights. setInequality Set up inequality constraints for portfolio weights. setInitPort Set up initial portfolio weights. setOptions Set up hidden control properties in object (not implemented). setSolver Set up solver to estimate efficient portfolios.

## Methods

 estimatePortStd Estimate standard deviation of portfolio returns. estimatePortVaR Estimate value-at-risk for portfolio. estimateScenarioMoments Estimate mean and covariance of scenarios. simulateNormalScenariosByData Simulate multivariate normal asset return scenarios from data. simulateNormalScenariosByMoments Simulate multivariate normal asset return scenarios from a mean and covariance of asset returns. getCosts Get purchase and sales proportional transaction costs from the object. getOneWayTurnover Get one-way portfolio turnover constraints. getScenarios Obtain scenarios from PortfolioCVaR object. setCosts Set up purchase and sale proportional transaction costs for assets in the universe. setOneWayTurnover Set up one-way portfolio turnover constraints. setProbabilityLevel Set probability level for VaR and CVaR calculations. setScenarios Set asset returns scenarios by direct matrix. setTurnover Set up average turnover constraints for portfolio weights.

## Definitions

### Conditional Value-at-Risk Portfolio Optimization

For more information on the theory and definition of conditional value-at-risk optimization supported by portfolio optimization tools in Financial Toolbox™, see Portfolio Optimization Theory.

## Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

## Examples

expand all

### Construct a PortfolioCVaR Object and Determine Efficient Portfolios

Create efficient portfolios:

```load CAPMuniverse

p = PortfolioCVaR('AssetList',Assets(1:12));
p = p.simulateNormalScenariosByData(Data(:,1:12), 20000 ,'missingdata',true);
p = p.setDefaultConstraints;
p = p.setProbabilityLevel(0.95);

p.plotFrontier;

pwgt = p.estimateFrontier(5);

pnames = cell(1,5);
for i = 1:5
pnames{i} = sprintf('Port%d',i);
end

Blotter = dataset([{pwgt},pnames],'obsnames',p.AssetList);

disp(Blotter);
```
```           Port1       Port2       Port3       Port4      Port5
AAPL    0.014467    0.051475    0.090404     0.1221    1.0451e-14
AMZN           0           0           0          0     2.295e-14
CSCO           0           0           0          0    3.5965e-14
DELL           0           0           0          0    3.4191e-14
EBAY           0           0           0          0     1.038e-15
GOOG     0.20411     0.39147     0.57653    0.76409             1
HPQ      0.04915    0.021434           0          0    3.2713e-14
IBM      0.46243     0.34368     0.24692    0.11381    3.4062e-14
INTC           0           0           0          0    3.2813e-14
MSFT     0.26984     0.19194     0.08614          0    3.6087e-14
ORCL           0           0           0          0    3.3648e-14
YHOO           0           0           0          0    3.2615e-14```

## References

For a complete list of references for the PortfolioCVaR object and portfolio optimization tools, see Portfolio Optimization.