Common Operations on the PortfolioCVaR Object

Naming a PortfolioCVaR Object

To name a PortfolioCVaR object, use the Name property. Name is informational and has no effect on any portfolio calculations. If the Name property is nonempty, Name is the title for the efficient frontier plot generated by plotFrontier. For example, if you set up an asset allocation fund, you could name the PortfolioCVaR object Asset Allocation Fund:

p = PortfolioCVaR('Name','Asset Allocation Fund');
disp(p.Name);
Asset Allocation Fund

Configuring the Assets in the Asset Universe

The fundamental quantity in the PortfolioCVaR object is the number of assets in the asset universe. This quantity is maintained in the NumAssets property. Although you can set this property directly, it is usually derived from other properties such as the number of assets in the scenarios or the initial portfolio. In some instances, the number of assets may need to be set directly. This example shows how to set up a PortfolioCVaR object that has four assets:

p = PortfolioCVaR('NumAssets', 4);
disp(p.NumAssets);
4

After setting the NumAssets property, you cannot modify it (unless no other properties are set that depend on NumAssets). The only way to change the number of assets in an existing PortfolioCVaR object with a known number of assets is to create a new PortfolioCVaR object.

Setting Up a List of Asset Identifiers

When working with portfolios, you must specify a universe of assets. Although you can perform a complete analysis without naming the assets in your universe, it is helpful to have an identifier associated with each asset as you create and work with portfolios. You can create a list of asset identifiers as a cell vector of strings in the property AssetList. You can set up the list using the next two methods.

Setting Up Asset Lists Using the Constructor

Suppose you have a PortfolioCVaR object, p, with assets with symbols 'AA'', 'BA', 'CAT', 'DD', and 'ETR'. You can create a list of these asset symbols in the object using the constructor:

p = PortfolioCVaR('assetlist', { 'AA', 'BA', 'CAT', 'DD', 'ETR' });
disp(p.AssetList);
'AA'    'BA'    'CAT'    'DD'    'ETR'

Notice that the property AssetList is maintained as a cell array that contains strings, and that it is necessary to pass a cell array into the constructor to set AssetList. In addition, notice that the property NumAssets is set to 5 based on the number of symbols used to create the asset list:

disp(p.NumAssets);
5

Setting Up Asset Lists Using the setAssetList Method

You can also specify a list of assets using the method setAssetList. Given the list of asset symbols 'AA', 'BA', 'CAT', 'DD', and'ETR', you can use setAssetList with:

p = PortfolioCVaR;
p = setAssetList(p, { 'AA', 'BA', 'CAT', 'DD', 'ETR' });
disp(p.AssetList);
 'AA'    'BA'    'CAT'    'DD'    'ETR'

setAssetList also enables you enter symbols directly as a comma-separated list without creating a cell array of strings. For example, given the list of assets symbols 'AA', 'BA', 'CAT', 'DD', and 'ETR', use setAssetList:

p = PortfolioCVaR;
p = setAssetList(p, 'AA', 'BA', 'CAT', 'DD', 'ETR');
disp(p.AssetList);
'AA'    'BA'    'CAT'    'DD'    'ETR'

setAssetList has many additional features to create lists of asset identifiers. If you use setAssetList with just a PortfolioCVaR object, it creates a default asset list according to the name specified in the hidden public property defaultforAssetList (which is 'Asset' by default). The number of asset names created depends on the number of assets in the property NumAssets. If NumAssets is not set, then NumAssets is assumed to be 1.

For example, if a PortfolioCVaR object p is created with NumAssets = 5, then this code fragment shows the default naming behavior:

p = PortfolioCVaR('numassets',5);
p = setAssetList(p);
disp(p.AssetList);
'Asset1'    'Asset2'    'Asset3'    'Asset4'    'Asset5'

Suppose that your assets are, for example, ETFs and you change the hidden property defaultforAssetList to 'ETF', you can then create a default list for ETFs:

p = PortfolioCVaR('numassets',5);
p.defaultforAssetList = 'ETF'; 
p = setAssetList(p);
disp(p.AssetList);
'ETF1'    'ETF2'    'ETF3'    'ETF4'    'ETF5'

Truncating and Padding Asset Lists

If the NumAssets property is already set and you pass in too many or too few identifiers, the CVaR portfolio constructor, and the setAssetList method truncate or pad the list with numbered default asset names that use the name specified in the hidden public property defaultforAssetList. If the list is truncated or padded, a warning message indicates the discrepancy. For example, assume you have a PortfolioCVaR object with five ETFs and you only know the first three CUSIPs '921937835', '922908769', and '922042775'. Use this syntax to create an asset list that pads the remaining asset identifiers with numbered 'UnknownCUSIP' placeholders:

p = PortfolioCVaR('numassets',5);
p.defaultforAssetList = 'UnknownCUSIP';
p = setAssetList(p, '921937835', '922908769', '922042775');
disp(p.AssetList);
Warning: Input list of assets has 2 too few identifiers. Padding with numbered assets. 
> In PortfolioCVaR.setAssetList at 118 
    '921937835'    '922908769'    '922042775'    'UnknownCUSIP4'    'UnknownCUSIP5'

