Main Content

setInitPort

Set up initial or current portfolio

Description

obj = setInitPort(obj,InitPort) sets up initial or current portfolio for Portfolio, PortfolioCVaR, or PortfolioMAD 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 = setInitPort(obj,InitPort,NumAssets) sets up initial or current portfolio for portfolio objects with an additional options specified for NumAssets.

example

Examples

collapse all

Given an initial portfolio in x0, use the setInitPort function to set the InitPort property.

p = Portfolio('NumAssets', 4);
x0 = [ 0.3; 0.2; 0.2; 0.0 ];
p = setInitPort(p, x0);
disp(p.InitPort);
    0.3000
    0.2000
    0.2000
         0

Create an equally weighted portfolio of four assets using the setInitPort function.

p = Portfolio('NumAssets', 4);
p = setInitPort(p, 1/4, 4);
disp(p.InitPort);
    0.2500
    0.2500
    0.2500
    0.2500

Given an initial portfolio in x0, use the setInitPort function to set the InitPort property.

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

Create an equally weighted portfolio of four assets using the setInitPort function.

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

Given an initial portfolio in x0, use the setInitPort function to set the InitPort property.

p = PortfolioMAD('NumAssets', 4);
x0 = [ 0.3; 0.2; 0.2; 0.0 ];
p = setInitPort(p, x0);
disp(p.InitPort);
    0.3000
    0.2000
    0.2000
         0

Create an equally weighted portfolio of four assets using the setInitPort function.

p = PortfolioMAD('NumAssets', 4);
p = setInitPort(p, 1/4, 4);
disp(p.InitPort);
    0.2500
    0.2500
    0.2500
    0.2500

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

Initial or current portfolio weights, specified as a vector for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Note

If InitPort is specified as a scalar and NumAssets exists, then InitPort undergoes scalar expansion.

Data Types: double

Number of assets in portfolio, specified as a scalar for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Note

If it is not possible to obtain a value for NumAssets, it is assumed that NumAssets is 1.

Data Types: double

Output Arguments

collapse all

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

Tips

  • You can also use dot notation to set up an initial or current portfolio.

    obj = obj.setInitPort(InitPort, NumAssets);

  • To remove an initial portfolio, call this function with an empty argument [] for InitPort.

Version History

Introduced in R2011a