Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

PortfolioCVaR

Create PortfolioCVaR object for conditional value-at-risk portfolio optimization

Use the PortfolioCVaR function to create a PortfolioCVaR object for conditional value-at-risk portfolio optimization. For more information, see PortfolioCVaR

You can use the PortfolioCVaR function in several ways. To set up a portfolio optimization problem in a PortfolioCVaR object, the simplest syntax is:

p = PortfolioCVaR;
This syntax creates a PortfolioCVaR object, p, such that all object properties are empty.

The PortfolioCVaR function also accepts collections of argument name-value pair arguments for properties and their values. The PortfolioCVaR function accepts inputs for properties with the general syntax:

	p = PortfolioCVaR('property1', value1, 'property2', value2, ... );

If a PortfolioCVaR object already exists, the syntax permits the first (and only the first argument) of the PortfolioCVaR function to be an existing object with subsequent argument name-value pair arguments for properties to be added or modified. For example, given an existing PortfolioCVaR object in p, the general syntax is:

p = PortfolioCVaR(p, 'property1', value1, 'property2', value2, ... );

Input argument names are not case sensitive, but must be completely specified. In addition, several properties can be specified with alternative argument names (see Shortcuts for Property Names). The PortfolioCVaR function tries to detect problem dimensions from the inputs and, once set, subsequent inputs can undergo various scalar or matrix expansion operations that simplify the overall process to formulate a problem. In addition, a PortfolioCVaR object is a value object so that, given portfolio p, the following code creates two objects, p and q, that are distinct:

q = PortfolioCVaR(p, ...)

After creating a PortfolioCVaR object, you can use the associated object functions to set portfolio constraints, analyze the efficient frontier, and validate the portfolio model.

For details on this workflow, see PortfolioCVaR Object Workflow and for more detailed information on the theoretical basis for conditional value-at-risk portfolio optimization, see Portfolio Optimization Theory.

Syntax

p = PortfolioCVaR
p = PortfolioCVaR(Name,Value)
p = PortfolioCVaR(p,Name,Value)

Description

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 functions. For more information, see Creating 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 arguments.

example

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 arguments.

Examples

collapse all

You can create a PortfolioCVaR object, p, with no input arguments and display it using disp.

p = PortfolioCVaR;
disp(p);
  PortfolioCVaR with properties:

             BuyCost: []
            SellCost: []
        RiskFreeRate: []
    ProbabilityLevel: []
            Turnover: []
         BuyTurnover: []
        SellTurnover: []
        NumScenarios: []
                Name: []
           NumAssets: []
           AssetList: []
            InitPort: []
         AInequality: []
         bInequality: []
           AEquality: []
           bEquality: []
          LowerBound: []
          UpperBound: []
         LowerBudget: []
         UpperBudget: []
         GroupMatrix: []
          LowerGroup: []
          UpperGroup: []
              GroupA: []
              GroupB: []
          LowerRatio: []
          UpperRatio: []

This approach provides a way to set up a portfolio optimization problem with the PortfolioCVaR function. You can then use the associated set functions to set and modify collections of properties in the PortfolioCVaR object.

You can use the PortfolioCVaR function directly set up a “standard” portfolio optimization problem. Given scenarios of asset returns in the variable AssetScenarios, this problem is completely specified as follows:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioCVaR('Scenarios', AssetScenarios, ...
'LowerBound', 0, 'LowerBudget', 1, 'UpperBudget', 1, ...
'ProbabilityLevel', 0.95)
p = 
  PortfolioCVaR with properties:

             BuyCost: []
            SellCost: []
        RiskFreeRate: []
    ProbabilityLevel: 0.9500
            Turnover: []
         BuyTurnover: []
        SellTurnover: []
        NumScenarios: 20000
                Name: []
           NumAssets: 4
           AssetList: []
            InitPort: []
         AInequality: []
         bInequality: []
           AEquality: []
           bEquality: []
          LowerBound: [4x1 double]
          UpperBound: []
         LowerBudget: 1
         UpperBudget: 1
         GroupMatrix: []
          LowerGroup: []
          UpperGroup: []
              GroupA: []
              GroupB: []
          LowerRatio: []
          UpperRatio: []

Note that the LowerBound property value undergoes scalar expansion since AssetScenarios provides the dimensions of the problem.

Using a sequence of steps is an alternative way to accomplish the same task of setting up a “standard” CVaR portfolio optimization problem, given AssetScenarios variable is:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
0.00408 0.0289 0.0204 0.0119;
0.00192 0.0204 0.0576 0.0336;
0 0.0119 0.0336 0.1225 ];

m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioCVaR;
p = setScenarios(p, AssetScenarios);
p = PortfolioCVaR(p, 'LowerBound', 0);
p = PortfolioCVaR(p, 'LowerBudget', 1, 'UpperBudget', 1);
p = setProbabilityLevel(p, 0.95);

plotFrontier(p);

This way works because the calls to the PortfolioCVaR function are in this particular order. In this case, the call to initialize AssetScenarios provides the dimensions for the problem. If you were to do this step last, you would have to explicitly dimension the LowerBound property as follows:

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
0.00408 0.0289 0.0204 0.0119;
0.00192 0.0204 0.0576 0.0336;
0 0.0119 0.0336 0.1225 ];

m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioCVaR;
p = PortfolioCVaR(p, 'LowerBound', zeros(size(m)));
p = PortfolioCVaR(p, 'LowerBudget', 1, 'UpperBudget', 1);
p = setProbabilityLevel(p, 0.95);
p = setScenarios(p, AssetScenarios); 

plotFrontier(p);

If you did not specify the size of LowerBound but, instead, input a scalar argument, the PortfolioCVaR function assumes that you are defining a single-asset problem and produces an error at the call to set asset scenarios with four assets.

You can create a PortfolioCVaR object, p with the PortfolioCVaR function using shortcuts for property names.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0;
0.00408 0.0289 0.0204 0.0119;
0.00192 0.0204 0.0576 0.0336;
0 0.0119 0.0336 0.1225 ];

m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioCVaR('scenario', AssetScenarios, 'lb', 0, 'budget', 1, 'plevel', 0.95)
p = 
  PortfolioCVaR with properties:

             BuyCost: []
            SellCost: []
        RiskFreeRate: []
    ProbabilityLevel: 0.9500
            Turnover: []
         BuyTurnover: []
        SellTurnover: []
        NumScenarios: 20000
                Name: []
           NumAssets: 4
           AssetList: []
            InitPort: []
         AInequality: []
         bInequality: []
           AEquality: []
           bEquality: []
          LowerBound: [4x1 double]
          UpperBound: []
         LowerBudget: 1
         UpperBudget: 1
         GroupMatrix: []
          LowerGroup: []
          UpperGroup: []
              GroupA: []
              GroupB: []
          LowerRatio: []
          UpperRatio: []

Although not recommended, you can set properties directly, however no error-checking is done on your inputs.

m = [ 0.05; 0.1; 0.12; 0.18 ];
C = [ 0.0064 0.00408 0.00192 0; 
    0.00408 0.0289 0.0204 0.0119;
    0.00192 0.0204 0.0576 0.0336;
    0 0.0119 0.0336 0.1225 ];
m = m/12;
C = C/12;

AssetScenarios = mvnrnd(m, C, 20000);

p = PortfolioCVaR;

p = setScenarios(p, AssetScenarios);
p.ProbabilityLevel = 0.95;

p.LowerBudget = 1;
p.UpperBudget = 1;
p.LowerBound = zeros(size(m));
disp(p)
  PortfolioCVaR with properties:

             BuyCost: []
            SellCost: []
        RiskFreeRate: []
    ProbabilityLevel: 0.9500
            Turnover: []
         BuyTurnover: []
        SellTurnover: []
        NumScenarios: 20000
                Name: []
           NumAssets: 4
           AssetList: []
            InitPort: []
         AInequality: []
         bInequality: []
           AEquality: []
           bEquality: []
          LowerBound: [4x1 double]
          UpperBound: []
         LowerBudget: 1
         UpperBudget: 1
         GroupMatrix: []
          LowerGroup: []
          UpperGroup: []
              GroupA: []
              GroupB: []
          LowerRatio: []
          UpperRatio: []

Scenarios cannot be assigned directly to a PortfolioCVaR object. Scenarios must always be set through either the PortfolioCVaR function, the setScenarios function, or any of the scenario simulation functions.

Create efficient portfolios:

load CAPMuniverse

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

plotFrontier(p);

pwgt = estimateFrontier(p, 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.010984      0.073246       0.11933       0.13068    1.5092e-14
    AMZN             0             0    1.9935e-23     6.163e-33    2.8997e-14
    CSCO    1.7632e-38             0    2.0419e-23      2.08e-32    4.1869e-14
    DELL      0.022454    2.8699e-39    1.1285e-22     4.757e-32    3.9048e-14
    EBAY             0             0    2.0032e-22    3.4211e-49    1.3394e-15
    GOOG       0.20335       0.38055       0.56242       0.75932             1
    HPQ       0.041724     0.0099223    1.7162e-22     9.877e-33    3.8894e-14
    IBM        0.44482       0.36453       0.26282          0.11    3.7902e-14
    INTC     4.702e-38             0    2.4964e-22    4.2764e-50    3.8264e-14
    MSFT       0.27667       0.17175      0.055435    4.6946e-32    4.0873e-14
    ORCL             0    6.6122e-39    9.6127e-23    3.7371e-32    3.7811e-14
    YHOO    1.1755e-38    1.1755e-38    2.6544e-23             0     3.535e-14

Input Arguments

collapse all

Previously constructed PortfolioCVaR object, specified using the PortfolioCVaR function

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.

Example: p = PortfolioCVaR('AssetList',Assets(1:12));

collapse all

Linear equality constraint matrix, specified as a matrix.

Data Types: double

Linear inequality constraint matrix, specified as a matrix.

Data Types: double

Names or symbols of assets in the universe, specified as a cell array of character vectors.

Data Types: cell

Linear equality constraint vector, specified as a vector.

Data Types: double

Linear inequality constraint vector, specified as a vector.

Data Types: double

Proportional purchase costs, specified as a vector.

Data Types: double

Turnover constraint on purchases, specified as a scalar.

Data Types: double

Group A weights to be bounded by weights in group B, specified as a matrix.

Data Types: double

Group B weights, specified as a matrix.

Data Types: double

Group membership matrix, specified as a matrix.

Data Types: double

Initial portfolio, specified as a vector.

Data Types: double

Lower-bound constraint, specified as a vector.

Data Types: double

Lower-bound budget constraint, specified as a scalar.

Data Types: double

Lower-bound group constraint, specified as a vector.

Data Types: double

Minimum ratio of allocations between GroupA and GroupB, specified as a vector.

Data Types: double

Name for instance of the Portfolio object, specified as a character vector.

Data Types: char

Number of assets in the universe, specified as an integer scalar.

Data Types: double

Number of scenarios, specified as an integer scalar.

Data Types: double

Value-at-risk probability level which is 1 − (loss probability), specified as a scalar.

Data Types: double

Risk-free rate, specified as a scalar.

Data Types: double

Proportional sales costs, specified as a vector.

Data Types: double

Turnover constraint on sales, specified as a scalar.

Data Types: double

Turnover constraint, specified as a scalar.

Data Types: double

Upper-bound constraint, specified as a vector.

Data Types: double

Upper-bound budget constraint, specified as a scalar.

Data Types: double

Upper-bound group constraint, specified as a vector.

Data Types: double

Maximum ratio of allocations between GroupA and GroupB, specified as a vector.

Data Types: double

Output Arguments

collapse all

Updated CVaR portfolio object, returned as a PortfolioCVaR object, For more information on using the PortfolioCVaR object, see PortfolioCVaR.

More About

collapse all

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.

PortfolioCVaR Problem Sufficiency

A CVaR portfolio optimization problem is completely specified with the PortfolioCVaR object if three conditions are met.

The following are the three conditions that must be met:

  • You must specify a collection of asset returns or prices known as scenarios such that all scenarios are finite asset returns or prices. These scenarios are meant to be samples from the underlying probability distribution of asset returns. This condition can be satisfied by the setScenarios function or with several canned scenario simulation functions.

  • The set of feasible portfolios must be a nonempty compact set, where a compact set is closed and bounded. You can satisfy this condition using an extensive collection of properties that define different types of constraints to form a set of feasible portfolios. Since such sets must be bounded, either explicit or implicit constraints can be imposed and several tools, such as the estimateBounds function, provide ways to ensure that your problem is properly formulated.

  • You must specify a probability level to locate the level of tail loss above which the conditional value-at-risk is to be minimized. This condition can be satisfied by the setProbabilityLevel function.

    Although the general sufficient conditions for CVaR portfolio optimization go beyond the first three conditions, the PortfolioCVaR object handles all these additional conditions.

Shortcuts for Property Names

The PortfolioCVaR function has shorter argument names that replace longer argument names associated with specific properties of the PortfolioCVaR object.

For example, rather than enter 'ProbabilityLevel', the PortfolioCVaR function accepts the case-insensitive name 'plevel' to set the ProbabilityLevel property in a PortfolioCVaR object. Every shorter argument name corresponds with a single property in the PortfolioCVaR function. The one exception is the alternative argument name 'budget', which signifies both the LowerBudget and UpperBudget properties. When 'budget' is used, then the LowerBudget and UpperBudget properties are set to the same value to form an equality budget constraint.

Shortcuts for Property Names

Shortcut Argument Name

Equivalent Argument / Property Name

ae

AEquality

ai

AInequality

assetnames or assets

AssetList

be

bEquality

bi

bInequality

budget

UpperBudget and LowerBudget

group

GroupMatrix

lb

LowerBound

n or num

NumAssets

level, problevel, or plevel

ProbabilityLevel

rfr

RiskFreeRate

scenario or assetscenarios

Scenarios

ub

UpperBound

References

[1] For a complete list of references for the PortfolioCVaR object, see Portfolio Optimization.

Introduced in R2012b

Was this topic helpful?