Financial Toolbox | ![]() ![]() |
Specifying Additional Constraints
The example above defined a constraints matrix that specified a set of typical scenarios. It defined groups of assets, specified upper and lower bounds for total allocation in each of these groups, and it set the total allocation of one of the groups to a fixed value. Constraints like these are common occurrences. The function portcons
was created to simplify the creation of the constraint matrix for these and other common portfolio requirements. portcons
takes as input arguments a list of constraint-specifier strings, followed by the data necessary to build the constraint specified by the strings.
Assume that you need to add more constraints to the previous example. Specifically, add a constraint indicating that the sum of weights in any portfolio should be equal to 1, and another set of constraints (one per asset) indicating that the weight for each asset must greater than 0. This translates into five more constraint rows: two for the new equality, and three indicating that each weight must be greater or equal to 0. The total number of inequalities in the example is now 13. Clearly, creating the constraint matrix can turn into a tedious task.
To create the new constraint matrix using portcons
, use two separate constraint-specifier strings:
Default'
, which indicates that each weight is greater than 0 and that the total sum of the weights adds to 1.
GroupLims'
, which defines the minimum and maximum allocation on each group.
The only data requirement for the constraint-specifier string 'Default'
is NumAssets
(the total number of assets). The constraint-specifier string 'GroupLims'
requires three different arguments: a Groups
matrix indicating the assets that belong to each group, the GroupMin
vector indicating the minimum bounds for each group, and the GroupMax
vector indicating the maximum bounds for each group. Based on Table 2-6, Group Membership, build the Group
matrix, with each row representing a group, and each column representing an asset.
Table 2-5, Maximum and Minimum Group Exposure, has the information to build GroupMin
and GroupMax
.
Given that the number of assets is three, build the constraint matrix by calling portcons
.
In most cases, portcons('Default')
returns the minimal set of constraints required for calling portopt
. If ConSet
is not specified in the call to portopt
, the function calls portcons
passing 'Default'
as its only specifier.
Now use portopt
to obtain the vectors and arrays representing the risk, return, and weights for the portfolios computed along the efficient frontier.
[PortRisk, PortReturn, PortWts] = portopt(ExpReturn,... ExpCovariance, [], [], ConSet) PortRisk = 0.0586 Port Return = 0.1375 PortWts = 0.5 0.25 0.25
In this case the constraints allow only one optimum portfolio.
![]() | Linear Constraint Equations | Solving Sample Problems | ![]() |