This example computes the efficient frontier of portfolios consisting of three different assets, INTC, XON, and RD, given a list of constraints. The expected returns for INTC, XON, and RD are respectively as follows:
ExpReturn = [0.1 0.2 0.15];
The covariance matrix is
ExpCovariance = [ 0.005 -0.010 0.004; -0.010 0.040 -0.002; 0.004 -0.002 0.023];
Allow short selling up to 10% of the portfolio value in any asset, but limit the investment in any one asset to 110% of the portfolio value.
Consider two different sectors, technology and energy, with the following table indicating the sector each asset belongs to.
Constrain the investment in the Energy sector to 80% of the portfolio value, and the investment in the Technology sector to 70%.
To solve this problem, use
passing in a list of asset constraints. Consider eight different portfolios
along the efficient frontier:
NumPorts = 8;
To introduce the asset bounds constraints specified in Constraint
1, create the matrix
AssetBounds, where each column
represents an asset. The upper row represents the lower bounds, and
the lower row represents the upper bounds.
AssetBounds = [-0.10, -0.10, -0.10; 1.10, 1.10, 1.10];
Constraint 2 needs to be entered in two parts, the first part
defining the groups, and the second part defining the constraints
for each group. Given the information above, you can build a matrix
of 1s and 0s indicating whether a specific asset belongs to a group.
Each column represents an asset, and each row represents a group.
This example has two groups: the technology group, and the energy
group. Create the matrix
Groups as follows.
Groups = [0 1 1; 1 0 0];
GroupBounds matrix allows you to specify
an upper and lower bound for each group. Each row in this matrix represents
a group. The first column represents the minimum allocation, and the
second column represents the maximum allocation to each group. Since
the investment in the Energy sector is capped at 80% of the portfolio
value, and the investment in the Technology sector is capped at 70%,
GroupBounds matrix using this information.
GroupBounds = [0 0.80; 0 0.70];
frontcon to obtain
the vectors and arrays representing the risk, return, and weights
for each of the eight portfolios computed along the efficient frontier.
[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn,... ExpCovariance, NumPorts, , AssetBounds, Groups, GroupBounds)
Warning: In a future release, frontcon will be removed. Use the Portfolio object instead. See the release notes for details, including examples to make the conversion. > In frontcon at 89 PortRisk = 0.0416 0.0499 0.0624 0.0767 0.0920 0.1100 0.1378 0.1716 PortReturn = 0.1279 0.1361 0.1442 0.1524 0.1605 0.1687 0.1768 0.1850 PortWts = 0.7000 0.2582 0.0418 0.6031 0.3244 0.0725 0.4864 0.3708 0.1428 0.3696 0.4172 0.2132 0.2529 0.4636 0.2835 0.2000 0.5738 0.2262 0.2000 0.7369 0.0631 0.2000 0.9000 -0.1000
The output data is represented row-wise, where each portfolio's risk, rate of return, and associated weight is identified as corresponding rows in the vectors and matrix.
you to enter a fixed set of constraints related to minimum and maximum
values for groups and individual assets, you often need to specify
a larger and more general set of constraints when finding the optimal
risky portfolio. The function
this need, by accepting an arbitrary set of constraints as an input
The auxiliary function
be used to create the matrix of constraints, with each row representing
an inequality. These inequalities are of the type
<= b, where
A is a matrix,
a vector, and
Wts is a row vector of asset allocations.
The number of columns of the matrix
A, and the
length of the vector
Wts correspond to the number
of assets. The number of rows of the matrix
and the length of vector
b correspond to the number
of constraints. This method allows you to specify any number of linear
inequalities to the function
portcons is an entry
point to a set of functions that generate matrices for specific types
portcons allows you to specify
all the constraints data at once, while the specific portfolio constraint
functions allow you to build the constraints incrementally. These
constraint functions are
Consider an example to help understand how to specify constraints
portopt while bypassing
the use of
portcons. This example
requires specifying the minimum and maximum investment in various
Maximum and Minimum Group Exposure
Note that the minimum and maximum exposure in Asia is the same. This means that you require a fixed exposure for this group.
Also assume that the portfolio consists of three different funds. The correspondence between funds and groups is shown in the table below.
Using the information in these two tables, build a mathematical
representation of the constraints represented. Assume that the vector
of weights representing the exposure of each asset in a portfolio
Wts = [W1 W2
W1 + W2
W1 + W2
W2 + W3
Since you need to represent the information in the form
<= b, multiply equations 1, 3 and 5 by –1. Also
turn equation 7 into a set of two inequalities: W2
+ W3 ≥ 0.50 and W2
+ W3 ≤ 0.50. (The intersection of these
two inequalities is the equality itself.) Thus
-W1 - W2
W1 + W2
-W2 - W3
W2 + W3
Bringing these equations into matrix notation gives
A = [-1 -1 0; 1 1 0; 0 0 -1; 0 0 1; -1 0 0; 1 0 0; 0 -1 -1; 0 1 1] b = [-0.30; 0.75; -0.10; 0.55; -0.20; 0.50; -0.50; 0.50]
ConSet = [A, b]
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
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
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
total number of assets). The constraint-specifier string
three different arguments: a
Groups matrix indicating
the assets that belong to each group, the
indicating the minimum bounds for each group, and the
indicating the maximum bounds for each group. Based on the table Group Membership, build the
with each row representing a group, and each column representing an
Group = [1 1 0; 0 0 1; 1 0 0; 0 1 1]
The table Maximum and Minimum Group Exposure has the information to
GroupMin = [0.30 0.10 0.20 0.50]; GroupMax = [0.75 0.55 0.50 0.50];
Given that the number of assets is three, build the constraint
matrix by calling
ConSet = portcons('Default', 3, 'GroupLims', Group, GroupMin,... GroupMax);
In most cases,
the minimal set of constraints required for calling
not specified in the call to
portopt, the function
its only specifier.
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)
Warning: In a future release, portopt will no longer accept ConSet or varargin arguments. 'It will only solve the portfolio problem for long-only fully-invested portfolios. To solve more general problems, use the Portfolio object. See the release notes for details, including examples to make the conversion. > In portopt at 83 In frontcon at 231 PortRisk = 0.0586 Port Return = 0.1375 PortWts = 0.5 0.25 0.25
In this case, the constraints allow only one optimum portfolio.