Alternatively, suppose you have too many identifiers and need only the first four assets. This example illustrates truncation of the asset list using the PortfolioCVaR constructor:

p = PortfolioCVaR('numassets',4);
p = PortfolioCVaR(p, 'assetlist', { 'AGG', 'EEM', 'MDY', 'SPY', 'VEU' });
disp(p.AssetList);
Warning: AssetList has 1 too many identifiers. Using first 4 assets. 
> In PortfolioCVaR.checkarguments at 399
  In PortfolioCVaR.PortfolioCVaR>PortfolioCVaR.PortfolioCVaR at 195 
    'AGG'    'EEM'    'MDY'    'SPY'

The hidden public property uppercaseAssetList is a Boolean flag to specify whether to convert asset names to uppercase letters. The default value for uppercaseAssetList is false. This example shows how to use the uppercaseAssetList flag to force identifiers to be uppercase letters:

p = PortfolioCVaR;
p.uppercaseAssetList = true;
p = setAssetList(p, { 'aa', 'ba', 'cat', 'dd', 'etr' });
disp(p.AssetList);
'AA'    'BA'    'CAT'    'DD'    'ETR'

Setting Up an Initial or Current Portfolio

In many applications, creating a new optimal portfolio requires comparing the new portfolio with an initial or current portfolio to form lists of purchases and sales. The PortfolioCVaR object property InitPort lets you identify an initial or current portfolio. The initial portfolio also plays an essential role if you have either transaction costs or turnover constraints. The initial portfolio need not be feasible within the constraints of the problem. This can happen if the weights in a portfolio have shifted such that some constraints become violated. To check if your initial portfolio is feasible, use the method checkFeasibility described in Validating CVaR Portfolios. Suppose you have an initial portfolio in x0, then use the PortfolioCVaR object constructor to set up an initial portfolio:

x0 = [ 0.3; 0.2; 0.2; 0.0 ];
p = PortfolioCVaR('InitPort', x0);
disp(p.InitPort);
  0.3000
  0.2000
  0.2000
       0

As with all array properties, you can set InitPort with scalar expansion. This is helpful to set up an equally weighted initial portfolio of, for example, 10 assets:

p = PortfolioCVaR('NumAssets', 10, 'InitPort', 1/10);
disp(p.InitPort);
 0.1000
 0.1000
 0.1000
 0.1000
 0.1000
 0.1000
 0.1000
 0.1000
 0.1000
 0.1000

To clear an initial portfolio from your PortfolioCVaR object, use either the constructor or the setInitPort method with an empty input for the InitPort property. If transaction costs or turnover constraints are set, it is not possible to clear the InitPort property in this way. In this case, to clear InitPort, first clear the dependent properties and then clear theInitPort property.

The InitPort property can also be set with setInitPort which lets you specify the number of assets if you want to use scalar expansion. For example, given an initial portfolio in x0, use setInitPort to set the InitPort property:

p = PortfolioCVaR;
x0 = [ 0.3; 0.2; 0.2; 0.0 ];
p = setInitPort(p, x0);
disp(p.InitPort);
 0.3000
 0.2000
 0.2000
      0

To create an equally weighted portfolio of four assets, use setInitPort:

p = PortfolioCVaR;
p = setInitPort(p, 1/4, 4);
disp(p.InitPort); 
 0.2500
 0.2500
 0.2500
 0.2500

PortfolioCVaR object methods that work with either transaction costs or turnover constraints also depend on the InitPort property. Consequently, the set methods for transaction costs or turnover constraints permit the assignment of a value for the InitPort property as part of their implementation. For details, see Working with Average Turnover Constraints, Working with One-Way Turnover Constraints, and Working with Transaction Costs. If either transaction costs or turnover constraints are used, then the InitPort property must have a nonempty value. Absent a specific value assigned through the constructor or various set methods, the PortfolioCVaR object sets InitPort to 0 and warns if BuyCost, SellCost, or Turnover properties are set. This example shows what happens if you specify an average turnover constraint with an initial portfolio:

p = PortfolioCVaR('Turnover', 0.3, 'InitPort', [ 0.3; 0.2; 0.2; 0.0 ]);
disp(p.InitPort);
 0.3000
 0.2000
 0.2000
      0

In contrast, this example shows what happens if an average turnover constraint is specified without an initial portfolio:

p = PortfolioCVaR('Turnover', 0.3);
disp(p.InitPort);
Warning: InitPort and NumAssets are empty and either transaction costs or turnover constraints specified. 
Will set NumAssets = 1 and InitPort = 0. 
> In PortfolioCVaR.checkarguments at 322
  In PortfolioCVaR.PortfolioCVaR>PortfolioCVaR.PortfolioCVaR at 195 
     0

See Also

| | | |

Related Examples

More About

Was this topic helpful?