Documentation

This is machine translation

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

Add linear equality constraints for portfolio weights to existing constraints

Use the addEquality function with a Portfolio, PortfolioCVaR, or PortfolioMAD object to add linear equality constraints for portfolio weights to existing constraints.

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

Description

example

obj = addEquality(obj,AEquality,bEquality) adds linear equality constraints for portfolio weights to existing constraints.

Given a linear equality constraint matrix AEquality and vector bEquality, every weight in a portfolio Port must satisfy the following:

AEquality * Port = bEquality

This function "stacks" additional linear equality constraints onto any existing linear equality constraints that exist in the input portfolio object. If no constraints exist, this method is the same as setEquality.

Examples

collapse all

Use the addEquality method to create linear equality constraints. Add another linear equality constraint to ensure that the last three assets constitute 50% of a portfolio.

p = Portfolio;
A = [ 1 1 1 0 0 ];    % First equality constraint
b = 0.5;
p = setEquality(p, A, b);

A = [ 0 0 1 1 1 ];    % Second equality constraint
b = 0.5;

disp(p.NumAssets);
5
disp(p.AEquality);
1     1     1     0     0
0     0     1     1     1
disp(p.bEquality);
0.5000
0.5000

Use the addEquality method to create linear equality constraints. Add another linear equality constraint to ensure that the last three assets constitute 50% of a portfolio.

p = PortfolioCVaR;
A = [ 1 1 1 0 0 ];    % First equality constraint
b = 0.5;
p = setEquality(p, A, b);

A = [ 0 0 1 1 1 ];    % Second equality constraint
b = 0.5;

disp(p.NumAssets);
5
disp(p.AEquality);
1     1     1     0     0
0     0     1     1     1
disp(p.bEquality);
0.5000
0.5000

Use the addEquality method to create linear equality constraints. Add another linear equality constraint to ensure that the last three assets constitute 50% of a portfolio.

A = [ 1 1 1 0 0 ];    % First equality constraint
b = 0.5;
p = setEquality(p, A, b);

A = [ 0 0 1 1 1 ];    % Second equality constraint
b = 0.5;

disp(p.NumAssets);
5
disp(p.AEquality);
1     1     1     0     0
0     0     1     1     1
disp(p.bEquality);
0.5000
0.5000

Input Arguments

collapse all

Object for portfolio, specified using Portfolio, PortfolioCVaR, or PortfolioMAD object. For more information on creating a portfolio object, see

Linear equality constraints, specified as a matrix.

Note

An error results if AEquality is empty and bEquality is nonempty.

Data Types: double

Linear equality constraints, specified as a vector.

Note

An error results if bEquality is empty and AEquality is nonempty.

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 add the linear equality constraints for portfolio weights.