You are on page 1of 36

Portfolio optimization models and mean-variance spanning

tests

Wei-Peng Chen*
Department oI Finance, Hsih-Shin University, Taiwan
c8145666ms18.hinet.net

Huimin Chung
Graduate Institute oI Finance, National Chiao Tung University, Taiwan


Keng-Yu Ho
Department oI Finance, National Central University, Taiwan
kengyuhocc.ncu.edu.tw


Tsui-Ling Hsu
Graduate Institute oI Finance, National Chiao Tung University, Taiwan
tracy.shumsa.hinet.net


Prepared for Handbook of Quantitative Finance and Risk Management

*
Wei-Peng Chen is at the Department oI Finance at Shih-Hsin University; Huimin Chung and Tsui-Ling Hsu are at the
Graduate Institute oI Finance at the National Chiao Tung University. Keng-Yu Ho is at Department oI Finance, National Central
University. Address correspondence to Huimin Chung, Graduate Institute oI Finance, National Chiao Tung University, 1001
Ta-Hsueh Road, Hsinchu 30050, Taiwan; Tel: 886-3-5712121 ext.57075; Fax: 886-3-5733260;. E-mail:
chunghuimail.nctu.edu.tw.
2

In this chapter we introduce the theory and the application oI computer program oI modern
portIolio theory. The notion oI diversiIication is age-old 'don't put your eggs in one basket,
obviously predates economic theory. However a Iormal model showing how to make the most oI
the power oI diversiIication was not devised until 1952, a Ieat Ior which Harry Markowitz
eventually won Nobel Prize in economics.
Markowitz portIolio shows that as you add assets to an investment portIolio the total risk oI that
portIolio - as measured by the variance (or standard deviation) oI total return - declines
continuously, but the expected return oI the portIolio is a weighted average oI the expected returns
oI the individual assets. In other words, by investing in portIolios rather than in individual assets,
investors could lower the total risk oI investing without sacriIicing return.
In the second part we introduce the mean-variance spanning test which Iollows directly Irom the
portIolio optimization problem.

IA1RODUC1IOA OF MARKOWI1Z POR1FOLIO-SELEC1IOA MODEL
Harry Markowitz (1952, 1959) developed his portIolio-selection technique, which came to be
called modern portIolio theory (MPT). Prior to Markowitz's work, security-selection models
Iocused primarily on the returns generated by investment opportunities. Standard investment advice
was to identiIy those securities that oIIered the best opportunities Ior gain with the least risk and
then construct a portIolio Irom these. Following this advice, an investor might conclude that
railroad stocks all oIIered good risk-reward characteristics and compile a portIolio entirely Irom
these. The Markowitz theory retained the emphasis on return; but it elevated risk to a coequal level
oI importance, and the concept oI portIolio risk was born. Whereas risk has been considered an
important Iactor and variance an accepted way oI measuring risk, Markowitz was the Iirst to clearly
and rigorously show how the variance oI a portIolio can be reduced through the impact oI
diversiIication, he proposed that investors Iocus on selecting portIolios based on their overall
risk-reward characteristics instead oI merely compiling portIolios Irom securities that each
individually have attractive risk-reward characteristics.
A Markowitz portIolio model is one where no added diversiIication can lower the portIolio's
risk Ior a given return expectation (alternately, no additional expected return can be gained without
increasing the risk oI the portIolio). The Markowitz EIIicient Frontier is the set oI all portIolios oI
3
which expected returns reach the maximum given a certain level oI risk.

The Markowitz model is based on several assumptions concerning the behavior oI investors
and Iinancial markets:
1. A probability distribution oI possible returns over some holding period can be estimated
by investors.
2. Investors have single-period utility Iunctions in which they maximize utility within the
Iramework oI diminishing marginal utility oI wealth.
3. Variability about the possible values oI return is used by investors to measure risk.
4. Investors care only about the means and variance oI the returns oI their portIolios over a
particular period.
5. Expected return and risk as used by investors are measured by the Iirst two moments oI
the probability distribution oI returns-expected value and variance.
6. Return is desirable; risk is to be avoided
1
.
7. Financial markets are Irictionless.

MEASURMEA1 OF RE1URA AAD RISK
Throughout this chapter, investors are assumed to measure the level oI return by computing the
expected value oI the distribution, using the probability distribution oI expected returns Ior a
portIolio. Risk is assumed to be measurable by the variability around the expected value oI the
probability distribution oI returns. The most accepted measures oI this variability are the variance
and standard deviation.
Return

1
Markowitz model assumes that investors are risk averse. This means that given two assets that oIIer the same
expected return, investors will preIer the less risky one. Thus, an investor will take on increased risk only iI
compensated by higher expected returns. Conversely, an investor who wants higher returns must accept more risk. The
exact trade-oII will diIIer by investor based on individual risk aversion characteristics. The implication is that a rational
investor will not invest in a portIolio iI a second portIolio exists with a more Iavorable risk-return proIile - i.e., iI Ior
that level oI risk an alternative portIolio exists which has better expected returns.
Using risk tolerance, we can simple classiIy investors into three types: risk-neutral, risk-averse, and risk-lover.
Risk-neutral investor`s do not require the risk premium Ior risk investments; they judge risky prospects solely by their
expected rates oI return. Risk-averse investors are willing to consider only risk-Iree or speculative prospects with
positive premium; they make investment according the risk-return trade-oII. A risk-lover is willing to engage in Iair
games and gambles; this investor adjusts the expected return upward to take into account the `Iun` oI conIronting the
prospect`s risk.
4
Given any set oI risky assets and a set oI weights that describe how the portIolio investment is
split, the general Iormulas oI expected return Ior n assets is:

1
( )
n
P i i
i
E r wE r
=
=

(X.1)
where:
1
n
i
i
w
=


1.0;
n the number oI securities;
i
w
the proportion oI the Iunds invested in security i;
,
i P
r r
the return on ith security and portIolio p; and
E
the expectation oI the variable in the parentheses.
The return computation is nothing more than Iinding the weighted average return oI the
securities included in the portIolio.

Risk
The variance oI a single security is the expected value oI the sum oI the squared deviations
Irom the mean, and the standard deviation is the square root oI the variance. The variance oI a
portIolio combination oI securities is equal to the weighted average covariance
2
oI the returns on
its individual securities:

2
1 1
Var Cov ,
n n
p p i f i f
i f
r ww r r o
= =
= =

(X.2)
Covariance can also be expressed in terms oI the correlation coeIIicient as Iollows:


Cov ,
i f if i f if
r r p o o o = = (X.3)
where
if
p correlation coeIIicient between the rates oI return on security i,
i
r , and the rates oI return
on security f,
f
r , and
i
o , and
f
o represent standard deviations oI
i
r and
f
r respectively. ThereIore:

1 1
Var
n n
p i f if i f
i f
r ww p o o
= =
=

(X.4)

2
High covariance indicates that an increase in one stock's return is likely to correspond to an increase in the other. A
low covariance means the return rates are relatively independent and a negative covariance means that an increase in
one stock's return is likely to correspond to a decrease in the other.
5
Overall, the estimate oI the mean return Ior each security is its average value in the sample
period; the estimate oI variance is the average value oI the squared deviations around the sample
average; the estimate oI the covariance is the average value oI the cross-product oI deviations.

EFFICIEA1 POR1FOLIO
fficient portfolios may contain any number oI asset combinations. We examine eIIicient
asset allocation by using two risky assets Ior example. AIter we understand the properties oI
portIolios Iormed by mixing two risky assets, it will be easy to see how portIolio oI many risky
assets might best be constructed.

