# Using Portfolio Objects

Portfolio object for mean-variance portfolio optimization and analysis

The Portfolio object implements mean-variance portfolio optimization. Portfolio objects support functions 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 using supported functions 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 these 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, 'UpperBudget',1, 'LowerBudget',1)```
or equivalently by:
```p = Portfolio; p = setAssetMoments(p, AssetMean, AssetCovar); p = setDefaultConstraints(p);```

For more information on the workflow when using Portfolio objects, see Portfolio Object Workflow and for more detailed information on the theoretical basis for mean-variance optimization, see Portfolio Optimization Theory.

## Examples

collapse 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 ```

## Properties

 Portfolio Properties Manage Portfolio object for mean-variance portfolio optimization and analysis

## Object Functions

 setAssetList Set up list of identifiers for assets setInitPort Set up initial or current portfolio setDefaultConstraints Set up portfolio constraints with nonnegative weights that sum to 1 getAssetMoments Obtain mean and covariance of asset returns from Portfolio object setAssetMoments Set moments (mean and covariance) of asset returns for Portfolio object estimateAssetMoments Estimate mean and covariance of asset returns from data setCosts Set up proportional transaction costs addEquality Add linear equality constraints for portfolio weights to existing constraints addGroupRatio Add group ratio constraints for portfolio weights to existing group ratio constraints addGroups Add group constraints for portfolio weights to existing group constraints addInequality Add linear inequality constraints for portfolio weights to existing constraints getBounds Obtain bounds for portfolio weights from portfolio object getBudget Obtain budget constraint bounds from portfolio object getCosts Obtain buy and sell transaction costs from portfolio object getEquality Obtain equality constraint arrays from portfolio object getGroupRatio Obtain group ratio constraint arrays from portfolio object getGroups Obtain group constraint arrays from portfolio object getInequality Obtain inequality constraint arrays from portfolio object getOneWayTurnover Obtain one-way turnover constraints from portfolio object setGroups Set up group constraints for portfolio weights setInequality Set up linear inequality constraints for portfolio weights setBounds Set up bounds for portfolio weights setBudget Set up budget constraints setCosts Set up proportional transaction costs setDefaultConstraints Set up portfolio constraints with nonnegative weights that sum to 1 setEquality Set up linear equality constraints for portfolio weights setGroupRatio Set up group ratio constraints for portfolio weights setInitPort Set up initial or current portfolio setOneWayTurnover Set up one-way portfolio turnover constraints setTurnover Set up maximum portfolio turnover constraint checkFeasibility Check feasibility of input portfolios against portfolio object estimateBounds Estimate global lower and upper bounds for set of portfolios estimateFrontier Estimate specified number of optimal portfolios on the efficient frontier estimateFrontierByReturn Estimate optimal portfolios with targeted portfolio returns estimateFrontierByRisk Estimate optimal portfolios with targeted portfolio risks estimateFrontierLimits Estimate optimal portfolios at endpoints of efficient frontier plotFrontier Plot efficient frontier estimateMaxSharpeRatio Estimate efficient portfolio to maximize Sharpe ratio for Portfolio object estimatePortMoments Estimate moments of portfolio returns for Portfolio object estimatePortReturn Estimate mean of portfolio returns estimatePortRisk Estimate standard deviation of portfolio returns (portfolio risk) setSolver Choose main solver and specify associated solver options for portfolio optimization

## Create Object

To create a `Portfolio` object, use the `Portfolio` function. For more details on working with a Portfolio object, see:

## External Web Sites

#### Introduced in R2011a

Was this topic helpful?

Get trial now