Sunteți pe pagina 1din 10

Portfolio Optimization

via Efficient Frontier with


the IMSL

Numerical Libraries
A White Paper by Visual Numerics, Inc.
March 2008
www.vni.com
Visual Numerics, Inc.
2500 Wilcrest Drive, Suite 200
Houston, TX 77042
USA
Portfolio Optimization via Efficient Frontier with the IMSL Numerical Libraries
by Visual Numerics, Inc.
Copyright 2004 - 2008 by Visual Numerics, Inc. All rights reserved.
Printed in the United States of America.
Publishing History:
Updated March 2008
Originally published April 2004
Trademark Information
Visual Numerics, IMSL and PV-WAVE are registered trademarks of Visual Numerics, Inc. in the U.S. and other countries. JMSL, JWAVE, TS-
WAVE and Knowledge in Motion are trademarks of Visual Numerics, Inc. All other company, product or brand names are the property of their
respective owners.
The information contained in this document is subject to change without notice. Visual Numerics, Inc., makes no warranty of any kind with
regard to this material, included, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. Visual
Numerics, Inc., shall not be liable for errors contained herein or for incidental, consequential, or other indirect damages in connection with
the furnishing, performance, or use of this material.
3
TABLE OF CONTENTS
Introduction 4
Inputs to the Problem 4
Constraints on the Solution 5
Computing the Efficient Frontier 6
Analysis of the Efficient Frontier Curve 8
Finding the Optimal Portfolio 9
For more Information 9
4
Introduction
The ultimate goal of portfolio optimization is to build a portfolio with the proper proportion of its
components that will balance minimum risk and maximum return. One textbook method to that end
involves the computation of the efficient frontier curve, which enumerates a set of portfolios that will
generate some given rate of return while minimizing risk to the investor. Once that curve is computed, an
optimal portfolio can be selected from the set through a graphical method that involves the risk-free rate
of return. This document will travel through the discovery of that ideal portfolio by reviewing the necessary
inputs, constraints on the solution, the computation and analysis of the efficient frontier, and how to select
the optimal solution from the set of possible solutions.
Several IMSL Library functions are referred to in the text. The function is named generically in the text,
and the actual function names are provided parenthetically for the IMSL Fortran Library, IMSL C Library,
IMSL C# Library and JMSL Library respectively. Some details of the use of some of the functions may
be included in the text; for complete usage information, please consult the appropriate IMSL Library
documentation.
The term security will be used in reference to the items that make up the portfolio throughout this
document; however, the contents of the portfolio may well be a combination of stocks, bonds, indices or
any investment. Further, the example in this paper is built on just five securities. The analysis technique
and algorithms scale to problems of much larger scale with hundreds or thousands of securities.
Inputs to the Problem
The required data for input to the main optimization routine is the variance-covariance matrix for the
securities involved, the individual expected fractional returns, and the risk-free interest rate. The first two
items may not be explicitly known. However, they can be computed from a time history of each security.
The variance-covariance matrix contains the variance for each security as well as the covariance between
each pair of securities. This information is important because the variance, , is a measure of the risk
associated with a given security. Further, it is important to know how well the securities are correlated with
each other. This matrix is symmetric (
12
=
21
) so only the upper triangular part needs to be stored and
looks like:

11

12

13

14

15

22

23

24

25

33

34

35

44

45

