Professional Documents
Culture Documents
On each example worksheet, read the comments at the bottom of the sheet, then
click Tools Solver... to examine the decision variables, constraints, and objective.
To find the optimal solution, click the Solve button.
The models in this workbook deal with decisions to invest in stocks and bonds. To help you
understand the models in this workbook, we briefly explain the ideas behind the stock and bond
models in the Theory worksheet.
The Markowitz model uses the Solver to determine the percent of our available funds to invest
in each of five stocks, so as to incur the least risk for a target rate of return. The resulting
portfolio of stocks is called an efficient portfolio. In this model, we assume that the variances
and covariances of stocks are known. In the Full Markowitz model, we calculate the variances
and covariances of stocks from a history of stock prices.
The Efficient Frontier worksheet contains a Markowitz model and an embedded chart. A
short VBA program, also included in the workbook, uses the Solver to optimize the
Markowitz model for several different target rates of return. The VBA code is run and the
resulting portfolio returns and variances are plotted on the chart when you press the button on
the worksheet.
The Sharpe model computes an efficient portfolio using alphas and betas which relate the
return on each stock to the return on the market and the risk-free rate. The alphas, betas and
residual variances are computed via linear regression from a history of stock prices.
The four Bond worksheets illustrate how a portfolio of bonds may be 'immunized' against
changes in interest rates. The model Bond1 assumes that bond durations are known. In model
Bond2, the durations are calculated using Excels DURATION function.
Models Bond3 and Bond4 illustrate 'exact matching' in fixed-income portfolios. Here we
assume that the investor has a series of liabilities (for example, pension payments) to be met in
future periods, and the principal and interest on the bonds must cover the liabilities in each
period.
unds to invest
the variances
he variances
s the button on
nown. In model
nts) to be met in
ties in each
against fluctuation of interest rates is to have a portfolio whose duration is equal to ones own
investment time horizon. A portfolio of bonds has a duration that is the weighted average of
the duration of the individual bonds.
In model Bond1 we assume we know the duration of the bonds available and want to maximize
the yield of the portfolio while keeping the duration equal to a given investment time horizon.
This technique is known as bond portfolio 'immunization.' Bond2 is another immunization
model, but this time the duration for each bond is calculated from the face value, maturity,
annual coupon and yield to maturity of each bond.
In model Bond3 we look at another common way to protect against interest rate fluctuations.
When we acquire a portfolio of bonds, we can exactly calculate the cash flow that arrives from
this portfolio. This consists of the coupons plus the face values of the bonds that mature.
This also works the other way around. If we know we need to have certain amounts of cash
available at certain periods, we can put together a portfolio that does exactly this. The Solver
chooses that portfolio that covers the required amounts in each year and costs the least.
Bond4 is another example of this technique called 'Exact Matching.' This time we allow
excess funds in a certain period to be reinvested to meet requirements in a future period.
o terms. The
s. We can also
ogether will
ain expected
vidual stock
the relative
is the right
variance of
nd the other
he residual
bution (100
t variance).
mprovement.
quality, its
tes go up, the
e interest can
e coupon could
ut at the end of
nd is repaid.
annual coupon
of protecting
al to ones own
d average of
nt to maximize
time horizon.
e, maturity,
fluctuations.
at arrives from
nts of cash
is. The Solver
252769092.xls
Stock 2
20.00%
7.00%
0
Portfolio %
Expected Return
Linear QP Terms
20.00%
8.00%
0
Stock 3
20.00%
9.50%
0
Stock 4
20.00%
6.50%
0
Stock 5
20.00%
14.00%
0
Total
100.00%
Variance/Covariance Matrix
Stock 1
Stock 2
2.50%
0.10%
1.00%
-0.50%
1.60%
Stock 1
Stock 2
Stock 3
Stock 4
Stock 5
0.10%
1.10%
-0.10%
1.20%
-0.85%
Stock 3
1.00%
-0.10%
1.20%
0.65%
0.75%
Stock 4
-0.50%
1.20%
0.65%
0.40%
1.00%
Stock 5
1.60%
-0.85%
0.75%
1.00%
2.00%
Variance
Std. Dev.
Return
Problem
An investor wants to put together a portfolio consisting of up to 5 stocks. Using the Markowitz method, what is the
best combination of stocks to minimize risk for a given return? The variances are known for each stock, as are the
covariances between all stocks. The returns for all stocks are also known.
Solution
1) The variables are the percentage allocations of our funds to invest in each stock. In this worksheet, the variables
are given the name Allocations. The sum of the allocations (which must be 100%) is computed in the cell named
Total_Portfolio.
2) The constraints are very simple. First there are the logical constraints:
Allocations >= 0 via the Assume Non-Negative option
Total_Portfolio = 1
Then there is a constraint that the portfolio return should be at least a certain target value (9% in this example). This
return is calculated in the cell named Portfolio_return:
Portfolio_Return >= 0.09
3) The objective is to minimize portfolio variance, which is calculated according to the Markowitz method in the cell
named Portfolio_Variance.
Remarks
In this worksheet, we use the QUADPRODUCT function to compute the portfolio variance. If you see #NAME? on
this worksheet, you need to open the add-in (DOTPRD32.XLL or DOTPROD.XLL) that provides QUADPRODUCT.
In the Full Markowitz worksheet, we calculate the portfolio variance 'manually' without using QUADPRODUCT.
The Markowitz method can only be used if all the variances of individual stocks, and the covariances between each
pair of stocks are known. In this model we assumed that all the terms are given. In the Full Markowitz worksheet we
actually calculate the variances and covariances from a history of stock prices.
Page 7
252769092.xls
#NAME?
#NAME?
9.00%
ee #NAME? on
witz worksheet we
Page 8
252769092.xls
20.00%
8.70%
Stock 2
20.00%
7.10%
Stock 3
20.00%
9.40%
Stock 4
20.00%
10.70%
Stock 5
20.00%
6.90%
Total
100.00%
Variance/Covariance Matrix
Stock 1
Stock 1
Stock 2
Stock 3
Stock 4
Stock 5
Variance Terms
Stock 2
Stock 3
Stock 4
Stock 5
0.03%
0.12%
0.03%
0.06%
0.01%
0.12%
1.23%
0.20%
0.16%
-0.05%
0.03%
0.20%
0.04%
0.04%
-0.01%
0.06%
0.16%
0.04%
0.51%
0.02%
0.01%
-0.05%
-0.01%
0.02%
0.05%
0.01%
0.07%
0.01%
0.03%
0.00%
Variance
Std. Dev.
Return Terms
1.74%
1.42%
1.88%
2.14%
1.38%
Return
10.00%
12.00%
8.00%
7.00%
9.00%
7.00%
8.00%
6.00%
9.00%
11.00%
Stock 2
15.00%
17.00%
4.00%
-8.00%
15.00%
22.00%
3.00%
-14.00%
2.00%
15.00%
Stock 3
12.00%
13.00%
9.00%
7.00%
9.00%
11.00%
9.00%
6.00%
8.00%
10.00%
Stock 4
18.00%
16.00%
3.00%
4.00%
8.00%
10.00%
-3.00%
15.00%
20.00%
16.00%
Stock 5
5.00%
8.00%
10.00%
9.00%
5.00%
4.00%
4.00%
6.00%
8.00%
10.00%
Problem
An investor wants to put together a portfolio consisting of up to 5 stocks. Using the Markowitz method, what is the
best combination of stocks to minimize risk for a given return? In this model, we calculate stock returns, the variance
of each stock, and the covariances between stocks, using the Excel functions AVERAGE, VARP and COVAR.
Solution
1) The variables are the percentage allocations of our funds to invest in each stock. In this worksheet, the variables
are cells B6 to F6 (they are not given a name). The sum of the percentage allocations (which must be 100%) is
computed in cell H6.
2) The constraints are very simple. First there are the logical constraints:
B6:F6 >= 0 via the Assume Non-Negative option
Page 9
252769092.xls
H6 = 1
Then there is a constraint that the portfolio return should be at least a certain target value (9% in this example). This
return is calculated in cell I19, as the sum of the weighted stock returns:
I19 >= 0.09
3) The objective is to minimize portfolio variance, which is calculated from the weighted individual stock variances
and covariances according to the Markowitz method in cell I17.
Remarks
The stock variances and covariances are calculated in cells B11:F15 from the historical price data in cells B23:F32.
Using historical price data to compute estimates of stock returns, variances and covariances is only a first step in
investment planning. Stock returns, as well as variances and covariances, vary over time. Investors often rely on
security analysts to provide better estimates of these quantities for the future.
Page 10
252769092.xls
0.12%
3.49%
8.56%
t be 100%) is
Page 11
252769092.xls
stock variances
n cells B23:F32.
y a first step in
Page 12
252769092.xls
0.00%
7.00%
Portfolio %
Expected Return
Stock 2
3.57%
8.00%
Stock 3
0.00%
9.50%
Stock 4
0.00%
6.50%
Stock 5
96.43%
15.00%
Total
100.00%
Variance/Covariance Matrix
Stock 1
Stock 1
Stock 2
Stock 3
Stock 4
Stock 5
2.50%
0.10%
1.00%
-0.50%
1.60%
Stock 2
0.10%
1.10%
-0.10%
1.20%
-0.85%
Stock 3
1.00%
-0.10%
1.20%
0.65%
0.75%
Stock 4
-0.50%
1.20%
0.65%
0.40%
1.00%
Stock 5
1.60%
-0.85%
0.75%
1.00%
2.00%
Variance
Variance Terms
0.00%
-0.03%
0.00%
0.00%
1.83%
Std. Dev.
Des. Ret
Return Terms
0.00%
0.29%
0.00%
0.00%
14.46%
Return
This worksheet includes a Markowitz portfolio model that can be optimized by the Solver to find the minimum variance
portfolio for a given target rate of return. We then use VBA (Visual Basic Application Edition) code to set the target
rate of return to different values (from 10% to almost 15%) and run the Solver to optimize the model for each target return.
The VBA code stores the target returns and resulting portfolio variances in cells J21 through K40, which are linked to
the X-Y plot shown to the right. When you press the button labeled 'Create Frontier', the VBA code is run and the
resulting efficient frontier is drawn on the embedded chart.
To see the VBA code controlling the Solver, select Tools Macro... Visual Basic Editor, or press Alt+F11. In the VBA
window, in the left-hand Project list window double-click on Modules, then double-click on Module1. To successully
run the code and create the chart, you may need to choose Tools References... in the VBA Editor and click to set a
check mark next to 'Solver'.
Page 13
252769092.xls
Efficient Frontier
12.06
10.06
Re turn
8.06
6.06
4.06
2.06
0.0180255
13.43%
14.75%
14.75%
0.06
0
6
Variance
he minimum variance
e1. To successully
Page 14
10
12
252769092.xls
12
Page 15
252769092.xls
Stock 2
Stock 3
Stock 4
Stock 5
20.00%
20.00%
20.00%
20.00%
20.00%
0.577381 1.672619 0.64881 0.934524 0.767857
0.047738 -0.04274 0.049881 0.043452 0.016786
0.000261 0.014236 0.000353 0.006059 0.000389
0.00001 0.00057 0.00001 0.00024 0.00002
Total
100.00%
Portfolio Variance
0.12%
Portfolio Return
8.56%
10.00%
12.00%
8.00%
7.00%
9.00%
7.00%
8.00%
6.00%
9.00%
11.00%
Stock 2
15.00%
17.00%
4.00%
-8.00%
15.00%
22.00%
3.00%
-14.00%
2.00%
15.00%
Stock 3
12.00%
13.00%
9.00%
7.00%
9.00%
11.00%
9.00%
6.00%
8.00%
10.00%
Stock 4
18.00%
16.00%
3.00%
4.00%
8.00%
10.00%
-3.00%
15.00%
20.00%
16.00%
Stock 5
5.00%
8.00%
10.00%
9.00%
5.00%
4.00%
4.00%
6.00%
8.00%
10.00%
Market
8.00%
10.00%
9.00%
7.00%
4.00%
6.00%
5.00%
5.00%
6.00%
8.00%
Problem
An investor wants to put together a portfolio consisting of up to 5 stocks. Using the Sharpe Single-Index method,
what is the best combination of stocks to maximize return for a given level of risk (variance)?
Solution
1) The variables are the percentage or fractional allocations of our funds to invest in each stock. In this worksheet,
the variables are given the name Portfolio_fractions. The sum of the allocations (which must be 100%) is computed
in the cell named Portfolio_Total.
2) The constraints are very simple. First there are the logical constraints:
Portfolio_Fractions >= 0 via the Assume Non-Negative option
Portfolio_Total = 1
Then there is a constraint that the portfolio variance should be no more than 0.0003 (in this example). The portfolio
variance is calculated in the cell named Variance:
Variance <= 0.0003
3) The objective is to maximize portfolio return which is calculated according to the Sharpe method in the cell
named Return.
Page 16
252769092.xls
Remarks
This model uses historical data on the stocks and market to calculate the returns and variance of the stocks and
the portfolio. It also uses Excel's regression tools to estimate the alphas and betas, as well as the residual error,
necessary to use the Sharpe Single Index method.
A different approach to this problem would be to minimize risk for a certain return. It is easy to adjust the Solver to
do this. Simply change the set cell to be the variance and adjust the constraint to hold the return at a given level.
Page 17
252769092.xls
20.00%
2.8
8.00%
Bond 2
20.00%
3.1
6.00%
Bond 3
Bond 4
20.00%
3.7
10.00%
Bond 5
20.00%
3.5
9.00%
Bond 6
10.00%
3.8
8.00%
10.00%
4
5.00%
3.8
3.4
7.90%
Portfolio Duration
Portfolio Yield
Total
100.00%
Problem
An investor wants to put together a portfolio consisting of up to 6 different bonds. To minimize risk of
loss of principal value due to interest rate fluctuations and to assure enough cash-flow at a certain point
in the future, he wants to make sure that the average duration of the bonds equals his investment time
horizon. How should the investor choose his portfolio to optimize the combined yield of the bonds,
while making sure that the duration of the portfolio equals the investment time horizon? The duration
and the yield to maturity are known for each bond.
Solution
1) The variables are the percentages or fractions of our available funds to invest in each bond. In
worksheet BOND1 these are given the name Portfolio_fractions.
2) The constraints are very simple. First we have the logical constraints:
Portfolio_fractions >= 0 via the Assume Non-Negative option
Portfolio_total = 1
Then there is the constraint to make sure that the portfolio duration equals the investment time horizon:
Portfolio_duration = Time_horizon
3) The objective is to maximize the portfolio yield. This is given the name Portfolio_yield
Remarks
In this model we assume that the duration of the bond is known. In worksheet BOND2 we will see how
to use EXCEL's build-in functions to calculate the duration of each bond.
Page 18
252769092.xls
20.00%
8.00%
$150
$1,000
Bond 2
Bond 3
20.00%
6.00%
$100
$1,000
Bond 4
20.00%
9.00%
$120
$1,000
Bond 5
20.00%
10.00%
$175
$1,000
20.00%
7.00%
$0
$1,000
Bond 6
20.00%
9.00%
$125
$1,000
Total
120.00%
3.5
#NAME?
9.80%
Problem
An investor wants to put together a portfolio consisting of up to 6 different bonds. To minimize risk of
loss of principal value due to interest rate fluctuations and to assure enough cash-flow at a certain point
in the future, he wants to make sure that the average duration of the bonds equals his investment time
horizon. How should the investor choose his portfolio to optimize the combined yield of the bonds,
while making sure that the duration of the portfolio equals the investment time horizon? All bonds
mature in 4 years and have one annual interest payment. The annual payments, the yield and the
face values of the bonds are all known
Solution
1) The variables are the percentages or fractions of our available funds to invest in each bond. In
worksheet BOND1 these are given the name Portfolio_fractions.
2) The constraints are very simple. First we have the logical constraints:
Portfolio_fractions >= 0 via the Assume Non-Negative option
Portfolio_total = 1
Then there is the constraint to make sure that the portfolio duration equals the investment time horizon:
Portfolio_duration = Time_horizon
3) The objective is to maximize the portfolio yield. This is given the name Portfolio_yield
Remarks
The solution is the same as in worksheet BOND1. The difference is that instead of the duration of
each bond being given, it is now calculated from the yield, annual coupon and face value.
The Excel function DURATION is only available if you have installed the Analysis ToolPak add-in. If
you see #NAME? on the worksheet, choose Tools Add-Ins..., click to put a check mark next to
Analysis ToolPak, then click OK. If Analysis ToolPak is missing from the list of available add-ins, you
may need to install it from the Excel or Office CD.
Page 19
252769092.xls
7%
Interest Rate
Characteristics of bonds
Face Value
Coupon Payment
Years to Maturity
Price
Number Purchased
Cash Flow
Year 1
Year 2
Year 3
Year 4
Year 5
Bond 1
Bond 2
Bond 3
Bond 4
Bond 5
$1,000
$100
3
#NAME?
$1,000
$125
5
#NAME?
$1,000
$150
6
#NAME?
$1,000
$200
4
#NAME?
$1,000
$75
6
#NAME?
Bond 1
Bond 2
Bond 3
Bond 4
Bond 5
10
Bond 1
$1,000
$1,000
$1,000
10
Bond 2
$1,250
$1,250
$1,250
$1,250
$1,250
Year 6
10
Bond 3
$1,500
$1,500
$1,500
$1,500
$1,500
$1,500
10
Bond 4
10
Bond 5
$2,000
$2,000
$2,000
$2,000
$750
$750
$750
$750
$750
$750
Cost
#NAME?
Total
$6,500
$6,500
$6,500
$5,500
$3,500
$2,250
Problem
In models BOND1 and BOND2 we saw a way for an investor to protect against interest rate fluctuations. Here, we'll look
at another method. An investor wants to put together a portfolio consisting of up to 6 different bonds. He has certain cashflow requirements in the future that the coupons of the bonds should cover. (For example, a pension fund must meet
requirements for future pension payments.) These payments are independent of interest rate changes. How should the
investor choose his portfolio to minimize the cost of the bonds, while making sure that the payments cover his future cashflow requirements?
Solution
1) The variables are the number of each bond to include in the portfolio. In worksheet BOND3 these are given the name
Purchased_bonds.
2) The constraints are very simple. First we have the logical constraints:
Purchased_bonds >= 0 via the Assume Non-Negative option
Purchased_bonds = integer (We can not buy fractions of a bond)
Then there is the constraint to make sure that the cash-flow requirements are met:
Cash_flow >= Liabilities
3) The objective is to minimize the portfolio cost. This is given the name Total_cost.
Remarks
In this model we assume that money coming in from maturing bonds can not be used to cover the cash-flow requirements.
Also, we do not account for excess money in one period that may be transferred to the next period. In model BOND4 we
will account for this.
Page 20
252769092.xls
Liability
$32,000
$25,000
$22,000
$28,000
$25,000
$20,000
h-flow requirements.
model BOND4 we
Page 21
252769092.xls
7%
Interest Rate
Characteristics of bonds
Bond 1
Face Value
Coupon Payment
Years to Maturity
Price
Bond 2
$1,000
$100
3
#NAME?
Bond 1
Cash Flow
Year 1
Year 2
Year 3
Year 4
Year 5
Bond 2
50
Number Purchased
Bond 3
$1,000
$125
5
#NAME?
Bond 1
$5,000
$5,000
$5,000
Bond 4
$1,000
$150
6
#NAME?
Bond 3
50
Bond 2
Bond 4
50
Bond 3
$6,250
$6,250
$6,250
$6,250
$6,250
Year 6
Bond 5
$1,000
$175
4
#NAME?
$1,000
$75
6
#NAME?
Bond 5
50
Bond 4
$7,500
$7,500
$7,500
$7,500
$7,500
$7,500
$8,750
$8,750
$8,750
$8,750
50
Bond 5
$3,750
$3,750
$3,750
$3,750
$3,750
$3,750
Problem
An investor wants to put together a portfolio consisting of up to 6 different bonds. He has certain cash-flow requirements in the future
that the coupons of the bonds should cover. (For example, a pension fund must meet requirements for future pension payments.)
These payments are independent of interest rate changes. Excess payments in a period can be reinvested, to be available in the
next period, at a certain interest rate. How should the investor choose his portfolio to minimize the cost of the bonds, while making
sure that the payments cover his future cash-flow requirements?
Solution
1) The variables are the number of each bond to include in the portfolio. In worksheet BOND3 these are given the name
Purchased_bonds.
2) The constraints are very simple. First we have the logical constraints:
Purchased_bonds >= 0 via the Assume Non-Negative option
Purchased_bonds = integer (We can not buy fractions of a bond)
Then there is the constraint to make sure that the cash-flow requirements are met:
Cash_flow >= Liabilities
3) The objective is to minimize the portfolio cost. This is given the name Total_cost.
Remarks
The solution is similar to the one in BOND3. The difference is that the cash-flow takes into account the reinvestment of excess
funds in one period for the next period. Remember that the original idea behind exact matching was to minimize the influence
of interest rate changes. In this model, however, we are again more dependent on the interest rate, since a shift in the future
rate would affect the solution to the model. Thus, the market value of the portfolio may fluctuate to a greater extent than if we
Page 22
252769092.xls
Page 23
252769092.xls
Cost
#NAME?
Total w/Int
$31,250
$30,448
$37,079
$42,384
$32,891
$19,694
Liability
$32,000
$25,000
$22,000
$28,000
$25,000
$20,000
Page 24
252769092.xls
Page 25