| Contents | Index |
Add linear equality constraints for portfolio weights to existing constraints
obj = addEquality(obj, AEquality, bEquality)
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.
Use dot notation to add the linear equality constraints for portfolio weights:
obj = obj.addEquality(AEquality, bEquality)
To remove linear equality constraints from a portfolio object:
obj = obj.setEquality([ ], [ ])
obj |
A portfolio object [Portfolio]. |
AEquality |
Matrix to form linear equality constraints [matrix]. |
bEquality |
Vector to form linear equality constraints [vector]. |
obj |
Updated portfolio object [Portfolio]. |
| Access | public |
| Static | false |
| Hidden | false |
To learn about attributes of methods, see Method Attributes in the MATLAB Object-Oriented Programming documentation.
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
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 |