Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

setInitPort

Set up initial or current portfolio

Use the setInitPort function with a Portfolio, PortfolioCVaR, or PortfolioMAD object to set up initial or current portfolio for portfolio objects.

For details on the respective workflows when using these different objects, see Portfolio Object Workflow, PortfolioCVaR Object Workflow, and PortfolioMAD Object Workflow.

Syntax

obj = setInitPort(obj,InitPort)
obj = setInitPort(obj,InitPort,NumAssets)

Description

example

obj = setInitPort(obj,InitPort) sets up initial or current portfolio for portfolio objects.

example

obj = setInitPort(obj,InitPort,NumAssets) sets up initial or current portfolio for portfolio objects with an additional options specified for NumAssets.

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

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 method with an empty argument [] for InitPort.

Introduced in R2011a

Was this topic helpful?