55
5
Occasionally, one will have this information already, but the IMSL Library Covariance function (CORVC,
covariances, com.imsl.stat.Covariances, Imsl.Stat.Covariances) can compute the matrix from the input
time series.
Next, the expected returns must be provided. These values are often based on knowledge of the security or
its market, but if such knowledge is lacking then they can be computed using any of several methods such
as a linear regression or a geometric mean of the historical returns.
The final required input is the risk-free interest rate. This is the rate of return an investor could realize
assuming zero risk, like the Fed Funds rate or the Treasury Bill rate. The computed efficient frontier is a
set of optimized portfolios, each of which minimizes risk (volatility) for a given rate of return. The risk-free
rate of return is used to select a single optimal portfolio from this set of optimized portfolios that has the
greatest return for a low amount of risk.
Constraints on the Solution
The above inputs are the raw data necessary to compute a solution. To solve the optimization problem, a
set of constraints is also required. The default constraints on the contents of the portfolio would be that
each security can make up from 0 to 100% of the portfolio and that the sum of all the security
contributions must be 100%.
An investor may have other ideas that constrain the weights of some or all of the securities in the portfolio.
For example, in the interest of diversification, one may require that no security make up more than 25% of
the portfolio. Alternatively, there may be a favorite security among the group that deserves a minimum
weight of 12%. There may also be a security that is not in favor that should be limited to a maximum
weight of 8%. And there remains the transparent constraint on the solution that the total of the weights
must be 100% to build a complete portfolio. For an example case of five securities with the above
constraints, the bounds on the weights may look like the following matrix:
The left side holds the lower bounds; the right, the upper. The second security is the favorite, and the
fourth is the one to limit. The final row is for the constraint that the total of all the weights must be 100%.
0.00 0.25
0.12 0.25
0.00 0.25
0.00 0.08
0.00 0.25
1.00 1.00
6
The coefficient matrix for the constraints goes along with the bounds discussed above. For the general
example with five securities, this coefficient matrix looks like:
As before, each of the first five rows is for each security in the portfolio and the final row is for the additional
constraint that all the weights must sum to 100%. One can make this more complex if there are constraints
like the sum of the first three securities must be less than 15% where there would be an additional row in
the coefficient matrix (1,1,1,0,0) and an additional row in the constraints on the weights of (0,0.15).
It may be easier to understand these constraints if they are written out algebraically. For the above example
for five securities, the weights are w
1
through w
5
in the following set of equations:
Computing the Efficient Frontier
With the above required inputs and the bounds on the solution set, the efficient frontier can now be
computed. This step is made up of several smaller steps. First, minimum and maximum possible returns
must be computed. Then for all the returns between the extremes, the portfolio that minimizes the risk is
computed. The efficient frontier is this set of portfolios for given values of risk and return.
The minimum and maximum possible returns are computed using the IMSL Library Linear Programming
function (DENSE_LP, linear_programming, com.imsl.math.DenseLP, Imsl.Math.DenseLP). The inputs into this
function are the constraints discussed above and the expected returns for each investment. Note that the
constraints here are both upper and lower bounds. As such, they must be input into the function as separate
one-dimensional arrays, with the lower bound as a parameter and the upper as an optional argument. The
optimal value returned from the linear programming function is the minimum possible return that can be
realized given this set of securities and the bounds on their weights in the portfolio. To find the maximum
possible return, the same function and input matrices are used except that the negative of the expected
returns is used. Literally, the negative return will be minimized now, yielding the maximum possible return.
1 0 0 0 0
0 1 0 0 0
0 0 1 0 0
0 0 0 1 0
0 0 0 0 1
1 1 1 1 1
0.05 w
1
1.00
0.12 w
2
1.00
0.05 w
3
1.00
0.05 w
4
0.08
0.05 w
5
1.00
1.00 w
1
+ w
2
+ w
3
+ w
4
+ w
5
1.00
7
With the minimum and maximum possible returns known, the extents of possible values on the risk-return
plot have been limited vertically. The next step is to find the portfolio that minimizes risk for each one of a
hundred or so return values evenly distributed between the minimum and maximum possible returns. Each
portfolio is computed using the IMSL Library Quadratic Programming function (QPROG, quadratic_prg,
com.imsl.math.Quadradic.Programming, Imsl.Math.QuadraticProgramming). The solution to this function is
a vector of weights for the securities that build the portfolio with the minimum amount of risk for the given
expected return. Also of interest is the overall value of risk for the portfolio, which is related to the optimal
object function found. Note that this is an output keyword for the IMSL C Library function, but not for the
IMSL Fortran, IMSL C#, or JMSL Library routines. It can be computed easily, however, since it is just:
Here x is the solution (the vector of weights), Q is the variance-covariance matrix.
At this point, for each possible return, the combination of securities that minimizes risk is known.
Graphically, one plots the risk and return values with risk on the x axis and return on the y axis. For
graphical purists, this will appear to be the reverse of what would normally be plotted since the resulting
curve appears as a double-valued function. That is, for some value of risk (on the x axis), two values of
return (on the y axis) may be observed. Figure 1 shows a typical efficient frontier graph.
FIGURE 1. An Efficient Frontier.
kx
T
Qx
8
Analysis of the Efficient Frontier Curve
This curve forms the basis of portfolio optimization and should be well understood. Minimum and
maximum possible returns were the first two points solved for. Determined by the linear programming
function calls, these points indicate the extents of realizable return for the portfolio contents and weight
constraints. It is impossible to achieve a higher or lower return rate than this; that is, there is no portfolio
that can give returns outside these bounds. See Figure 2.
On the other axis, the quadratic programming function has found the minimum risk for values of return
between the extremes. There are many portfolios that can result in a larger amount of risk for a given
return, and these portfolios would be points to the right of the efficient frontier curve. However, it is
impossible to find a portfolio that exposes less risk for any given value of return than those portfolios that
lie on this line. Thus the achievable risk-return space is the area of the graph between the vertical extents
of the curve and to the right. It is not possible, again given the content selection and constraints on the
proportions, to build a portfolio that returns risk and return values outside of this region.
FIGURE 2. The Achievable Risk-Return Space.
9
Finding the Optimal Portfolio
Examination of the portfolios that make up the efficient frontier curve will help in understanding the
concept of an optimal portfolio out of this set of portfolios that minimizes risk. This examination starts
with the bottom most point on the curve, where the portfolio represents the minimum return achievable,
and it has some value of risk associated with it. As one moves along the curve, the rate of return increases
and the rate of risk decreases, indicating better portfolio combinations with regards to higher return for less
risk. Eventually, the point of minimum risk is reached for some given return. If one were interested in only
minimizing risk, then this is the ideal portfolio combination. However, notice that there are points on the
curve indicating portfolios that yield a higher return. Moving along the curve further upward, the level of
risk increases along with the rate of return. At some point, the portfolios, while achieving higher rates of
return, are entering into a region of unacceptably high amounts of risk for those returns. The question
becomes where along this portion of the curve is the ideal spot?
The capital market line is a line defined such that the intercept is the risk-free rate of return and the slope
is the Sharpe ratio. In terms of the Capital Asset Pricing Model, the slope is the beta of the portfolio, .
The optimal portfolio, balancing the maximum return for the lowest amount of risk, can be found by
maximizing the slope of the line. To find this optimal portfolio, the risk-free rate of return is plotted on the
same graph as the efficient frontier. Since this point is risk-free by definition, it will appear where risk
equals zero, or somewhere on the y axis. The maximum slope occurs where the line is tangent to the
efficient frontier. Continuing the march along the curve moving from the point of minimum risk, the
amount of risk slowly increases as the rate of return increases. After the optimal portfolio is reached,
notice that the curvature of the efficient frontier is such that assuming additional risk does not achieve
a proportional return.
Figure 3 shows the efficient frontier (solid line) along with the risk-free rate of return (square) and the
capital market line (dashed line). The intersection of the efficient frontier curve with the tangent line is
the location in risk-return space of the optimal portfolio. One would then return to the solution provided by
the quadratic programming function to find what the associated weights are for this value of return. This
weight vector is the answer to the overall optimization problem: the ratio of each security in the portfolio.
The last extreme point on the curve is the portfolio that gives the maximum return. If the interest was just
in maximizing the possible return, this is the portfolio of choice. However, an investor would assume a
larger amount of risk to achieve this return. The combination of maximizing return and minimizing risk
yields the optimal portfolio at the tangent point found above.
10
FIGURE 3. The Optimal Portfolio.
For more Information
The ultimate goal of portfolio optimization is to build a portfolio with the proper proportion of its
components that will balance minimum risk and maximum return. The efficient frontier curve, which
enumerates a set of portfolios, will generate some given rate of return while minimizing risk to the
investor. This white paper outlined the necessary inputs, constraints on the solution, the computation
and analysis of the efficient frontier, and how to select the optimal solution from the set of possible
solutions.
Several IMSL Library functions were referred to in the text. The IMSL Numerical Libraries have been
the cornerstone of predictive analytics and high-performance computing applications in science,
technical and business environments for more than three decades. Regarded as the most
sophisticated and reliable technology available, the IMSL Libraries provide users with the software
and technical expertise needed to develop and execute scalable numerical analysis applications.
To view a brief online demonstration of the JMSL Numerical Library being used to solve a portfolio
optimization problem similar to the one described in this white paper, visit the Demos area at
http://www.vni.com/products/imsl/jmsl/jmsl.php
For general information on the IMSL Numerical Libraries for Fortran, C/C++, .NET or Java, visit
http://www.vni.com/products/imsl/

S-ar putea să vă placă și