Class: Portfolio

Set up list of identifiers for assets


obj = setAssetList(obj,varargin)


obj = setAssetList(obj,varargin) sets up a list of identifiers for the assets.


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

    obj = obj.setAssetList(varargin);
  • To clear an AssetList, call this method with[] or{[]}.

Input Arguments


Portfolio object [Portfolio].


Asset identifiers. Either a comma-separated list of strings or a vector cell array of strings. Each string is an asset identifier.

If an asset list is entered as an input, this method 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').

For more information on setting up a list of asset identifiers, see Common Operations on the Portfolio Object.

Output Arguments


Updated Portfolio object [Portfolio].

    Note:   The underlying object 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', and so on.

    • sortAssetList — Reserved for future implementation.

    • uppercaseAssetList — If true, make all asset identifiers uppercase strings. Otherwise does nothing. Default is false.



To learn about attributes of methods, see Method Attributes in the MATLAB® Object-Oriented Programming documentation.


expand all

Create a Default List of Asset Names with Three Assets

Create a default list of asset names with three assets.

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

Create an Explicitly Named List of Asset Names with Three Assets

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

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

See Also

Was this topic helpful?