Skip to Main Content Skip to Search
Product Documentation

addEquality - Class: Portfolio

Add linear equality constraints for portfolio weights to existing constraints

Syntax

obj = addEquality(obj, AEquality, bEquality)

Description

obj = addEquality(obj, AEquality, bEquality) to add 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:

AEquality * Port = bEquality

An results if AEquality is empty and bEquality is nonempty, or if AEquality is nonempty and bEquality is empty.

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

Tips

Input Arguments

obj

A portfolio object [Portfolio].

AEquality

Matrix to form linear equality constraints [matrix].

bEquality

Vector to form linear equality constraints [vector].

Output Arguments

obj

Updated portfolio object [Portfolio].

Attributes

Accesspublic
Staticfalse
Hiddenfalse

To learn about attributes of methods, see Method Attributes in the MATLAB Object-Oriented Programming documentation.

Examples

To add another linear equality constraint to ensure that the last 3 assets constitute 50% of a portfolio, use addEquality to build up linear equality constraints:

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

A = [ 0 0 1 1 1 ];    % second equality constraint
b = 0.5;
p = p.addEquality(A, b);

disp(p.NumAssets);
disp(p.AEquality);
disp(p.bEquality);

5

1     1     1     0     0
0     0     1     1     1

0.5000
0.5000

See Also

Portfolio | setEquality

  


Free Interactive Computational Finance CD

View demos and recorded presentations led by industry experts.

Now On Demand
Network with industry peers and learn the latest applications of the leading software product for computational finance.

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS