Main Content

Common Operations on the PortfolioMAD Object

Naming a PortfolioMAD Object

To name a PortfolioMAD 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 PortfolioMAD object Asset Allocation Fund:

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

Configuring the Assets in the Asset Universe

The fundamental quantity in the PortfolioMAD 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 PortfolioMAD object that has four assets:

p = PortfolioMAD('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 PortfolioMAD object with a known number of assets is to create a new PortfolioMAD 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 character vectors in the property AssetList. You can set up the list using the next two methods.

Setting Up Asset Lists Using the PortfolioMAD Function

Suppose that you have a PortfolioMAD 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 PortfolioMAD:

p = PortfolioMAD('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 character vectors, and that it is necessary to pass a cell array into PortfolioMAD 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 Function

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

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

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

p = PortfolioMAD;
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 PortfolioMAD 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 PortfolioMAD object p is created with NumAssets = 5, then this code fragment shows the default naming behavior:

p = PortfolioMAD('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 = PortfolioMAD('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 PortfolioMAD object, and the setAssetList function 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 that you have a PortfolioMAD 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 = PortfolioMAD('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 PortfolioMAD.setAssetList at 121 
  Columns 1 through 4

    '921937835'    '922908769'    '922042775'    'UnknownCUSIP4'

  Column 5

    'UnknownCUSIP5'

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

p = PortfolioMAD('numassets',4);
p = PortfolioMAD(p, 'assetlist', { 'AGG', 'EEM', 'MDY', 'SPY', 'VEU' });
disp(p.AssetList)
Warning: AssetList has 1 too many identifiers. Using first 4 assets. 
> In PortfolioMAD.checkarguments at 410
  In PortfolioMAD.PortfolioMAD>PortfolioMAD.PortfolioMAD at 187 
    '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 = PortfolioMAD;
p.uppercaseAssetList = true;
p = setAssetList(p, { 'aa', 'ba', 'cat', 'dd', 'etr' });
disp(p.AssetList)
'AA'    'BA'    'CAT'    'DD'    'ETR'

See Also

| | | |

Related Examples

More About