1wo-risky-assets portfolio
Because we now envision Iorming a -portIolio Irom two risky assets, we need to understand
how the uncertainties oI asset returns interact. It turns out that the key determinant oI portIolio risk
id the extent to which the returns on the two assets tend to vary rather in tandem or in opposition.
The degree to which a two-risky-assets portIolio reduces variance oI returns depends on the degree
oI correlation between the returns oI the securities.
Suppose a proportion denoted by
A
w is invested in asset A, and the remainder 1
A
w , denoted
by
B
w , is invested in asset B. The expected rate oI return on the portIolio is a weighted average oI
the expected returns on the component assets, with the same portIolio proportions as weights.
( ) ( ) ( )
P A A B B
E r w E r w E r = + (X.5)
The variance oI the rate oI return on the two-asset portIolio is
2 2 2 2 2 2
( ) 2
P A A B B A A B B A B AB A B
w w w w w w o o o o o p o o = + = + + (X.6)
where
AB
p is the correlation coeIIicient between the returns on asset A and asset B. II the
correlation between the component assets is small or negative, this will reduce portIolio risk.
First, assume that 1.0
AB
p = , which would mean that Asset A and B are perIectly positively
correlated, the right-hand side oI equation X.6 is a perIect square and simpliIies to
2 2 2 2 2
2
2
( )
p A A B B A B A B
A A B B
w w w w
w w
o o o o o
o o
= + +
= +

6
or
p A A B B
w w o o o = +
ThereIore, the portIolio standard deviation is a weighted average oI the component security
standard deviations only in the special case oI perIect positive correlation. In this circumstance,
there are no gains to be had Iorm diversiIication. Whatever the proportions oI asset A and asset B,
both the portIolio mean and the standard deviation are simple weighted averages. Figure X.1 shows
the opportunity set with perIect positive correlation - a straight line through the component assets.
No portIolio can be discarded as ineIIicient in this case, and the choice among portIolios depends
only on risk preIerence. DiversiIication in the case oI perIect positive correlation is not eIIective.

Figure X.1 Investment opportunity sets for asset A and asset B with various correlation coefficients
3

PerIect positive correlation is the only case in which there is no beneIit Irom diversiIication.
With any correlation coeIIicient less than 1.0( 1 p ), there will be a diversiIication eIIect, the
portIolio standard deviation is less than the weighted average oI the standard deviations oI the
component securities. ThereIore, there are beneIits to diversiIication whenever asset returns are less
than perIectly correlated.
Our analysis has ranged Irom very attractive diversiIication beneIits ( 0
AB
p ) to no beneIits at
all 1.0
AB
p = . For
AB
p within this range, the beneIits will be somewhere in between.
Negative correlation between a pair oI assets is also possible. Where negative correlation is

3
The prooIs oI the slope and the shape oI extreme correlation between asset A and asset B are in Appendix A.
0
$tandard Deviation

p
e
c
t
e
d

R
e
t
u
r
n

asset B
asset A
1 p =
0 p =
1 p =
0 1 p
1 p =
7
present, there will be even greater diversiIication beneIits. Again, let us start with an extreme. With
perIect negative correlation, we substitute 1.0
AB
p = in equation X.6 and simpliIy it in the same
way as with positive perIect correlation. Here, too, we can complete the square, this time, however,
with diIIerent results.
2 2
( )
P A A B B
w w o o o =
And, thereIore,
| |
P A A B B
ABS w w o o o = (X.7)
With perIect negative correlation, the beneIits Irom diversiIication stretch to the limit.
Equation X.7 points to the proportions that will reduce the portIolio standard deviation all the way
to zero.
An investor can reduce portIolio risk simply by holding instruments which are not perIectly
correlated. In other words, investors can reduce their exposure to individual asset risk by holding a
diversiIied portIolio oI assets. DiversiIication will allow Ior the same portIolio return with reduced
risk.

1he concept of Markowitz efficient frontier
Every possible asset combination can be plotted in risk-return space, and the collection oI all
such possible portIolios deIines a region in this space. The line along the upper edge oI this region
is known as the eIIicient Irontier. Combinations along this line represent portIolios (explicitly
excluding the risk-Iree alternative) Ior which there is lowest risk Ior a given level oI return.
Conversely, Ior a given amount oI risk, the portIolio lying on the eIIicient Irontier represents the
combination oIIering the best possible return. Mathematically the eIIicient Irontier is the
intersection oI the set oI portIolios with minimum variance and the set oI portIolios with maximum
return.
Figure X.2 shows investors the entire investment opportunity set, which is the set oI all
attainable combinations oI risk and return oIIered by portIolios Iormed by asset A and asset B in
diIIering proportions. The curve passing through A and B shows the risk-return combinations oI all
the portIolios that can be Iormed by combining those two assets. Investors desire portIolios that lie
to the northwest in Figure X.2. These are portIolios with high expected returns (toward the north oI
the Iigure) and low volatility (to the west).
8

Figure X.2 Investment opportunity set for asset A and asset B
The area within curve 'AZ is the Ieasible opportunity set representing all possible portIolio
combinations. PortIolios that lie below the minimum-variance portIolio (point V) on the Iigure can
thereIore be rejected out oI hand as ineIIicient. The portIolios that lie on the Irontier 'A in Figure
X.2would not be likely candidates Ior investors to hold. Because they do not meet the criteria oI
maximizing expected return Ior a given level oI risk or minimizing risk Ior a given level oI return.
This is easily seen by comparing the portIolio represented by points B and B`. Since investors
always preIer more expected return than less Ior a given level oI risk, B` is always better than B.
Using similar reasoning, investors would always preIer B to V because it has both a higher return
and a lower level oI risk. In Iact, the portIolio at point V is identiIied as the minimum-variance
portfolio; since no other portIolio exists that has a lower standard deviation. The curve 'A
represents all possible eIIicient portIolios and is the eIIicient Irontier
4
, which represents the set oI
portIolios that oIIers the highest possible expected rate oI return Ior each level oI portIolio standard
deviation.

4
The eIIicient Irontier will be convex this is because the risk-return characteristics oI a portIolio change in a
non-linear Iashion as its component weightings are changed. (As described above, portIolio risk is a Iunction oI the
correlation oI the component assets, and thus changes in a non-linear Iashion as the weighting oI component assets
changes.) The eIIicient Irontier is a parabola (hyperbola) when expected return is plotted against variance (standard
deviation).
A
Minimum
Variance
PortIolio
(MVP)
0
B
B`
Investment
Opportunity
Set
V
$tandard Deviation

p
e
c
t
e
d

R
e
t
u
r
n



9

Figure X.3 The efficient frontier of risky assets and individual assets
Any portIolio on the down ward sloping potion oI the Irontier curve is dominated by the
portIolio that lies directly above it on the upward sloping portion oI the Irontier curve since that
portIolio has higher expected return and equal standard deviation. The best choice among the
portIolios on the upward sloping portion oI the Irontier curve is not as obvious, because in this
region higher expected return is accompanied by higher risk. The best choice will depend on the
investor`s willingness to trade oII risk against expected return.

Short selling
Various constraints may preclude a particular investor Irom choosing portIolios on the eIIicient
Irontier, however. Short sale restrictions are only one possible constraint. Short sale is a usual
regulated type oI market transaction. It involves selling assets that are borrowed in expectation oI a
Iall in the assets` price. When and iI the price declines, the investor buys an equivalent number oI
assets at the new lower price and returns to the lender the assets that was borrowed.
Now, relaxing the assumption oI no short selling, investors could sell the lowest-return asset B
(here, we assume that ( ) ( ) and
A B A B
E r E r o o > > ). II the number oI short sales is unrestricted,
then by a continuous short selling oI B and reinvesting in A the investor could generate an inIinite
expected return. The eIIicient Irontier oI unconstraint portIolio is shown in Figure X.4. The upper
bound oI the highest-return portIolio would no longer be A but inIinity (shown by the arrow on the
top oI the eIIicient Irontier). Likewise the investor could short sell the highest-return security A and
0
EIIicient Irontier
oI risky assets
$tandard Deviation

p
e
c
t
e
d

R
e
t
u
r
n

Individual assets
Minimum
variance
portIolio
10
reinvest the proceeds into the lowest-yield security B
5
, thereby generating a return less than the
return on the lowest-return assets. Given no restriction on the amount oI short selling, an inIinitely
negative return can be achieved, thereby removing the lower bound oI B on the eIIicient Irontier.
Hence, short selling generally will increase the range oI alternative investments Irom the
minimum-variance portIolio to plus or minus inIinity
6
.

Figure X.4 The efficient frontier of unrestricted/restricted portfolio
Relaxing the assumption oI no short selling in this development oI the eIIicient Irontier
involves a modiIication oI the analysis oI the eIIicient Irontier oI constraint (not allowed short
sales). Next section, we introduce the mathematical analysis oI the eIIicient Irontier with/without
short selling constraints.

Calculating the Minimum variance portfolio
In Markowitz portIolio model, we assume investors choose portIolios based on both expected
return, ( )
p
E r , and the standard deviation oI return as a measure oI its risk,
p
o . So, the portIolio
selection problem can be expressed as maximizing the return with respect to the risk oI the
investment (or, alternatively, minimizing the risk with respect to a given return, hold the return
constant and solve Ior the weighting Iactors that minimize the variance).

5
Rational investor will not short sell a high-return asset and buy a low-return asset. This case is just Ior extreme
assumption.
6
Whether an investor engages in any oI this short-selling activity depends on the investor`s own unique set oI
indiIIerence curves.
0
`

A
P
V

p
e
c
t
e
d

R
e
t
u
r
n

$tandard Deviation
B
without short sales
with short sales
11
Mathematically, the portIolio selection problem can be Iormulated as quadratic program. For
two risky assets A and B, the portIolio consists oI ,
A B
w w , the return oI the portIolio is then, The
weights should be chosen so that (Ior example) the risk is minimized, that is
2 2 2 2 2
Min 2
A
P A A B B A B AB A B
w
w w w w o o o p o o = + +
Ior each chosen return and subject to 1, 0, 0
A B A B
w w w w + = > > . The last two constraints
simply imply that the assets cannot be in short positions.
The minimum variance portIolio weights are shown in Table X.1, the detail prooIs are in
Appendix B.

Table X.1 The mimimum variance portfolio weight of two-assets portfolio without short selling
The correlation oI two assets Weight oI Asset A Weight oI Asset B
p 1
B
A
A B
w
o
o o
=


2
A B
B
A B
w
o o
o o


p -1
B
A
A B
w
o
o o
=
+

A
B
A B
w
o
o o
=
+

p 0
2
2 2
B
A B
A
w
o
o o
=
+

2 2
2 2
2
A B
A B
B
w
o o
o o

=
+

Above, we simply use two-risky-assets portIolio to calculate the minimum variance portIolio
weights. II we generalization to portIolios containing assets, the minimum portIolio weights can
then be obtained by minimizing the Lagrange Iunction Ior portIolio variance.
2
1 1
Min
n n
p i f if i f
i f
ww o p o o
= =
=


Subject to
1 2
... 1

w w w + + + =

1
1 1 1
Cov 1
n n n
i f i f i
i f i
ww rr W 2
= = =
+
= +

' '

(X.8)
in which
1
2 are the Lagrange multipliers, respectively,
if
p is the correlation coeIIicient between
i
r
and
f
r , and other variables are as previously deIined.
By using this approach the minimum variance can be computed Ior any given level oI expected
portIolio return (subject to the other constraint that the weights sum to one). In practice it is best to
12
use a computer because oI the explosive increase in the number oI calculations as the number oI
securities considered grows. The eIIicient set that is generated by the aIorementioned approach
(equation X.8) is sometimes called the minimum-variance set because oI the minimizing nature oI
the Lagrangian solution.

Calculating the weights of optimal risky portfolio
One oI the goals oI portIolio analysis is minimizing the risk or variance oI the portIolio.
Previous section introduce the calculation oI minimum variance portIolio, we minimum the
variance oI portIolio subject to the portIolio weights` summing to one. II we add a condition into
the equation X.8 whish is be subject to the portIolio`s attaining some target expected rate oI return,
we can get the optimal risky portIolio.
2
1 1
Min
n n
p i f if i f
i f
WW o p o o
= =
=


Subject to

*
1
n
i i
i
W E R E
=
=

, where
*
E is the target expected return and
1
1.0
n
i
i
W
=
=


The Iirst constraint simply says that the expected return on the portIolio should equal the target
return determined by the portIolio manager. The second constraint says that the weights oI the
securities invested in the portIolio must sum to one.
The Lagrangian objective Iunction can be written:

*
1 2
1 1 1 1
Cov 1
n n n n
i f i f i i i
i f i i
ww rr E wE r w 2 2
= = = =
+
= + +

| ' '

(X.9)
Taking the partial derivatives oI this equation with respect to each oI the
variables,
1 2
, ,....,

w w w
1 2
, , 2 2 and setting the resulting equations equal to zero yields the
minimization oI risk subject to the Lagrangian constraints. Then, we can solve the weights and
these weights are represented optimal risky portIolio by using oI matrix algebra.
II there no short selling constraint in the portIolio analysis, second constraint,
1
1.0
n
i
i
w
=
=

,
13
should substitute to
1
1.0
n
i
i
w
=
=

, where the absolute value oI the weights


i
w allows Ior a given
i
w to
be negative (sold short) but maintains the requirement that all Iunds are invested or their sum equals
one.
The Lagrangian Iunction is

*
1 2
1 1 1 1
Cov 1
n n n n
i f i f i i i
i f i i
ww rr E w E r w 2 2
= = = =
+
= + +

| ' '

(X.10)
II the restriction oI no short selling is in minimization variance problem, it needs to add a third
constraint:
0, 1, ,
i
w i > =
The addition oI this non-negativity constraint precludes negative values Ior the weights (that is,
no short selling). The problem now is a quadratic programming problem similar to the ones solved
so Iar, except that the optimal portIolio may Iall in an unIeasible region. In this circumstance the
next best optimal portIolio is elected that meets all oI the constraints.

Finding the efficient frontier of risky assets
According to two-Iund separation, the eIIicient Irontier oI risky assets can be Iormed by any
two risky portIolios one the Irontier. All portIolios on the mean-variance eIIicient Irontier can be
Iormed as a weighted average oI any two portIolios or Iunds on the eIIicient Irontier is called
two-Iund separation. So iI we have any two points oI the portIolio combinations, we can draw an
entire eIIicient Irontier oI the risky assets. Previous sections we have introduced the minimum
variance portIolio and optimal risky portIolio given the expected return, then, we can generate the
entire eIIicient Irontier by the separation property.
Deriving the eIIicient Irontier may be quite diIIicult conceptually, but computing and graphing it
with any number oI assets and any set oI constraints is quite straightIorward. Later, we will use
EXCEL and MATLAB to generate the eIIicient Irontier.

Finding the optimal risky portfolio
We already have an eIIicient Irontier, however, how we deicide the best allocation oI portIolio?
One oI the Iactors to consider when selecting the optimal portIolio Ior a particular investor is degree
14
oI risk aversion, investor`s willingness to trade oII risk against expected return. This level oI
aversion to risk can be characterized by deIining the investor`s indiIIerence curve, consisting oI the
Iamily oI risk/return pairs deIining the trade-oII 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. The optimal portIolio along the eIIicient Irontier is not unique with
this model and depends upon the risk/return tradeoII utility Iunction oI each investor. We use the
utility Iunction that is commonly employed by Iinancial theorists and the AIMR (Association oI
Investment Management and Research) assigns a portIolio with a given expected return ( )
p
E r and
standard deviation
p
o the Iollowing utility Iunction:

2
( ) 0.005
p p
U E r Ao = (X.11)
where U is the utility value and A is an index oI the investor`s risk aversion. The Iactor oI 0.005 is
a scaling convention that allows us to express the expected return and standard deviation in
equation X.11 as percentages rather than decimals. We interpret this expression to say that the
utility Irom a portIolio increases as the expected rate oI return increases, and it decreases when the
variance increases. The relative magnitude oI these changes is governed by the coeIIicient oI risk
aversion, A . For risk-neutral investors, A0. Higher levels oI risk aversion are reIlected in larger
values Ior A.
PortIolio selection, then, is determined by plotting investors` utility Iunctions together with the
eIIicient-Irontier set oI available investment opportunities. In Figure X.6, two sets oI indiIIerence
curves labeled
1
U and
2
U are shown together with the eIIicient Irontier. The
1
U curve has a
higher slope, indicating a greater level oI risk aversion. The investor is indiIIerent to any
combination oI
p
r and
p
o along a given curve. The
2
U curve would be appropriate Ior a less
risk-averse investorthat is, one who would be willing to accept relatively higher risk to obtain
higher levels oI return. The optimal portIolio would be the one that provides the highest utilitya
point in the northwest direction (higher return and lower risk). This point will be at the tangent oI a
utility curve and the eIIicient Irontier. Each investor is logically selecting the optimal portIolio
given his or her risk-return preIerence, and neither is more correct than the other.
15

Figure X.6 Indifference Curves and fficient frontier

In order to simpliIy the determination oI optimal risky portIolio, we use the capital allocation
line (CAL), which depicts all Ieasible risk-return combinations available Irom diIIerent asset
allocation choices, to determine the optimal risky portIolio. To start, however, we will demonstrate
the solution oI the portIolio construction problem with only two risky assets (in our example, asset
A and asset B) and a risk-Iree asset. In this case, we can derive an explicit Iormula Ior the weights
oI each asset in the optimal portIolio. This will make it easy to illustrate some oI the general issues
pertaining to portIolio optimization.
The objective is to Iind the weights
A
w and
B
w that result in the highest slope oI the CAL
( i.e., the weights that result in the risky portIolio with the highest reward-to-variability ratio).
ThereIore, the objective is to maximize the slope oI the CAL Ior any possible portIolio, P. Thus out
objective Iunction is the slope that we have called
S
AL : The entire portIolio including risky and
risk-Iree assets.
( )
p f
S
p
E r r
AL
o

= (X.12)
For the portIolio with two risky assets, the expected return and standard deviation oI portIolio
S are
( ) ( ) ( )
P A A B B
E r w E r w E r = + (X.5)
2 2 2 2 1/ 2
( 2 )
P A A B B A B AB A B
w w w w o o o p o o = + + (X.13)
0
B
A
$tandard Deviation

p
e
c
t
e
d

R
e
t
u
r
n

Minimum
variance
portIolio EIIicient
Irontier oI
risky assets
1
U
2
U
16
When we maximize the objection Iunction,
S
AL , we have to satisIy the constraint that the
portIolio weights sum to 1. ThereIore, we solve a mathematical problem Iormally written as
( )

i
p f
S
w
p
E r r
AL
Max
o

=
Subject to 1
i
w =

.In this case oI two risky assets, the solution Ior the weights oI the optimal
risky portfolio S, can be shown to be as Iollows
7
:
2
2 2
| ( ) | | ( ) |
| ( ) | | ( ) | | ( ) ( ) |
1
A f B B f AB A B
A
A f B B f A A f B f AB A B
B A
E r r E r r
w
E r r E r r E r r E r r
w w
o p o o
o o p o o

=
+ +
=

Then, we Iorm an optimal complete portIolio
8
given an optimal risky portIolio and the CAL
generated by a combination oI portIolio S and risk-Iree asset. We have constructed the optimal
portIolio S, we can use the individual investor`s degree oI risk aversion, A, to calculate the optimal
proportion oI complete portIolio to invest in the risky component.
Assuming that a risk-Iree rate is
f
r , and a risky portIolio with expected return ( )
p
E r and
standard deviation
p
o will Iind that, Ior any choice oI , the expected return oI the complete
portIolio is
( ) | ( ) |
f p f
E r r E r r = +
The variance oI the overall portIolio is
2 2 2
p
o o =
The investor attempts to maximum utility, U, by choosing the best allocation to the risky asset,
. To solve the utility maximization problem more generally, we write the problem as Iollows:
2
y
2 2
U ( ) 0.005
| ( ) | 0.005
Max
f p f p
E r A
r E r r A
o
o

= +

Setting the derivative oI this expression to zero, we can solve Ior yield the optimal

7
The solution procedure Ior two risky assets is as Iollows. Substitute Ior expected return Irom equationX.5 and Ior
standard deviation Irom equation X.13. Substitute 1
A
w Ior
B
w . DiIIerentiate the resulting expression Ior Sp with
respect to
A
w , set the derivative equal to zero, and solve Ior
B
w .
8
The complete portIolio means that the entire portIolio including risky and risk-Iree assets.
17
position Ior risk-averse investors in the risky asset,
*
, as Iollows:
*
2
( )
0.01
p f
p
E r r

Ao

= (X.14)
The solution shows that the optimal position in the risky asset is, as one would expect,
inversely proportional to the level oI risk aversion and the level oI risk (measured by the variance)
and directly proportional to the risk premium oIIered by the risky asset.
Once we have reached this point, generalizing to the case oI many risky assets is
straightIorward. BeIore we move on, let us brieIly summarize the steps we Iollowed to arrive at the
complete portIolio.
1. SpeciIy the return characteristics oI all securities (expected returns, variances,
covariances).
2. Establish the risky portIolio:
a. Calculate the optimal risky portIolio S.
b. Calculate the properties oI portIolio S using the weights determined in step and
equations X.5 and X.13.
3. Allocation Iunds between the risky portIolio and the risk-Iree asset:
a. Calculate the Iraction oI the complete portIolio allocated to PortIolio S (the risky
portIolio) and to risk-Iree asset (equation X.14).
b. Calculate the share oI the complete portIolio invested in each asset and in risk-Iree
asset.

Figure X.7 Determination of the optimal portfolio

IndiIIerence Curve
Opportunity Set oI Risky
Assets
Optimal
Complete
PortIolio
CAL
0
Optimal Risky PortIolio
$tandard Deviation

p
e
c
t
e
d

R
e
t
u
r
n


f
r
18
In practice, when we try to construct optimal risky portIolios Irom more than two risky assets
we need to rely on MicrosoIt EXCEL or another computer program. We present can be used to
construct eIIicient portIolios oI many assets in the next section.

AL1ERAA1I'E COMPU1ER PROCAME 1O CALCULA1E EFFICIEA1 FROA1IER
Several soItware packages can be used to generate the eIIicient Irontier. In this section, we will
demonstrate the method using MicrosoIt Excel and MATLAB.

Application: Microsoft Excel
Excel is Iar Irom the best program Ior generating the eIIicient Irontier and is limited in the
number oI assets it can handle, but working through a simple portIolio optimizer in Excel can
illustrate concretely the nature oI the calculations used in more sophisticated black-box` programs.
You will Iind that Excel, the computation o the eIIicient Irontier is Iairly easy.
Assume an American investor who Iorms a six-stock-index portIolio. The portIolio consists oI
six stock indexes: United State (S&P500), United Kingdom (FTSE100), Switzerlan (Swiss Market
Index, SMI) ,Singapore (Straits Times Index, STI), HongKong (Hang Seng Index, HSI) , and Korea
(Korea Composite Stock Price Index, KOSPI), with monthly price data Irom Jan. 1990 to Dec. 2006.
He/she wants to know his/her optimal portIolio allocation.
The Markowitz portIolio selection problem can be divided into three parts. First, we need to
calculate the eIIicient Irontier. Secondly, we need to choose the optimal risky portIolio given one`s
capital allocation line (Iind the point at the tangent oI a CAL and the eIIicient Irontier). Finally,
using the optimal complete portIolio allocate Iunds between the risky portIolio and the risk-Iree
asset.
$tep one: Finding efficient frontier
First, we need to calculate expected return, standard deviation, and covariance matrix. The
expected return and standard deviation can been calculated by applying the Excel STDEV and
AVERAGE Iunctions to the historic monthly percentage returns data
9
. Table X.2A and B shows
average returns, standard deviations, and the correlation matrix
10
Ior the rates oI return on the stock

9
The expected return and standard deviation oI each index need to be annualized.
10
The correlation matrix is calculated in Excel using the data analysis Iunction that is Iound under the Tool Menu. Note
iI Data Analysis does not appear on the Tool Menu you will need to select Add-in and add to the Menu.
19
index. AIter we input Table X.2A into our spreadsheet as shown, we create the covariance matrix in
Table X.2B using the relationship ( , )
i f if i f
ov r r p o o = .
Table X.2 Performance of si stock indees






20
Table X.2 (Concluded)




21
Table X.2 (Concluded)

BeIore computing oI the eIIicient Irontier, we need to prepare the data to establish a
benchmark against which to evaluate our eIIicient portIolios, we can Iorm a border-multiplied
covariance matrix. We use the target mean oI 15 Ior example. To compute the target portIolio`s
mean and variance, these weights are entered in the border column B49-B54 and border row
C48-H48. We calculate the variance oI this portIolio in cell C56 in Table X.2D. The entry in C56
equals the sum oI all elements in the border-multiplied covariance matrix where each element is
Iirst multiplied by the portIolio weights given in both the row and column borders. We also include
two cells to compute the standard deviation and expected return oI the target portIolio (Iormulas in
cells C57, C58)
11
.
To compute points along the eIIicient Irontier we use the Excel Solver in Table X.2D (which
you can Iind in the Tools menu)
12
. Once you bring up Solver, you are asked to enter the cell oI the
target (objective) Iunction. In our application, the target is the variance oI the portIolio, given in cell
C56. Solver will minimize this target. You next must input the cell range iI the decision variables
( in this case, the portIolio weights, contained in cells B49-B54). Finally, you enter all necessary
constraints into the Solver. For an unrestricted eIIicient Irontier that allows short sales, there are two
constraints: Iirst, that the sum oI the weights1.0 (cell B551), and second, that the portIolio

11
Because the expected returns and the portIolio weights are represented by column vectors (denoted
e
and
w
respectively, with row vector transposes
T
e
and
T
w
), and the variance-covariance terms by matrix
J
, then
the expressions can be written as simple matrix Iormulas. So, the calculation oI expected return and variance oI
portIolio can use the Excel array Iunctions.

Matrix notation Excel Iormula:
PortIolio return:
T
w e SUMPRODUCT(w,e)
PortIolio variance:
T
w Jw MMULT(TRANSPOSE( ),MMULT( , )) w J w
12
II Solver does not show up under the Tools menu, you should select Add-Ins and then select Analysis. This should
ass Solver to the list oI options in the Tools menu.
22
expected return equals target return 15 (cell B5815)
13
. Once you have entered the two
constraints you ask the Solver to Iind the optimal portIolio weights.
The Solver beeps when it has Iound a solution and automatically alters the portIolio weight
cells in row 48 and column C to show the makeup oI the eIIicient portIolio. It adjusts the entries in
the border-multiplied covariance matrix to reIlect the multiplication by these new weights, and it
shows the mean and variance oI this optimal portIolio-the minimum variance portIolio with mean
return oI 15. These results are shown in Table X.2D, cells C56-C58. You can Iind that they yield
an expected return oI 15 with a standard deviation oI 17.11 (results in cells C58 and C57). To
generate the entire eIIicient Irontier, keep changing the required mean in the constraint (cell C58),
letting the Solver work Ior you. II you record a suIIicient number oI points, you will be able to
generate a graph oI the quality oI Figure X.8.
II short selling is not allowed, the Solver also allows you to all 'no short sales and other
constrains easily. We need to impose the additional constraints that each weight (the elements in
column B and row 49) must be nonnegative. Once they are entered, you repeat the
variance-minimization exercise until you generate the entire restricted Irontier. The outer Irontier in
Figure X.8 is drawn assuming that the investor may maintain negative portIolio weights, the inside
Irontier obtained allowing short sales. Table X.2 E and F present a number oI points on the two
Irontiers with and without short sales. You can see that the weights in restricted portIolios are never
negative. The minimum variance portIolios in two Irontiers are not the same.
BeIore we move on, let us summarize the steps oI using Solver to calculate the
variance-minimization portIolio.
The steps with Solver are:
1. Invoke Solver by choosing Tools then Options then Solver.
2. SpeciIy in the Solver parameter Dialog Box: the Target cell to be optimized speciIy max
or min
3. Choose Add to speciIy the constrains then OK
4. Solve and get the results in the spreadsheet.



13
II you do not set the second constraint: target mean equal to 20, then you can the minimum variance portIolio. The
minimum variance portIolio has 18.637 expected return and a standard deviation oI 15.643.
23
Figure X.8 fficient frontier of unrestricted and restricted portfolio
Portfolio fficient Frontier
0
5
10
15
20
25
30
0 5 10 15 20 25 30 35
PortIolio Risk ()
P
o
r
t
I
o
l
i
o

R
e
t
u
r
n

(

)
Restricted Unrestricted S&P 500 FTSE100 SMI STI HSI KOSPI

$tep two: Finding optimal risky portfolio
Now that we have the eIIicient Irontier, we proceed to step two. In order to get the optimal
risky portIolio, we should Iind the portIolio on the tangency point oI capital allocation and eIIicient
Irontier. To do so, we can use the Solver to help us. First, you enter the oI the target Iunction,
'maximum the reward-to-variability ratio (
( )
p f
p
E r r
o

,we assume risk-Iree rate is 4.01


14
) the
slope oI the CAL, input the cell range (the portIolio weights, contained in cells B49-B54), and other
necessary constraints( such like the sum oI the weights equal to one and others). Then ask the
Solver to Iind the optimal portIolio weights. The results are shown in Table X.2 E and F. The
optimal risky portIolio with short selling allowance has expected return oI 19.784 with a standard
deviation oI 22.976 (cell B69, C69). The expected return and standard deviation oI the restricted
optimal risky portIolio are 12.897and 16.998 (cell B80, C80).
$tep three: Capital allocation decision
One`s allocation decision will inIluence by his degree oI risk aversion. Now we have optimal
risky portIolio, we can use the concept oI complete portIolio allocation Iunds between risky
portIolio and risk-Iree asset. We use equation X.11 as our utility Iunction and set the risk aversion
equal to 5 and risk-Iree rate is 4.1. First we construct a complete portIolio with risk-Iree asset and

14
We use three month Treasury Bill interest rate as the risk-Iree rate, the average interest rate oI 3month T-Bill is
4.09 Iorm 1990/01 to 2006/12.
24
optimal risky portIolio.
According to equation X.14, the optimal weight in risky portIolio is
2
( )
0.01
p f
p
E r r
Ao

and the
optimal position oI risk-Iree asset is 1-
2
( )
0.01
p f
p
E r r
Ao

. Then we can use equation 5 and 6 calculate the


