Financial Toolbox | ![]() ![]() |
Portfolio Construction Examples
The efficient frontier computation functions require information about each asset in the portfolio. This data is entered into the function via two matrices: an expected return vector and a covariance matrix. The expected return vector contains the average expected return for each asset in the portfolio. The covariance matrix is a square matrix representing the interrelationships between pairs of assets. This information can be directly specified or can be estimated from an asset return time series with the function ewstats
.
Efficient Frontier Example
This example computes the efficient frontier of portfolios consisting of three different assets using the function frontcon
. To visualize the efficient frontier curve clearly, consider 10 different evenly spaced portfolios.
Assume that the expected return of the first asset is 10%, the second is 20%, and the third is 15%. The covariance is defined in the matrix ExpCovariance
.
ExpReturn = [0.1 0.2 0.15]; ExpCovariance = [ 0.005 -0.010 0.004; -0.010 0.040 -0.002; 0.004 -0.002 0.023]; NumPorts = 10;
Since there are no constraints, you can call frontcon
directly with the data you already have. If you call frontcon
without specifying any output arguments, you get a graph representing the efficient frontier curve.
Calling frontcon
while specifying the output arguments returns the corresponding vectors and arrays representing the risk, return, and weights for each of the 10 points computed along the efficient frontier.
[PortRisk, PortReturn, PortWts] = frontcon(ExpReturn,... ExpCovariance, NumPorts) PortRisk = 0.0392 0.0445 0.0559 0.0701 0.0858 0.1023 0.1192 0.1383 0.1661 0.2000 PortReturn = 0.1231 0.1316 0.1402 0.1487 0.1573 0.1658 0.1744 0.1829 0.1915 0.2000 PortWts = 0.7692 0.2308 0.0000 0.6667 0.2991 0.0342 0.5443 0.3478 0.1079 0.4220 0.3964 0.1816 0.2997 0.4450 0.2553 0.1774 0.4936 0.3290 0.0550 0.5422 0.4027 0 0.6581 0.3419 0 0.8291 0.1709 0 1.0000 0.0000
The output data is represented row-wise. Each portfolio's risk, rate of return, and associated weights are identified as corresponding rows in the vectors and matrix.
For example, you can see from these results that the second portfolio has a risk of 0.0445, an expected return of 13.16%, and allocations of about 67% in the first asset, 30% in the second, and 3% in the third.
Portfolio Selection and Risk Aversion
One of the factors to consider when selecting the optimal portfolio for a particular investor is degree of risk aversion. This level of aversion to risk can be characterized by defining the investor's indifference curve. This curve consists of the family of risk/return pairs defining the trade-off between the expected return and the risk. It establishes the increment in return that a particular investor will require in order to make an increment in risk worthwhile. Typical risk aversion coefficients range between 2.0 and 4.0, with the higher number representing lesser tolerance to risk. The equation used to represent risk aversion in the Financial Toolbox is
A
is the index of investor's aversion.
sig
is the standard deviation.
Optimal Risky Portfolio Example
This example computes the optimal risky portfolio on the efficient frontier based upon the risk-free rate, the borrowing rate, and the investor's degree of risk aversion. You do this with the function portalloc
.
First generate the efficient frontier data using either portopt
or frontcon
. This example uses portopt
and the same asset data from the previous example.
ExpReturn = [0.1 0.2 0.15]; ExpCovariance = [ 0.005 -0.010 0.004; -0.010 0.040 -0.002; 0.004 -0.002 0.023];
This time consider 20 different points along the efficient frontier.
As with frontcon
, calling portopt
while specifying output arguments returns the corresponding vectors and arrays representing the risk, return, and weights for each of the portfolios along the efficient frontier. Use them as the first three input arguments to the function portalloc
.
Now find the optimal risky portfolio and the optimal allocation of funds between the risky portfolio and the risk-free asset, using these values for the risk-free rate, borrowing rate and investor's degree of risk aversion.
Calling portalloc
without specifying any output arguments gives a graph displaying the critical points.
Calling portalloc
while specifying the output arguments returns the variance (RiskyRisk
), the expected return (RiskyReturn
), and the weights (RiskyWts
) allocated to the optimal risky portfolio. It also returns the fraction (RiskyFraction
) of the complete portfolio allocated to the risky portfolio, and the variance (OverallRisk
) and expected return (OverallReturn
) of the optimal overall portfolio. The overall portfolio combines investments in the risk-free asset and in the risky portfolio. The actual proportion assigned to each of these two investments is determined by the degree of risk aversion characterizing the investor.
[RiskyRisk, RiskyReturn, RiskyWts,RiskyFraction, OverallRisk,... OverallReturn] = portalloc (PortRisk, PortReturn, PortWts,... RisklessRate, BorrowRate, RiskAversion) RiskyRisk = 0.1288 RiskyReturn = 0.1791 RiskyWts = 0.0057 0.5879 0.4064 RiskyFraction = 1.1869 OverallRisk = 0.1529 OverallReturn = 0.1902
The value of RiskyFraction
exceeds 1 (100%), implying that the risk tolerance specified allows borrowing money to invest in the risky portfolio, and that no money will be invested in the risk-free asset. This borrowed capital is added to the original capital available for investment. In this example the customer will tolerate borrowing 18.69% of the original capital amount.
Constraint Specification Example
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.
Constraint 1. 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.
Constraint 2. Consider two different sectors, technology and energy, with the table below indicating the sector each asset belongs to.
Asset |
INTC |
XON |
RD |
Sector |
Technology |
Energy |
Energy |
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 frontcon
, passing in a list of asset constraints. Consider eight different portfolios along the efficient frontier.
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.
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.
The 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%, create the GroupBounds
matrix using this information.
Now use 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) 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.
![]() | Portfolio Optimization Functions | Linear Constraint Equations | ![]() |