Documentation

Portfolio class

Superclasses: AbstractPortfolio

Portfolio object for mean-variance portfolio optimization and analysis

Description

The Portfolio object implements mean-variance portfolio optimization and is derived from the abstract portfolio optimization class AbstractPortfolio. Portfolio objects implement all methods in the AbstractPortfolio class along with methods that are specific to mean-variance portfolio optimization.

The main workflow for portfolio optimization is to create an instance of a Portfolio object that completely specifies a portfolio optimization problem and to operate on the Portfolio object to obtain and analyze efficient portfolios. A mean-variance optimization problem is completely specified with the following three elements:

  • A universe of assets with estimates for the prospective mean and covariance of asset total returns for a period of interest.

  • A portfolio set that specifies the set of portfolio choices in terms of a collection of constraints.

  • A model for portfolio return and risk, which, for mean-variance optimization, is either the gross or net mean of portfolio returns and the standard deviation of portfolio returns.

After you specify three elements in an unambiguous way, you can solve and analyze portfolio optimization problems. The simplest mean-variance portfolio optimization problem has:

  • A mean and covariance of asset total returns

  • Nonnegative weights for all portfolios that sum to 1 (the summation constraint is known as a budget constraint)

  • Built-in models for portfolio return and risk that use the mean and covariance of asset total returns

Given mean and covariance of asset returns in the variables AssetMean and AssetCovar, this problem is completely specified by:

p = Portfolio('AssetMean', AssetMean, 'AssetCovar', AssetCovar,...
'LowerBound', 0, 'Budget')

or equivalently by:

p = Portfolio;
p = setAssetMoments(p, AssetMean, AssetCovar); 
p = setDefaultConstraints(p);

Construction

p = Portfolio constructs an empty Portfolio object for mean-variance portfolio optimization and analysis. You can then add elements to the Portfolio object using the supported add and set methods. For more information, see Constructing the Portfolio Object.

p = Portfolio(Name,Value) constructs a Portfolio object for mean-variance portfolio optimization and analysis with additional options specified by one or more Name,Value pair arguments. Name is a property name and Value is its corresponding value. Name must appear inside single quotes (''). You can specify several name-value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

p = Portfolio(p,Name,Value) constructs a Portfolio object for mean-variance portfolio optimization and analysis using a previously constructed Portfolio object p with additional options specified by one or more Name,Value pair arguments.

Input Arguments

p

(Optional) Previously constructed Portfolio object (p).

Property Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

'AInequality'

Linear inequality constraint matrix ([] or [matrix]).

Default: []

'AssetCovar'