expected return and standard deviation oI the overall optimal portIolio. The results are shown in
Table X.2 G and H. The optimal unrestricted (restricted) portIolio has 13.44 (9.48) expected
return with 13.73 (10.46) standard deviation. And the investor will invest 60 (62) oI
portIolio value in risky portIolio and 40 (38) in risk-Iree asset.
To sum up the three steps, the all results are shown in Table X.3.
Table X.3 The results of optimization problem
portIolio Unrestricted portIolio Restricted portIolio

Minimum
variance
portIolio
Optimal
risky
portIolio
Optimal
Overall
portIolio
Minimum
variance
portIolio
Optimal
risky
portIolio
Optimal
Overall
portIolio
PortIolio
Return
7.73 19.78 13.44 8.28 12.89 9.48
PortIolio
Risk
12.71 22.98 13.73 12.83 16.99 10.46

Application: MA1LA
By using the Solve, you can repeat the variance-minimization exercise until you generate the
entire eIIicient Irontier, just with on push oI a button. The computation oI the eIIicient Irontier is
Iairly easy in MicrosoIt Excel. However, Excel is limited in the number oI assets it can handle. II
our portIolio consists oI hundreds oI asset, using Excel to deal with the Markowitz optimal problem
will become more complicated. MATLAB can handle this problem. The Financial Toolbox in
MATLAB provides a complete integrated computing environment Ior Iinancial analysis and
engineering. The toolbox has everything you need to perIorm mathematical and statistical analysis
oI Iinancial data and display the results with presentation-quality graphics. You do not need to
switch tools, convert Iiles, or rewrite applications. Just write expressions the way you think oI
problems, MATLAB will do all that Ior you. You can quickly ask, visualize, and answer
complicated questions.
Financial Toolbox includes a set oI portIolio optimization Iunctions designed to Iind the
portIolio that best meets investor requirements. Recall the steps when using Excel in previous
25
section. In the portIolio optimization problem, we need to prepare several the data Ior the
computation preparation. First, we need the expected return, standard deviation, covariance matrix.
Then, we can calculate the optimal risky portIolio weights and know how allocate will be more
eIIicient. BeIore taking real portIolio selection example by using MATLAB, we introduce the
several portIolio optimization Iunctions that will be use in our portIolio selection analysis.

Mean-variance efficient frontier
Calling Iunction frontcon can returns the mean-variance eIIicient Irontier Ior a given group
oI assets with user-speciIied asset constraints, covariance, and returns. The computation is based on
sets oI constraints representing the maximum and minimum weights Ior each asset, and the
maximum and minimum total weight Ior speciIied groups oI assets. The eIIicient Irontier
computation Iunctions require inIormation about each asset in the portIolio. This data is entered into
the Iunction via two matrices: an expected return vector and a covariance matrix. Calling
frontcon while speciIying the output arguments returns the corresponding vectors and arrays
representing the risk, return, and weights Ior each oI the 10 points computed along the eIIicient
Irontier. Since there are no constraints, you can call frontcon directly with the data you already
have. II you call frontcon without speciIying any output arguments, you get a graph representing
the eIIicient Irontier curve.
Function: frontcon
Syntax
!ortRisk, !ortReturn, !ortWts, = frontcon(ExpReturn, ExpCovariance, Num!orts,
!ortReturn, AssetBounds, Groups, GroupBounds)
!ortRisk, !ortReturn and !ortWts are the returns oI frontcon, where !ortRisk is a
vector oI the standard deviation oI each portIolio, !ortReturn is a vector oI the expected return oI
each portIolio, and !ortWts is an matrix oI weights allocated to each asset
15
. The output data is
represented row-wise, where each portIolio`s risk, rate oI return, and associated weight is identiIied
as corresponding rows in the vectors and matrix.
ExpReturn, ExpCovariance, Num!orts are frontcon required inIormation, Num!orts,
!ortReturn, AssetBounds , and GroupBounds all are optional inIormation. ExpReturn
speciIies the expected return oI each asset; ExpCovariance speciIies the covariance oI the asset

15
The total oI all weights in a portIolio is 1.
26
returns. !ortWts is a he matrix oI weights allocated to each asset, an optional item. In Num!orts,
you can deIine the number oI portIolios you want to be generated along the eIIicient Irontier. II
Num!orts is empty (entered as ||), frontcon computes 10 equally spaced points
16
. !ortReturn
is vector oI length equal to the number oI portIolios containing the target return values on the
Irontier. II !ortReturn is not entered or ||, Num!orts equally spaced returns between the
minimum and maximum possible values are used. AssetBounds is a matrix containing the lower
and upper bounds on the weight allocated to each asset in the portIolio
17
. Groups is number oI
groups matrix speciIying asset groups or classes
18
. GroupBounds matrix allows you to speciIy an
upper and lower bound Ior each group. Each row in this matrix represents a group. The Iirst column
represents the minimum allocation, and the second column represents the maximum allocation to
each group.
Notice, the arguments in the parentheses are the Iunction required data; the items in the square
bracket are the returns oI Iunction, the return will be show in the output. II you do not want to
results show up in output window, you can clear the square bracket just keep the item. On the
contrary, iI you want show some results in the output window, just add square bracket when
expression Ieedback oI Iunctions in writing syntax. Moreover, the names oI input arguments can be
user-speciIied, it is not necessary to be named as our example shown. You can name what you want,
as long as the concept oI data matches the Iunction arguments required.

Portfolios on constrained efficient frontier
II you want set some linear constraints when computing eIIicient Irontier, you can call
portopt Iunction. The portopt computes portIolios along the eIIicient Irontier Ior a given group
oI assets, based on a set oI user-speciIied linear constraints. Typically, these constraints are
generated using the constraint speciIication Iunctions which we will describe in next section.
Function: portopt
$ynta
!ortRisk, !ortReturn, !ortWts, = portopt(ExpReturn, ExpCovariance, Num!orts,
!ortReturn, ConSet)

16
When entering a target rate oI return (!ortReturn), enter Num!orts as an empty matrix ||.
17
The DeIault oI lower asset bound is all 0s (no short-selling); deIault upper asset bound is all 1s (any asset may
constitute the entire portIolio).
18
Groups(i,j) 1 (jth asset belongs in the ith group). Groups(i,j) 0 (jth asset not a member oI the ith group).
27
The portopt is an advanced version oI frontcon Iunction. The most diIIerence between this
two is ConSet, others are the same as our described in frontcon Iunction. ConSet, optional
inIormation, is a constraint matrix Ior a portIolio oI asset investments, created using portcons. II
not speciIied, a deIault is created. The syntax expressed above will return the mean-variance
eIIicient Irontier with user-speciIied covariance, returns, and asset constraints (ConSet). II
portopt is invoked without output arguments, it returns a plot oI the eIIicient Irontier.

Portfolio constraints
While frontcon allows you to enter a Iixed set oI constraints related to minimum and
maximum values Ior groups and individual assets, you oIten need to speciIy a larger and more
general set oI constraints when Iinding the optimal risky portIolio. The Iunction portopt addresses
this need, by maccepting an arbitrary set oI constraints as an input matrix. The auxiliary Iunction
portcons can be used to create the matrix oI constraints, with each row representing an inequality.
These inequalities are oI the type A*Wts' b, where A is a matrix, b is a vector, and Wts is a row
vector oI asset allocations. The number oI columns oI the matrix A, and the length oI the vector
Wts correspond to the number oI assets. The number oI rows oI the matrix A, and the length oI
vector b correspond to the number oI constraints. This method allows you to speciIy any number oI
linear inequalities to the Iunction portopt
19
.

Function: portcons
$ynta
ConSet = portcons(varargin
20
)
ConSet portcons('ConstType', Data1, ..., DataN) creates a matrix ConSet, based on the
constraint type ConstType, and the constraint parameters Data1, ..., DataN.
ConSet portcons('ConstType1', Data11, ..., Data1N,'ConstType2', Data21, ...,
Data2N, ...) creates a matrix ConSet, based on the constraint types ConstTypeN, and the

19
In reality, portcons is an entry point to a set oI Iunctions that generate matrices Ior speciIic types oI constraints.
portcons allows you to speciIy all the constraints data at once, while the speciIic portIolio constraint Iunctions allow
you to build the constraints incrementally. These constraint Iunctions are pcpval, pcalims, pcglims, and pcgcomp.
20
varargin is variable length input argument list. The varargin statement is used only inside a Iunction M-Iile to
contain optional input arguments passed to the Iunction. The varargin argument must be declared as the last input
argument to a Iunction, collecting all the inputs Irom that point onwards. In the declaration, varargin must be
lowercase.
28
corresponding constraint parameters DataN1, ..., DataNN.
Table X.4 The detail information of portcons function
Constraint type Description Value
Default
All allocations are ~ 0; no
short selling allowed.
Combined value oI
portIolio allocations
normalized to 1
NumAssets (required). Scalar representing
number oI assets in portIolio.
!ortValue
Fix total value oI portIolio
to PVal.
!Val (required). Scalar representing total value
oI portIolio.
NumAssets (required). Scalar representing
number oI assets in portIolio.
AssetLims
Minimum and maximum
allocation per asset.
AssetMin (required). Scalar or vector oI length
NASSETS, speciIying minimum allocation per
asset.
AssetMax (required). Scalar or vector oI length
NASSETS, speciIying maximum allocation per
asset.
NumAssets (optional).
GroupLims
Minimum and maximum
allocations to asset group.
Groups (required). NGROUPS-by-NASSETS
matrix speciIying which assets belong to each
group.
GroupMin (required). Scalar or a vector oI
length NGROUPS, speciIying minimum
combined allocations in each group.
GroupMax (required). Scalar or a vector oI
length NGROUPS, speciIying maximum
combined allocations in each group.
GroupComparison
Group-to-group
comparison constraints.
GroupA (required). NGROUPS-by-NASSETS
matrix speciIying Iirst group in the comparison.
AtoBmin (required). Scalar or vector oI length
NGROUPS speciIying minimum ratios oI
allocations in GroupA to allocations in GroupB.
AtoBmax (required). Scalar or vector oI length
NGROUPS speciIying maximum ratios oI
allocations in GroupA to allocations in GroupB.
GroupB (required). NGROUPS-by-NASSETS
matrix speciIying second group in the
comparison.
Custom
Custom linear inequality
constraints A*PortWts'
b.
A (required). NCONSTRAINTS-by-NASSETS
matrix, speciIying weights Ior each asset in each
inequality equation.
b (required). Vector oI length NCONSTRAINTS
speciIying the right hand sides oI the
inequalities.
Source: MATLAB Financial toolbox

29
Optimal capital allocation to efficient frontier portfolios
A last Iunction we describe here may be used to Iind an optimal portIolio. So Iar, we have deal
with eIIicient portIolios, leaving the risk/return trade-oII unresolved. We may resolve this trade-oII
by linking mean-variance portIolio theory to the more general utility theory. Function portalloc
computes the optimal risky portIolio on the eIIicient Irontier, based on the risk-Iree rate, the
borrowing rate, and the investor`s degree oI risk aversion. Also generates the capital allocation line,
which provides the optimal allocation oI Iunds between the risky portIolio and the risk-Iree asset. In
the Financial toolbox the Iunction portalloc is provided, which yields the optimal portIolio
assuming the quadratic utility Iunction:
2
( ) 0.005
p p
U E r Ao = , where the parameter A is linked to
risk aversion; its deIault value is 3.
Function: portalloc
$ynta
RiskyRisk, RiskyReturn, RiskyWts, RiskyFraction, JverallRisk, JverallReturn, =
portalloc(!ortRisk, !ortReturn, !ortWts, RisklessRate, BorrowRate, RiskAversion)
RiskyRisk is the standard deviation oI the optimal risky portIolio; RiskyReturn is the
expected return oI the optimal risky portIolio; RiskyWts is a vector oI weights allocated to the
optimal risky portIolio; RiskyFraction is the Iraction oI the complete portIolio allocated to the
risky portIolio; JverallRisk is the standard deviation oI the optimal overall portIolio;
JverallReturn is the expected rate oI return oI the optimal overall portIolio.
!ortRisk is standard deviation oI each risky asset eIIicient Irontier portIolio; !ortReturn is
expected return oI each risky asset eIIicient Irontier portIolio; !ortWts is weights allocated to each
asset. RisklessRate is risk-Iree lending rate (Ior investing), a decimal number; BorrowRate is
borrowing rate, which is larger than the riskless rate, a decimal number
21
. RiskAversion is
coeIIicient oI investor's degree oI risk aversion (DeIault 3). BorrowRate and RiskAversion
are optional.
As with frontcon, calling portopt while speciIying output arguments returns the
corresponding vectors and arrays representing the risk, return, and weights Ior each oI the portIolios
along the eIIicient Irontier. Use them as the Iirst three input arguments to the Iunction portalloc.
Calling portalloc while speciIying the output arguments returns the variance (RiskyRisk), the
expected return (RiskyReturn), and the weights (RiskyWts) allocated to the optimal risky

