Main Content

setGroups

Set up group constraints for portfolio weights

Description

example

obj = setGroups(obj,GroupMatrix,LowerGroup) sets up group constraints for portfolio weights 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 = setGroups(obj,GroupMatrix,LowerGroup,UpperGroup) sets up group constraints for portfolio weights for portfolio objects with an additional option specified for UpperGroup.

Given GroupMatrix and either LowerGroup or UpperGroup, a portfolio Port must satisfy the following:

LowerGroup <= GroupMatrix * Port <= UpperGroup

Examples

collapse all

Suppose you have a portfolio of five assets and you want to ensure that the first three assets constitute at most 30% of your portfolio. Given a Portfolio object p, set the group constraints with the following.

G = [ true true true false false ];
p = Portfolio;
p = setGroups(p, G, [], 0.3);

disp(p.NumAssets);
     5
disp(p.GroupMatrix);
     1     1     1     0     0
disp(p.UpperGroup);
    0.3000

Suppose you have a portfolio of five assets and you want to ensure that the first three assets constitute at most 30% of your portfolio. Given a CVaR portfolio object p, set the group constraints with the following.

G = [ true true true false false ];
p = PortfolioCVaR;
p = setGroups(p, G, [], 0.3);

disp(p.NumAssets);
     5
disp(p.GroupMatrix);
     1     1     1     0     0
disp(p.UpperGroup);
    0.3000

Suppose you have a portfolio of five assets and you want to ensure that the first three assets constitute at most 30% of your portfolio. Given PortfolioMAD object p, set the group constraints with the following.

G = [ true true true false false ];
p = PortfolioMAD;
p = setGroups(p, G, [], 0.3);

disp(p.NumAssets);
     5
disp(p.GroupMatrix);
     1     1     1     0     0
disp(p.UpperGroup);
    0.3000

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

Group constraint matrix, specified as a matrix for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Note

The group matrix GroupMatrix is usually an indicator of membership in groups, which means that its elements are usually either 0 or 1. Because of this interpretation, GroupMatrix can be either a logical or numerical matrix.

Data Types: double

Lower bound for group constraints, specified as a vector for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Note

If input is scalar, LowerGroup undergoes scalar expansion to be conformable with GroupMatrix.

Data Types: double

Upper bound for group constraints, returned as a vector for a Portfolio, PortfolioCVaR, or PortfolioMAD input object (obj).

Note

If input is scalar, UpperGroup undergoes scalar expansion to be conformable with GroupMatrix.

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 group constraints for portfolio weights.

    obj = obj.setGroups(GroupMatrix, LowerGroup, UpperGroup);

  • To remove group constraints, enter empty arrays for the corresponding arrays. To add to existing group constraints, use addGroups.

Version History

Introduced in R2011a