Covariance of asset returns ([] or square matrix.

Default: []

'AssetList'

Names or symbols of assets in the universe ([] or [vector cell of strings]).

Default: []

'AssetMean'

Mean of asset returns ([] or vector).

Default: []

'bInequality'

Linear inequality constraint vector ([] or [vector]).

Default: []

'BuyCost'

Proportional purchase costs ([] or vector).

Default: []

'BuyTurnover'

Turnover constraint on purchases ([] or [scalar]).

Default: []

'GroupA'

Group A weights to be bounded by weights in group B ([] or [matrix]).

Default: []

'GroupB'

Group B weights ([] or [matrix]).

Default: []

'GroupMatrix'

Group membership matrix ([] or [matrix]).

Default: []

'InitPort'

Initial portfolio ([] or vector).

Default: []

'LowerBudget'

Lower-bound budget constraint ([] or [scalar]).

Default: []

'LowerGroup'

Lower-bound group constraint ([] or [vector]).

Default: []

'LowerRatio'

Minimum ratio of allocations between groups A and B ([] or [vector]).

Default: []

'Name'

Name for instance of the Portfolio object ([] or [string]).

Default: []

'NumAssets'

Number of assets in the universe ([] or [integer scalar]).

Default: []

'RiskFreeRate'

Risk-free rate ([] or scalar).

Default: []

'SellCost'

Proportional sales costs ([] or vector).

Default: []

'SellTurnover'

Turnover constraint on sales ([] or [scalar]).

Default: []

'Turnover'

Turnover constraint ([] or [scalar]).

Default: []

'UpperBound'

Upper-bound constraint ([] or [vector]).

Default: []

'UpperBudget'

Upper-bound budget constraint ([] or [scalar]).

Default: []

'UpperGroup'

Upper-bound group constraint ([] or [vector]).

Default: []

'UpperRatio'

Maximum ratio of allocations between groups A and B ([] or [vector]).

Default: []

Properties

The following properties are from the Portfolio class.

AssetCovar

Covariance of asset returns ([] or matrix).

Attributes:

SetAccesspublic
GetAccesspublic

AssetMean

Mean of asset returns ([] or vector).

Attributes:

SetAccesspublic
GetAccesspublic

BuyCost

Proportional purchase costs ([] or vector).

Attributes:

SetAccesspublic
GetAccesspublic

BuyTurnover

Turnover constraint on purchases ([] or [scalar]).

Attributes:

SetAccesspublic
GetAccesspublic

RiskFreeRate

Risk-free rate ([] or scalar).

Attributes:

SetAccesspublic
GetAccesspublic

SellCost

Proportional sales costs ([] or vector).

Attributes:

SetAccesspublic
GetAccesspublic

SellTurnover

Turnover constraint on sales ([] or [scalar]).

Attributes:

SetAccesspublic
GetAccesspublic

Turnover

Turnover constraint ([] or [scalar]).

Attributes:

SetAccesspublic
GetAccesspublic

Properties

The following properties are inherited from the AbstractPortfolio class.

AEquality

Linear equality constraint matrix ([] or [matrix]).

Attributes:

SetAccesspublic
GetAccesspublic

AInequality

Linear inequality constraint matrix ([] or [matrix]).

Attributes:

SetAccesspublic
GetAccesspublic

AssetList

Names or symbols of assets in the universe ([] or [vector cell of strings]).

Attributes:

SetAccesspublic
GetAccesspublic

bEquality

Linear equality constraint vector ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

bInequality

Linear inequality constraint vector ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

GroupA

Group A weights to be bounded by group B ([] or [matrix]).

Attributes:

SetAccesspublic
GetAccesspublic

GroupB

Group B weights ([] or [matrix]).

Attributes:

SetAccesspublic
GetAccesspublic

GroupMatrix

Group membership matrix ([] or [matrix]).

Attributes:

SetAccesspublic
GetAccesspublic

InitPort

Initial portfolio ([] or vector).

Attributes:

SetAccesspublic
GetAccesspublic

LowerBound

Lower-bound constraint ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

LowerBudget

Lower-bound budget constraint ([] or [scalar]).

Attributes:

SetAccesspublic
GetAccesspublic

LowerGroup

Lower-bound group constraint ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

LowerRatio

Minimum ratio of allocations between groups A and B ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

Name

Name for instance of the Portfolio object ([] or [string]).

Attributes:

SetAccesspublic
GetAccesspublic

NumAssets

Number of assets in the universe ([] or [integer scalar]).

Attributes:

SetAccesspublic
GetAccesspublic

UpperBound

Upper-bound constraint ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

UpperBudget

Upper-bound budget constraint ([] or [scalar]).

Attributes:

SetAccesspublic
GetAccesspublic

UpperGroup

Upper-bound group constraint ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

UpperRatio

Maximum ratio of allocations between groups A and B ([] or [vector]).

Attributes:

SetAccesspublic
GetAccesspublic

Inherited Methods

The following methods are inherited from the AbstractPortfolio class.

addEquality

Add equality constraints for portfolio weights to existing constraints.

addGroupRatio

Add group ratio constraints for portfolio weights to existing constraints.

addGroups

Add group constraints for portfolio weights to existing constraints.

addInequality

Add inequality constraints for portfolio weights to existing constraints.

checkFeasibility

Determine if portfolios are members of the set of feasible portfolios.

estimateBounds

Determine if set of feasible portfolios is nonempty and bounded.

estimateFrontier

Estimate portfolios on the entire efficient frontier.

estimateFrontierByReturn

Estimate portfolios on the efficient frontier with targeted returns or return proxies.

estimateFrontierByRisk

Estimate portfolios on the efficient frontier with targeted risks or risk proxies.

estimateFrontierLimits

Estimate portfolios at the extreme ends of the efficient frontier (minimum risk and maximum return).

estimateMaxSharpeRatio

Estimate efficient portfolio that maximizes the Sharpe ratio.

estimatePortReturn

Estimate return or return proxy for specified portfolios.

estimatePortRisk

Estimate risk or risk proxy for specified portfolios.

getBounds

Get lower and upper bounds from the object.

getBudget

Get lower and upper budget constraints from the object.

getEquality

Get equality constraint matrix and vector from the object.

getGroupRatio

Get base matrix, comparison matrix, and lower and upper bounds for group ratio constraints from the object.

getGroups

Get group matrix and lower and upper bounds for group constraints from the object.

getInequality

Get inequality constraint matrix and vector from the object.

plotFrontier

Plot efficient frontier and optionally obtain risks and returns for portfolios on the efficient frontier.

setAssetList

Set up a list of asset names and symbols to be associated with assets in the universe.

setBounds

Set up lower and upper bounds for portfolio weights.

setBudget

Set up lower and upper budget constraints for portfolio weights.

setDefaultConstraints

Set up default constraints for portfolio weights (nonnegative weights that must sum to 1).

setEquality

Set up equality constraints for portfolio weights.

setGroupRatio

Set up group ratio constraints for portfolio weights.

setGroups

Set up group constraints for portfolio weights.

setInequality

Set up inequality constraints for portfolio weights.

setInitPort

Set up initial portfolio weights.

setOptions

Set up hidden control properties in object (not implemented).

setSolver

Set up solver to estimate efficient portfolios.

Methods

estimateAssetMoments

Estimate mean and covariance of asset returns from price or return data.

estimatePortMoments

Estimate mean and standard deviation of portfolio returns for specified portfolios.

getAssetMoments

Get mean and covariance of asset returns from the object.

getCosts

Get purchase and sales proportional transaction costs from the object.

getOneWayTurnover

Get one-way portfolio turnover constraints.

setAssetMoments

Set up mean and covariance of asset returns.

setCosts

Set up purchase and sale proportional transaction costs for assets in the universe.

setOneWayTurnover

Set up one-way portfolio turnover constraints.

setTurnover

Set up average turnover constraints for portfolio weights.

Definitions

Mean-Variance Portfolio Optimization

For more information on the theory and definition of mean-variance optimization supported by portfolio optimization tools in Financial Toolbox™, see Portfolio Optimization Theory.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB® documentation.

Examples

expand all

Construct a Portfolio Object and Determine Efficient Portfolios

Create efficient portfolios:

load CAPMuniverse

p = Portfolio('AssetList',Assets(1:12));
p = estimateAssetMoments(p, Data(:,1:12),'missingdata',true);
p = setDefaultConstraints(p);
plotFrontier(p);

pwgt = estimateFrontier(p, 5);

pnames = cell(1,5);
for i = 1:5
	pnames{i} = sprintf('Port%d',i);
end

Blotter = dataset([{pwgt},pnames],'obsnames',p.AssetList);

disp(Blotter);
            Port1        Port2       Port3       Port4      Port5
    AAPL     0.017926    0.058247    0.097816    0.12955    0    
    AMZN            0           0           0          0    0    
    CSCO            0           0           0          0    0    
    DELL    0.0041906           0           0          0    0    
    EBAY            0           0           0          0    0    
    GOOG      0.16144     0.35678     0.55228    0.75116    1    
    HPQ      0.052566    0.032302    0.011186          0    0    
    IBM       0.46422     0.36045     0.25577    0.11928    0    
    INTC            0           0           0          0    0    
    MSFT      0.29966     0.19222    0.082949          0    0    
    ORCL            0           0           0          0    0    
    YHOO            0           0           0          0    0    

References

For a complete list of references for the Portfolio object and portfolio optimization tools, see Portfolio Optimization.

Was this topic helpful?