21
II borrowing is not desired, or not an option, set to NaN (deIault).
30
portIolio. It also returns the Iraction (RiskyFraction) oI the complete portIolio allocated to the
risky portIolio, and the standard deviation (JverallRisk) and expected return (JverallReturn)
oI the optimal overall portIolio consisting oI the risky portIolio and the risk-Iree asset. The overall
portIolio combines investments in the risk-Iree asset and in the risky portIolio. The actual
proportion assigned to each oI these two investments is determined by the degree oI risk aversion
characterizing the investor. The value oI RiskyFraction exceeds 1 (100), implying that the risk
tolerance speciIied allows borrowing money to invest in the risky portIolio, and that no money will
be invested in the risk-Iree asset. This borrowed capital is added to the original capital available Ior
investment. Calling portalloc without speciIying any output arguments gives a graph displaying
the critical points.

Six-stock-index portfolio
We use the previous example. Assume an American investor Iorm six-stock-index portIolio
and he/she wants to what is his/her optimal portIolio allocation. We assume risk Iree investment
return is 4.1, investor`s degree oI risk aversion is 5, and borrowing rate is 7. We also allow
short selling up to 100 oI the portIolio value in each stock index, but limit the investment in any
each stock index to 150 oI the portIolio value. Now we use MATLAB to assist him/her.
First, we calculate rate oI return oI the natural logarithm stock index price, save them as a text
Iile ' stockindex.txt into C:\ProgramFiles\MATLAB7\work\ stockindex.txt, and load this Iile
into MATLAB Secondly, use mean and cov Iunctions calculate expected return oI each stock index
and covariance matrix oI portIolio. Thirdly, call portcons to create the matrix oI constraints Ior
short selling allowance and call portfopt compute constrained eIIicient Irontier. Then, Use
!ortRisk, !ortRet, !ortWts input arguments to the Iunction portalloc and Iind the optimal
risky portIolio and the optimal allocation oI Iunds between the risky portIolio and the risk-Iree
asset.





31
Figure X.11 MATLAB code for asset allocation
clear all;
clc;
tic
%portfolio.m
load stock_index.txt;
!ortfolio = stock_index (:,6);
m n, = size(!ortfolio);
AvrRet,= mean(!ortfolio);
ExpRetVec,= (1+ AvrRet).^12-1;
CovMtx,= cov(!ortfolio);

% CJM!&TE EFFICIENT FRJNTIER (SHJRT SELLING ALLJWED)
Num!orts = n;
AssetMin = -1 -1 -1 -1 -1 -1,;
AssetMax = 1.5 1.5 1.5 1.5 1.5 1.5,;
pval = 1;
Constraint = portcons('!ortValue',pval, Num!orts, 'AssetLims', AssetMin, AssetMax,
Num!orts);
!ortRisk,!ortRet,!ortWts, = portopt(ExpRetVec, CovMtx, 50, ,, Constraint);
JptRisk,JptRet,JptWts,=portopt(ExpRetVec, CovMtx, Num!orts, ,, Constraint);

% J!TIMAL ASSET ALLJCATIJN
RisklessRate = 0.041;
BorrowRate = 0.07;
RiskAversion = 5;
RiskyRisk, RiskyReturn, RiskyWts, RiskFraction, JverallRisk, JverallReturn, =
portalloc (!ortRisk, !ortRet, !ortWts, RisklessRate, BorrowRate, RiskAversion)

% !LJT THE RES&LT
plot(!ortRisk, !ortRet, 'm-', JptRisk, JptRet, 'x', ...
0, RisklessRate, 'k:square', RiskyRisk, RiskyReturn, 'k:diamond',...
0; RiskyRisk,, RisklessRate; RiskyReturn,,'r--')
xlabel('!ortfolio Risk');
ylabel('!ortfolio Return ');
title('Efficient Frontier');
%legend('Efficient Frontier', 'Jptimal !ortfolio', 'Risk free asset', 'Risky
!ortfolio', 'Asset Allocation !oint')
grid on

In this example the customer will tolerate borrowing 373.44 oI the original capital amount to
invest in the six-stock-index portIolio, and that no money will be invested in the risk-Iree asset.
The optimal overall portIolio return is 84.28with 39.31 standard deviation. The expected return
oI six-stock-index portIolio is 23.32, portIolio risk is 8.30. The best allocation proportion oI
each asset Ior the investor is to allocate 63.34 portIolio value in S&P 500 Index, 114.39 in
Swiss Market Index(SMI), and 122.93 in Hang Seng Index(HSI), and short selling 100
portIolio value in FTSE100 Index, 94.45 in Straits Times Index(STI) ,and 6.21 in Korea
Composite Stock Price Index (KOPSI) .


32
Figure X.12 MATLAB output of optimal allocation problem
RiskyRisk =
0.0830
RiskyReturn =
0.2332
RiskyWts =
0.6334 -1.0000 1.1439 -0.9445 1.2293 -0.0621
RiskFraction =
4.7344
JverallRisk =
0.3931
JverallReturn =
0.8428

Figure X.13 Optimal asset allocation





33
References
Benninga Simon, 1999, Financial Modeling, The MIT press, Combridge, Massachusetts, London,
England 1999.
Bodie ., A. Kane ,and A. J. Marcus, 2003, Essentials of Investment FiIth edition,
xxxx:McGraw-Hill.
Bodie ., A. Kane ,and A. J. Marcus, 2005, Investment, Sixth edition, McGraw-Hill.
Brandimarte Paolo, umerical Methods in Finance. A MATLAB-Based Introduction, New
York:John Wiley & Sons. Inc.
Cheng F. Lee, Joseph E. Finnerty, Donals H. Wort ,1990, Securit Analsis and Portfolio
Management, xxxx:xxxx
Jackson Mary and Mike Staunton, 2002, Advanced Modelling in Finance using Excel and
JBA,xxxx:xxxx.































34
Appendi A
To prove the slope and the shape oI extreme correlation between two assets
Assuming that the weight oI asset A and asset B are
1 2
and w w , and
1 2
1 w w + = .
2 2 2 2 2
2 2 2 2 2
2
2
*
2 2
Minimum variance portIolio (MVP)
var( ) 2
(1 ) 2 (1 )
. .
2

p p A B A B A B A B AB
A A A B A A A B AB
p
B AB A B
A
A A B AB A B
Min r w w w w
w w w w
F O w
w
o o o o o p
o o o o p
o
o p o o
o o p o o
= = + +
= + +


=
+
* *
1
B A
w w =

Case one: Two assets are perIectly position correlated
II short sales are allowed, then even though 1 p =
Selling short asset A and go extra long in asset B
12
II 1, p = +
2 2
2
*
( ) ( ) (1 ) ( )
| (1 ) |
| (1 ) |
: 0
( )
, ( ) ( )
( )
( )
( ) ( )
p A A A B
p A A A B
p A A A B
p
B
A
A A B
p p
A B A B
A A
p
p
A A B
p
p A B
A
E R w E r w E r
w w
w w
MJP w
w
E R
E r E r
w w
E R
E R
w E r E r
w
o o o
o o o
o
o
o o
o
o o
o
o o o
= +
= +
= +

= =


= =


= = +











35
Case Two: Two assets are perIectly negative correlated
Just invest both asset A and b (both in long position)
12
II 1, p =
2 2
2
*
* 2
*
* *
( ) ( ) (1 ) ( )
| (1 ) |
| (1 ) |
: 0
a. 0
b.
2
2
2
( ) 0
| (1 ) | (
p A A A B
p A A A B
p A A A B
p
B
A
A A B
A A p
A A
B
A A A
A B
B
p A B B B
A B
p A A A B A
E R w E r w E r
w w
w w
MJP w
w
w w
w w
Let w w w
w w w
o o o
o o o
o
o
o o
o
o
o o
o
o o o o o
o o
o o o
= +
=
=

= =
+
= =
>
= = >
+
= + = >
+
= + =
*
*
* *
)

| (1 ) |
( )
( )
( ) ( )

c.
0.5
0.5
0.5
( ) 0.5 0
| (1
A B B
A A
p A A A B
p
p p
A A B
A B
p
A p B B
A
A A
B
A A A
A B
B
p A B B B
A B
p A A A
when w w
w w
E R
E R
w E r E r
w
w
w w
Let w w w
w w
o o o
o o o
o
o o
o
o o o
o
o o
o
o o o o o
o o
o o
+
>
= +


+
= + = = = +

+ +

= =
+
= + =
+
=
*
) | | ( ) |

| |
( )
( )
( ) ( )

( )
B A A B B
A A
p A A B A B
p
p p
A A B
A B
p
A p A B
A
w
when w w
w w
E R
E R
w E r E r
w
w
o o o o
o o o o
o
o o
o
o o o
= +

= +


+
= + = = =


36
Appendi B
The weights oI minimum variance portIolio
The weights should be chosen so that (Ior example) the risk is minimized, that is
2 2 2 2 2
Min 2
A
P A A B B A B AB A B
w
w w w w o o o p o o = + +
Ior each chosen return and subject to 1, 0, 0
A B A B
w w w w + = > > . The last two constraints simply
imply that the assets cannot be in short positions.
Substitute
( , )
A B
AB
A B
ov r r
p
o o
=

into equation X.6.



2 2 2 2 2
(1 ) 2
p A A A B A B A B AB
w w w w - o o o o p = + +
2 2 2 2 2 2 2 2
2 2 2
p A A B A B A B A AB A B A B AB A B
w w w w w w - o o o o p o o p o o = + + +
F.O.C.
2
0
P
A
w
o
=



2
2 2 2
2 2 2 2 4
P
A A B A B AB A B A AB A A
A
w w w
w
o
o o o p o o p o o

= + +



2 2 2
2 ( 2 ) 2 2 0
A A B AB A B B AB B A
w o o p o o o p o o + =
2
2 2
2
B AB A B
A
A B AB A B
w
o p o o
o o p o o

=
+

1
B A
w w =
When p 1

B
A
A B
w
o
o o
=


2
A B
B
A B
w
o o
o o


When p -1

B
A
A B
w
o
o o
=
+

A
B
A B
w
o
o o
=
+

When p 0

2
2 2
B
A B
A
w
o
o o
=
+

2 2
2 2
2
A B
A B
B
w
o o
o o

=
+

You might also like