setAssetList

Set up list of identifiers for assets

Syntax

obj = setAssetList(obj,AssetList)
obj = setAssetList(obj,'asset1','asset2',asset3',...)

Description

example

obj = setAssetList(obj,AssetList) sets up the list of identifiers for assets for Portfolio, PortfolioCVaR, or PorfolioMAD objects. For details on the respective workflows when using these different objects, see Portfolio Object Workflow, PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

example

obj = setAssetList(obj,'asset1','asset2',asset3',...) sets up a list of asset identifiers, specified as a comma-separated list of character vectors, a cell array of character vectors, or string array where each character vector or string is an asset identifier.

Note

  • If an asset list is entered as an input, this function overwrites an existing asset list in the object if one exists.

  • If no asset list is entered as an input, three actions can occur:

    • If NumAssets is nonempty and AssetList is empty, AssetList becomes a numbered list of assets with default names according to the hidden property in defaultforAssetList ('Asset').

    • If NumAssets is nonempty and AssetList is nonempty, nothing happens.

    • If NumAssets is empty and AssetList is empty, the default NumAssets =1 is set and a default asset list is created ('Asset1').

Examples

collapse all

Create a default list of asset names with three assets.

p = Portfolio('NumAssets',3);
p = setAssetList(p);
disp(p.AssetList);
    'Asset1'    'Asset2'    'Asset3'

Create a list of asset names for three equities AGG, EEM, and VEU.

p = Portfolio;
p = setAssetList(p, 'AGG', 'EEM', 'VEU');
disp(p.AssetList);
    'AGG'    'EEM'    'VEU'

Create a default list of asset names with three assets.

p = PortfolioCVaR('NumAssets',3);
p = setAssetList(p);
disp(p.AssetList);
    'Asset1'    'Asset2'    'Asset3'

Create a list of asset names for three equities AGG, EEM, and VEU.

p = PortfolioCVaR;
p = setAssetList(p, 'AGG', 'EEM', 'VEU');
disp(p.AssetList);
    'AGG'    'EEM'    'VEU'

Create a default list of asset names with three assets.

p = PortfolioMAD('NumAssets',3);
p = setAssetList(p);
disp(p.AssetList);
    'Asset1'    'Asset2'    'Asset3'

Create a list of asset names for three equities AGG, EEM, and VEU.

p = PortfolioMAD;
p = setAssetList(p, 'AGG', 'EEM', 'VEU');
disp(p.AssetList);
    'AGG'    'EEM'    'VEU'

Input Arguments

collapse all

Object for portfolio, specified using Portfolio, PortfolioCVaR, or PortfolioMAD object. For more information on creating a portfolio object, see

Data Types: object

List of assets, specified using a character vector, cell array of character vectors, or string array where each character vector or string is an asset identifier.

Data Types: char | cell | string

Output Arguments

collapse all

Updated portfolio object, returned as a Portfolio, PortfolioCVaR, or PortfolioMAD object. For more information on creating a portfolio object, see

The underlying object (obj) has a number of public hidden properties to format the asset list:

  • defaultforAssetList — Default name for assets ('Asset'). Change this name to create default asset names such as 'ETF', 'Bond'.

  • sortAssetList — Reserved for future implementation.

  • uppercaseAssetList — If true, make all asset identifiers uppercase character vectors. Otherwise do nothing. Default is false.

Tips

  • You can also use dot notation to set up list of identifiers for assets.

    obj = obj.setAssetList(AssetList);

  • To clear an AssetList, call this function with [] or {[]}.

Introduced in R2011a