|
WebCab Portfolio Demo v4.2 (J2SE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object | +--webcab.lib.finance.portfolio.Markowitz
This class applies the Markowitz Model to analyze the construction and
qualitative nature of a portfolio's risk-return characteristics. In particular,
we offer methods by which the continuum (in risk and expected return) of portfolios
(known as the Efficient Frontier) which consists of the portfolios with the minimum
risk for a given value of the expected return which can be constructed from a given
collection of assets. Moreover, from this collection of Portfolios a unique optimal
portfolio can be selected with respect to a given value of the expected return, risk
(see SolveFrontier) or an investors risk - return profile given in terms
of a utility function.
Overview of Functionality Offered
The Efficient Frontier is the collection of portfolios constructed from the given set of assets which have the lowest possible risk for a given level of the expected return. Note that the weights of the assets making up the portfolio may themselves be subject to constraints (for example, no one asset can have a weighting more than 20 percent or less the 5 percent).
Once the Efficient Frontier is known, we are able to select from this continuum a unique portfolio which represent the optimal portfolio with respect to an investors risk - return profile. The return profile of the investor may be given in three distinct ways and the correspond optimal portfolio can them be constructed. The by one of the following means:
setUtilityFunctionInterp, or
setUtilityFunctionInterp.
Construction of the Efficient Frontier
The Efficient Frontier is constructed by the following steps:
The points on the Efficient Frontier are portfolios constructed from the set of assets considered which exhibit the lowest risk for a given expected return. These portfolio are characterized by the following three characteristics:
It is important to point out that the Efficient Frontier in monotonically increasing function in risk and expected return. This means that if we are given a value of the expected return then there will correspond a unique portfolio on the Efficient Frontier with a given total risk. Conversely, if we are given the total risk of the portfolio then there will exist a unique portfolio on the Efficient Frontier with a corresponding value its expected return.
The three means of Selecting the Optimal Portfolio
Within the application of portfolio theory the following two quantities will need to use the corresponding units of measurement throughout the computation:
The units used within these two quantities will effect the following objects:
Therefore, whenever wishing to apply our portfolio component you should decide for the beginning whether you wish to use absolute or relative values for these three instances.
Assumptions underlying Markowitz Theory
Portfolio theory in the shape of Markowitz Theory makes the following assumptions concerning the investment market and investors behavior within those markets. We summaries these assumptions below:
Types of functionality provided
With this class we offer Markowitz Theory related procedures which enable the evaluation of the Efficient Frontier and the optimal portfolio to be selected from the Efficient Frontier from knowledge of its expected return or the investors risk - reward utility function. That is, within this class we offer the following:
calculateEfficientFrontier
first evaluates the Efficient Frontier and sets it within private fields of the class. Note
that if applicable the constraints on the weights of the assets within the portfolios on the
Efficient Frontier should be set using setConstraints. Once the (possibly
constrained) Efficient Frontier has been set the method efficientFrontier(double, int),
can read of the portfolios with almost no additional computational overhead.
expectedReturnEfficientFrontier, assetWeightsEfficientFrontier,
portfolioRisksEfficientFrontier. We also provide within
this class a general cubic spline interpolation procedure Interpolation.cubicSplinePointwise(double[], double[], double, double, double),
which allows you to interpolate the Efficient Frontier from the known values of the expected
return and total risk of the finite set of known points of the Efficient Frontier.
efficientFrontier(double, double[][], double[], double)
returns the weights of the optimal portfolio (i.e. lowest risk) for a given expected return
and does not require prior evaluation of any other methods.
setUtilityFunctionInterp, or setUtilityFunctionPoly(double[]).
optimalPortfolio(double, double, double[][]),
optimalPortfolioMaxExpected(double, double, double[][]). Please, note that before either of these methods is called
you are required to set the investors utility function and evaluate the Efficient Frontier.
Notes on the Evaluation of the Efficient Frontier
To calculate the Efficient Frontier, Rosen's gradient projection optimization algorithm
is used. If you directly try to evaluate the optimal portfolio with respect to an investors
utility function then you will need numerous applications of Rosen's algorithm which will
become computationally intensive. Therefore, we designed this class so that this would not
be necessary by allowing the computation at the beginning a number of points on the Efficient
Frontier, from which the other points will be deduced (in fact, estimated) through the use of
cubic spline interpolation. These interpolation points are determined by
calculateEfficientFrontier, which must be called prior to
any subsequent method which depends on the Efficient Frontier being known.
Estimation/evaluation of non-observable parameters
A number of the parameters which are required by this classes methods such
as the covariance matrix are not directly observable from the market. However,
the evaluation may be evaluated or estimated directly from market driven
information such as historical asset prices. All methods related to the evaluation
of such parameters have been collected or are referenced within the
AssetParameters class.
In particular, the AssetParameters class contains the following
procedures:
AssetParameters.covarianceMatrix(double[], double[][]),
AssetParameters.covarianceMatrix(double[][])
AssetParameters.expectedReturns(double[][]),
AssetParameters.expectedReturns(double[][])
| Constructor Summary | |
Markowitz()
Creates a new Markowitz instance. |
|
| Method Summary | |
double[][] |
assetWeightsEfficientFrontier()
This method returns the array of dimension two which gives the weights of the portfolios on the Efficient Frontier for the collection of points at which it is evaluated. |
void |
calculateEfficientFrontier(double[][] covarianceMatrix,
double[] expectedReturns,
int numberInterpolationPoints,
double precision)
This method calls the calculateEfficientFrontier by setting the range of the expected returns over which the Efficient Frontier
is evaluated to be the entire range over which the (constrained) Efficient Frontier exists.
|
void |
calculateEfficientFrontier(double minimumExpectedReturn,
double maximumExpectedReturn,
double[][] covarianceMatrix,
double[] expectedReturns,
int numberInterpolationPoints,
double precision)
Calculates the interpolation points used in order to construct the Efficient Frontier with a given range of expected returns for a collection of assets from which the optimal portfolio can be constructed. |
double[][] |
covarianceMatrix(double[][] historicalReturns)
Deprecated. |
double[][] |
covarianceMatrix(double[] probability,
double[][] returns)
Deprecated. |
double[] |
efficientFrontier(double expectedReturn,
double[][] covarianceMatrix,
double[] expectedReturns,
double precision)
Returns the (possibly constrained) weights of the assets within the portfolio which offers the least risk for a given expected return. |
double[] |
efficientFrontier(double expectedReturn,
int numberOfAssets)
Returns the (possibly constrained) weights of the assets of the portfolio which offers the least risk for a given expected return. |
double[] |
expectedReturnEfficientFrontier()
Returns the value of the expected return at the set of points along which the Efficient Frontier has been evaluated and set to a private field. |
double[] |
expectedReturns(double[][] historicalReturns)
Deprecated. |
double[] |
expectedReturns(double[] probability,
double[][] returns)
Deprecated. |
double[] |
getLowerConstraints()
Returns the values of the lower bound constraints on the asset weights set by setConstraints. |
PointsOnEfficientFrontier |
getPointsOnEfficientFrontier()
This methods returns the complex type PointsOnEfficientFrontier which
represents points on the Efficient Frontier. |
double[] |
getUpperConstraints()
Returns the values of the upper bound constraints on the asset weights set by setConstraints. |
double |
maxFrontierReturn(double[] expectedReturns)
Evaluates the expected return of the portfolio on the (constrained) Efficient Frontier with the highest value of the expected return. |
double[] |
maxFrontierReturnWeights(double[] expectedReturns)
Returns the weights of the assets of the portfolio on the (constrained) Efficient Frontier with the highest value of the expected return. |
double |
minFrontierReturn(double[] expectedReturns)
Returns the expected return of the portfolio on the Efficient Frontier with the lowest value of the expected return. |
double[] |
minFrontierReturnWeights(double[] expectedReturns)
Returns the weights of the assets within the portfolio on the (constraints) Efficient Frontier which has the highest value of the expected return. |
double[][] |
optimalPortfolio(double[][] covarianceMatrix,
double[] expectedReturns)
This method constructs the optimal portfolios with respect to the investors utility function over the entire range for which the Efficient Frontier exists. |
double[][] |
optimalPortfolio(double minimumExpectedReturn,
double maximumExpectedReturn,
double[][] covarianceMatrix)
Evaluates the set of (possibly constrained) portfolios on the Efficient Frontier which are optimal with respect to the investors utility function. |
double[] |
optimalPortfolioMaxExpected(double minimumExpectedReturn,
double maximumExpectedReturn,
double[][] covarianceMatrix)
Calculates the (possibly constrained) portfolio on the Efficient Frontier which offers the maximum expected return from the set of portfolios which are selected from the Efficient Frontier by the investors utility function. |
double |
portfolioRisk(double[] weight,
double[][] covarianceMatrix)
Deprecated. |
double[] |
portfolioRisksEfficientFrontier(double[][] covarianceMatrix)
Within this method we evaluate the risks which correspond to the portfolios at the points which the Efficient Frontier is known. |
double |
portfolioVariance(double[] weight,
double[][] covarianceMatrix)
Deprecated. |
void |
setConstraints(double[] lowerBounds,
double[] upperBounds)
Here we allow constraints to be placed on the weights of the assets from which the portfolios within the Efficient Frontier will be constructed. |
void |
setUtilityFunctionInterp(double[] expectedReturn,
double[] totalRisk)
Sets the utility function which defines an investors preferred risk - expected return profile. |
void |
setUtilityFunctionPoly(double[] coefficient)
Sets the utility function which defines the investors preferred risk-return profile. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public Markowitz()
| Method Detail |
public void calculateEfficientFrontier(double minimumExpectedReturn,
double maximumExpectedReturn,
double[][] covarianceMatrix,
double[] expectedReturns,
int numberInterpolationPoints,
double precision)
throws NoSolutionException,
MarkowitzDemoException
Overview
A constrained optimization algorithm is used each time to find the portfolios which have the least risk for a given set of expected returns. In fact, an optimization algorithm which is computational intensive will need to be called for each evaluation of an interpolation point. These interpolation points will then be interpolated in order to the construct the Efficient Frontier over the range of expected returns considered.
Constraining the Weights of the assets of the Efficient Frontier's Portfolios
With our implementation we offer the possibility to constrain the weights of the assets
from which the portfolios on the Efficient Frontier are constructed. The constraints on the
weights on the portfolios are set by using the method setConstraints. We illustrate
the use constraints with the following example.
Say an investor requires a portfolio selected from n asset which has the
lowest risk for a given expected return but also has the requirement that all of
the assets must have a weight between 0.05 and 0.1
(i.e. between 5 and 10 percent). In this instance we would need to set the constraints
on the assets to be:
lowerBounds = {0.05, 0.05, 0.05,...., 0.05}
upperBounds = {0.1, 0.1, 0.1, ......, 0.1}
where each of the arrays above has n terms, using the method
setConstraints.
Remark: If the constraints are not set then they will take there default values
which are 0 and 1, for the lower bound respectively upper bound
of each asset. That is, they will remain as weights in the usual sense.
Selecting the range of the Expected Returns
We allow the user to restrict the range of expected returns over which the Efficient Frontier is evaluated since:
In short, the minimum and maximum of the expected return give a range over which the (possibly constrained) Efficient Frontier is evaluated. Once the range is set, the interpolation points (i.e. the set of expected returns) is used to equally divide up the range and the Efficient Frontier's interpolation points are evaluated (only) within this range. By excluding sections of the Efficient Frontier will allow more interpolation points to be evaluated within the range of expected returns of interest for a given computation effort.
Remark: For a given range the more interpolation points are evaluated the more accurately the Efficient Frontier will be represented which will result in to greater accuracy of the construction of the optimal portfolio.
Evaluating the Range of the expected returns on the Efficient Frontier
As mentioned before the points on the (constrained) Efficient Frontier correspond to portfolios which
can be constructed from a given set of available assets where the sum of the weightings of the assets
sum to 1. Therefore, (since the expected return is additive) the range of expected returns
will lie within the range of expected returns of the assets. Below we consider the exact range of the
value of the expected return for which the (constrained) Efficient Frontier exists.
Within this class we offer the two methods minFrontierReturn(double[]) and maxFrontierReturn(double[])
which evaluate the upper bounds and lower bounds respectively of the range of the expected returns over which
the Efficient Frontier exists for the given set of asset considered. If you set the range of expected returned
considered to lie outside this range then an exception will be thrown.
Remarks on the Range of expected returns of the Unconstrained Efficient Frontier
If the weights of the assets are not constrained then the range of expected returns (i.e. all possible optimal portfolios) will lie in the continuous range given by:
= the expected return of the asset with the lowest expected
return.
= the expected return of the asset with the highest expected
return.
Remarks on the Range of expected returns of the Constrained Efficient Frontier
In the case where the weights of the assets from which the portfolios on the Efficient Frontier
can be constructed are constrained. The range of the expected return for which the constrained Efficient
Frontier may exist may not cover the full range of values of expected returns of the assets. The reason
being that the asset with the highest (resp. lowest) expected return may have an upper bound in which
case you are not able to construct the portfolio solely of this asset because at all time the weights
of the assets must sum to 1.
The range of the Expected Returns and Performance considerations
The way in which you set the range of expected returns considered will depend on the nature of the problem you are considering. If you are considering a portfolio optimization problem in which the portfolio is constructed from a relatively few number of assets (for example, less than 30) then each evaluation of another interpolation points will be very rapid and hence as long as the total number of interpolation points which you wish to use over the total range is reasonable (i.e. less than 30) then the evaluation of the Efficient Frontier will take a few seconds. However, if you are considering a larger number of assets (for example, more than 80) then you may wish to considered only a proportion of the Efficient Frontier (i.e. a smaller range of expected values) so that you will need to evaluate of fewer number of interpolation points in order to construct the Efficient Frontier over that range to the desired level of accuracy.
Remark: The computational time increase in proportion to the number interpolation points returned.
Number of Interpolation Points used to represent the Efficient Frontier
The Efficient Frontier is persisted (i.e. stored) as the collection of points around which it is interpolated. Therefore, the more interpolation points used within this method the more accurately it will be stored. However, within the construction of the Efficient Frontier the main optimization algorithm is called when each interpolation point is evaluated. Therefore, in terms of performance the computational time required for the construction of the Efficient Frontier will increase in proportion to the number of points used.
As a rule of thumb I would suggest that the number of interpolation points used is chosen within the range [5,20]. The rational being that if less than five interpolation points are used then unreasonable amounts of qualitative information concerning the Efficient Frontier will be lost. Also, if more than twenty interpolation points are used then (generally speaking) no significant improvement in the accuracy will result.
Methods which directly depend on this method
The result of this method is stored in one of this classes private fields. The setting of this private field (that is, the calling of this method) is required in order to use the following methods:
expectedReturnEfficientFrontier - Evaluates the expected
returns of the portfolios at the points at which the Efficient Frontier is known.
assetWeightsEfficientFrontier - Evaluates the asset weights
of a portfolios at the points at which the Efficient Frontier is known.
portfolioRisksEfficientFrontier - Evaluates the risks of
the portfolio at the points at which the Efficient Frontier is known.
getPointsOnEfficientFrontier - Returns the type
PointsOnEfficientFrontier which contains information concerning the risks, expected returns, and
asset weights of the portfolios at the points at which the Efficient Frontier is known.
efficientFrontier(double, int) - Evaluates the asset weights of the portfolio at an arbitrary
point of the Efficient Frontier via interpolation.
optimalPortfolio - Evaluates the optimal portfolio(s) on the Efficient
Frontier with respect to the Investors Utility function.
optimalPortfolioMaxExpected - Evaluates the optimal portfolio
on the Efficient Frontier selected by the Investors Utility function with the highest expected return.
Remark: If any of these four methods are called without calculating the interpolation points first an exception will be thrown.
Evaluation of the Covariance matrix and Expected Returns
You are required to provide to this method the covariance matrix and the expected returns of the
collection of asset from which the portfolio's on the Efficient Frontier are constructed. We provide
within the AssetParameters class procedures which assist in there evaluation of the
covariance matrix and the expected returns via either a historical or scenario approach.
minimumExpectedReturn - the minimum expected return for which the Efficient Frontier is evaluated. If you require the entire Efficient Frontier to be evaluated then you may set this parameter to be equal to the return of the assets with the minimum return. Note that this parameter should be given as in relative (where 1 percent = 1), or absolute terms in accordance with the units used for the expected returns parameter.maximumExpectedReturn - the maximum expected return for which the Efficient Frontier is evaluated. If you require the entire Efficient Frontier to be evaluated then you may set this parameter to be equal to the return of the assets with the maximum return. Note that this parameter should be given as in relative (where 1 percent = 1), or absolute terms in accordance with the units used for the expected returns parameter.covarianceMatrix - the covariance matrix of the assets from which the (optimal) portfolio can be constructed. The dimensions of the (symmetric) covariance matrix will be n X n, where n is the number of assets from which the (optimal) portfolio can be constructed.expectedReturns - the array of the expected returns of the assets from which the (optimal) portfolio can be constructed. Where the k-th term of the array will correspond to the return from the k-th asset. Please note that the expected returns of the assets can be given in absolute (i.e. final market price) or relative terms (i.e. percentage changes), however which ever convention is used it the same convention should be used for the other parameters which depend on the expected returns.numberInterpolationPoints - the number of interpolation points for which the Efficient Frontier is calculated. Note that these interpolation points lie within the interval bound by the minimum and maximum expected returns set and be equally dispersed within this interval. Moreover, in all case one of the interpolation points will lie of the minimum expected return set and another will lie on the maximum expected return set.precision - this parameters allow the level of the precision required to be set, where the small the parameters the (generally) higher the precision. This variable should be chosen between the range 1E-8 and 1E-12. Note as with most numerical procedures the higher the precision the more computationally intensive the algorithm will become. The precision must be set to be a positive number less than 1; where a number of the magnitude 1E-12 will result in high precision and a number of the magnitude 1E-8 will result in rapid execution and acceptable precision for most purposes. Further details are provided within the Programmer's guide chapter of the PDF documentation.
NoSolutionException - thrown if this method attempts to construct a portfolio on the Efficient
Frontier for an expected return for which there does not exist such a portfolio. In such instances
the range of expected returns over which the Efficient Frontier is constructed should be reduced. Please
see the remarks above on the selection of a suitable range of expected returns.
MarkowitzDemoException
public void calculateEfficientFrontier(double[][] covarianceMatrix,
double[] expectedReturns,
int numberInterpolationPoints,
double precision)
throws MarkowitzDemoException
calculateEfficientFrontier by setting the range of the expected returns over which the Efficient Frontier
is evaluated to be the entire range over which the (constrained) Efficient Frontier exists.
For more details
concerning the issues effecting the constraints, efficiency, number of interpolation points use and so on...;
we refer the reader to the documentation for the method
calculateEfficientFrontier.
As mentioned above the only difference with the aforementioned method at that here the range of expected returns
have been set in the fashion as detail below.
Range of Expected Returns
The range over which the (constrained) Efficient Frontier is evaluated can be evaluated by using
the methods minFrontierReturn, maxFrontierReturn;
in order to evaluate the minimum and maximum of the continuous range of the expected return over which
the Efficient Frontier exists for the given set of assets considered. Note that with this procedure
we have set the range over which the Efficient Frontier is constructed to be equal to this largest
possible range.
covarianceMatrix - the covariance matrix of the assets from which the (optimal) portfolio can be constructed. The dimensions of the (symmetric) covariance matrix will be n X n, where n is the number of assets from which the (optimal) portfolio can be constructed.expectedReturns - the array of the expected returns of the assets from which the portfolios can be constructed. Where the k-th term will correspond to the percentage return (i.e. 1 percent = 1) or the absolute return of the k-th asset, depending on the convention used, of the set of assets from which the Portfolios (on the Efficient Frontier) can be constructed.numberInterpolationPoints - the number of interpolation points for which the Efficient Frontier is calculated. Note that these interpolation points lie within the interval bound by the minimum and maximum expected returns set and be equally dispersed within this interval. Moreover, in all case one of the interpolation points will lie of the minimum expected return set and another will lie on the maximum expected return set.precision - this parameters allow the level of the precision required to be set, where the small the parameters the (generally) higher the precision. This variable should be chosen between the range 1E-2 and 1E-10. Note as with most numerical procedures the higher the precision the more computationally intensive the algorithm will become. The precision must be set to be a positive number less than 1; where a number of the magnitude 1E-6 will result in high precision and a number of the magnitude 1E-3 will result in rapid execution and acceptable precision for most purposes. Further details are provided within the Programmer's guide chapter of the PDF documentation.
MarkowitzDemoException
public double[] expectedReturnEfficientFrontier()
throws MarkowitzDemoException
portfolioRisksEfficientFrontier you are able to plot the Efficient Frontier
for a set on points where the expected returns are plotted against the total risk.
Moreover, by interpolating this set of points using Interpolation
we are able to evaluate the coordinate values of the expected return and risk at an
arbitrary point of the Efficient Frontier.
Stateful Nature of this Method
Before this method is called you are required to evaluate the Efficient
Frontier by using the method calculateEfficientFrontier.
MarkowitzDemoExceptionassetWeightsEfficientFrontier - this associated method evaluates the corresponding
weights of the assets of the corresponding portfolios on the Efficient Frontier.
,
portfolioRisksEfficientFrontier - this associated method evaluates the corresponding
risks of the portfolios at the set of points at which the Efficient Frontier is known.
,
Interpolation class offers methods which allow the Efficient Frontier to
be constructed from a finite set of known points. Note that the most widely method by which
this is performance and the internal interpolation procedure used here is cubic spline
interpolation.
public double[][] assetWeightsEfficientFrontier()
throws MarkowitzDemoException
The returned array of dimension two has the following form. For the set of
points for which the Efficient Frontier is known the i-th point
where the 1-st point is the point corresponding to the portfolio
with the lowest expected return and the 2-nd point corresponds to
the portfolio with the next to lowest expected return and so on; portfolios
asset weights are given by returned[i], where return
is the array of dimension two returned by this method.
Stateful Nature of this Method
Before this method is called you are required to evaluate the Efficient
Frontier by using the method calculateEfficientFrontier.
MarkowitzDemoExceptionportfolioRisksEfficientFrontier - this associated
method evaluates the corresponding risks of the portfolios at the set of points at which the
Efficient Frontier is known.
,
expectedReturnEfficientFrontier - this associated
method evaluates the corresponding values of the expected returns of the portfolios on the
Efficient Frontier.
public double[] portfolioRisksEfficientFrontier(double[][] covarianceMatrix)
throws MarkowitzDemoException
Stateful Nature of this Method
Before this method is called you are required to evaluate the Efficient
Frontier by using the method calculateEfficientFrontier.
covarianceMatrix - the covariance matrix of the assets from which the (optimal) portfolio can be constructed. The dimensions of the (symmetric) covariance matrix will be n X n, where n is the number of assets from which the (optimal) portfolio can be constructed.
MarkowitzDemoExceptionassetWeightsEfficientFrontier - this associated
method evaluates the corresponding weights of the assets of the corresponding
portfolios on the Efficient Frontier.,
expectedReturnEfficientFrontier - this
associated method evaluates the corresponding values of the expected returns
of the portfolios on the Efficient Frontier.,
Interpolation - within this class we offer methods which allow
the Efficient Frontier to be constructed from a finite set of known points. Note
that the most widely method by which this is performance and the internal
interpolation procedure used here is cubic spline interpolation.
public PointsOnEfficientFrontier getPointsOnEfficientFrontier()
throws MarkowitzDemoException
PointsOnEfficientFrontier which
represents points on the Efficient Frontier. That is, it represents a collection
of portfolios which offer the lowest risk for a given expected return. The
PointsOnEfficientFrontier represents the portfolios on the Efficient
Frontier by storing within a complex type the following:
Remarks:
PointsOnEfficientFrontier which contains information
concerning the risks, expected returns, and asset weights of the portfolios at
the points at which the Efficient Frontier is known. Note that the units in which
the expected returns will be given will correspond to the units which where used
(i.e. relative or absolute) in the evaluation of the Efficient Frontier.
MarkowitzDemoException
public double[] efficientFrontier(double expectedReturn,
int numberOfAssets)
throws EfficientFrontierNotCalculatedException,
MarkowitzDemoException
Stateful Nature of this method
This method is stateful because it requires that the interpolation points of the
Efficient Frontier have already been evaluated by first called the method calculateEfficientFrontier.
Once the Efficient Frontier has been evaluated we are able to very efficiently evaluate
the weights of the optimal portfolio for the range of expected returns considered. The reason
being that the Efficient Frontier has already be constructed and here we are just `reading of'
optimal portfolios within the range of expected returns consider which lie on the Efficient
Frontier.
Setting Constraints on the weights of the Assets
By default the weights of the assets from which the portfolios on the Efficient Frontier
can be constructed can take any value within the closed interval [0,1].
However you are able to set an upper and lower constraint on each on the weights by called
the method setConstraints(double[], double[]) behind constructing the Efficient Frontier by calling
calculateEfficientFrontier(double, double, double[][], double[], int, double), after which this method may be called.
Suitable values of the Expected Return Parameter
For a given set of assets with possibly constrained asset weights there will correspond
a range of values of the expected return over which the (constrained) Efficient Frontier
exists. Naturally the value of the expected return about which the Efficient Frontier is
evaluated must lie within this range. You are able to evaluate this continuous range of
expected returns for which the Efficient Frontier exists by calling the methods
minFrontierReturn(double[]) and maxFrontierReturn(double[]), in order to evaluate the upper
and lower bounds respectively. If you are considering the constrained case then the
constraints should be set (by calling setConstraints(double[], double[])) before the range of the
expected returns are evaluated.
expectedReturn - the value of the expected return for which the Efficient Frontier is evaluate and the optimal portfolio (i.e. the portfolio with the lower risk) asset weights are returned. Please note that the units in which the expected return is given should correspond to the units used (i.e. relative or absolute) used in order to evaluate the Efficient Frontier.numberOfAssets - the number of assets from which the (optimal) portfolio is constructed, or equivalently the number of assets from which portfolios on the Efficient Frontier can be constructed.
EfficientFrontierNotCalculatedException - thrown if the Efficient Frontier is not calculated.
In order to evaluate the Efficient Frontier please call the method calculateEfficientFrontier(double, double, double[][], double[], int, double)
and then call this method again.
NoSolutionException - thrown if there are no portfolios with the desired value of the expected return
within the Efficient Frontier constructed. If there exists a portfolio which can be constructed from
the given collection of assets for the given desired expected return. Which is equivalent to asking
whether there exists an asset within the collection of assets from which the portfolios can be constructed
which has an expected return which is greater than or equal to the expected return of the portfolio desired.
If this is the case then the Efficient Frontier should be re-evaluated using
calculateEfficientFrontier which a range of expected returns
including the desired point, after which this method should be reapplied. If this is not the case
then you will need additional assets to be included within the collection of assets from which
the portfolio can be constructed which have an expected return which is greater than or equal
to the expected return desired. When these asset(s) have been made available then you will be
able to evaluate the Efficient Frontier on a range of value of the expected return which
includes the desired point using calculateEfficientFrontier
after which you will be able to reapply this method.
MarkowitzDemoExceptioncalculateEfficientFrontier - this method must be called
previously in order to evaluate the Efficient Frontier.
public void setConstraints(double[] lowerBounds,
double[] upperBounds)
throws MarkowitzDemoException
Methods effected by the setting of constraints on the Asset Weights
The methods within this class which are effected and how they are effected by the setting of constraints on the weights of the assets from which the portfolios are constructed is given below:
calculateEfficientFrontier - Each portfolio on the
Efficient Frontier must satisfy the constraints on the assets.
expectedReturnEfficientFrontier - Reads the
expected returns of the evaluated constrained portfolios on the constrained Efficient Frontier.
assetWeightsEfficientFrontier - Reads the asset
weights of the evaluated constrained portfolios on the constrained Efficient Frontier.
portfolioRisksEfficientFrontier - Reads the portfolios risk of the evaluated
constrained portfolios on the constrained Efficient Frontier.
getPointsOnEfficientFrontier - Reads the portfolios risk, weights and expected
returns of the evaluated (constrained) portfolios on the (constrained) Efficient Frontier.
efficientFrontier(double,int) - Returned the constrained portfolio which a given expected
return on the constrained Efficient Frontier.
efficientFrontier(double, double[][], double[], double) - Returns the weights of the constrained asset of
a portfolio on the constrained Efficient Frontier.
optimalPortfolio - Returns the set of constrained portfolios on the constrained
Efficient Frontier in accordance with the investors utility function.
optimalPortfolioMaxExpected - Returned the constrained portfolio with the maximum
expected return of the portfolio which where selected in accordance with the investors utility
function.
Nature of the Constraints
We illustrate the nature of the constraints with the following example. Say an
investor requires a portfolio selected from n asset which has the
lowest risk for a given expected return but also has the requirement that all of
the assets must have a weight between 0.05 and 0.1
(i.e. between 5 and 10 percent). In this instance we would set the constraints
on the assets to be:
lowerBounds = {0.05, 0.05, 0.05,...., 0.05}
upperBounds = {0.1, 0.1, 0.1, ......, 0.1}
where each of the arrays above has the same number of terms of the number of assets.
Constraints have Default Values
If the constraints are not set then they will take there default values which are
0 and 1, for the lower and upper bound respectively for
each asset weight.
Performance Issues
The introduction of constraints on the weights of the portfolios which form the Efficient Frontier will have the following consequences with regards to overall performance:
1 (i.e. there default value), then they will not effect the computational demands
required to evaluate the points on the Efficient Frontier. This allows lower bounds to be set
on the asset weight without reducing the performance of this class.
Remarks:
[0,1].
Motivation and Definition of Consistent Asset Constraints
Say that we wish to use place the following `constraints' on a portfolio which can be constructed from 3 assets:
lower bounds = {0.4, 0.4, 0.4}
upper bounds = {0.5, 0.5, 0.5}
1, there is no `consistent'
portfolio which can be constructed which satisfies these constraints and the
definition of the weight. Since even if we take the lower bounds for each of the
three assets the sum of the weights is greater than 1 (i.e.
0.4 + 0.4 + 0.4 = 1.2 > 1).
Similarly, say we wish to use the following set of constraints:
lower bounds = {0.2, 0.2, 0.2}
upper bounds = {0.3, 0.3, 0.3}
1. Since even if we take the upper bounds for each
of the three assets the sum of the weights is less than 1 (i.e.
0.3 + 0.3 + 0.3 = 0.9 < 1).
For these reason reasons we introduce the following property of `consistent constraints':
Definition: A set of upper and lower bound asset constraints of a portfolio are said to be
consistent if the sum of the lower bounds is less than or equal to 1, and the sum
of the upper bounds is greater than or equal to 1.
Without the `consistent constraint' condition there will not exist any possible selections of the asset weights which satisfy the constraints and the definition of the asset weights, i.e. the domain of possible portfolios will be empty. Therefore this condition of consistency of the constraints is mandatory for any set of constraints used within the construction of the constrained Portfolios on the constrained Efficient Frontier.
Constraints on the Asset Weights effect on the range of the Expected Returns for which the Efficient Frontier exists
The placing of constraints on the weights of the assets effects the range of expected returns for which the resulting portfolios can be constructed. Since the (constrained) Efficient Frontier is just a collection of portfolios subject also subject to the constraints which minimize the risk for a given level of the expected return. The range of values over which the Efficient Frontier exists must correspond to the range of expected returns of the possible constructed portfolios.
Within the methods maxFrontierReturn(double[]), and minFrontierReturn(double[]) we allow the maximum
and respectively minimum values of the expected return over which the (possibly constrained) Efficient
Frontier exists. We also offer two associated methods maxFrontierReturnWeights(double[]) and
minFrontierReturnWeights(double[]), which evaluate the assets weights of the portfolio at these
two ends points. These methods which construct the Portfolios on the Efficient Frontier at its
end points have the significant advantage of having almost no computational overhead, unlike
the construction of the portfolios on the Efficient Frontier at other points.
lowerBounds - an array where the i-th term corresponds to the lower bound on the weights (i.e. lies in the closed interval [0,1]) of the i-th asset from the collection of assets from which the portfolios can be constructed. Note that the length of this array must equal the number of assets from which the portfolios can be constructed.upperBounds - an array where the i-th term corresponds to the upper bound on the weights (i.e. lies in the closed interval [0,1]) of the i-th asset from the collection of assets from which the portfolios can be constructed. Note that the length of this array must equal the number of assets from which the portfolios can be constructed.
MarkowitzDemoException
public double[] getLowerConstraints()
throws MarkowitzDemoException
setConstraints. We return an array where the k-th term
of the array corresponds to the lower bound on the k-th asset's weight.
MarkowitzDemoException
public double[] getUpperConstraints()
throws MarkowitzDemoException
setConstraints. We return an array where the k-th term
of the array corresponds to the upper bound on the k-th asset's weight.
MarkowitzDemoException
public double minFrontierReturn(double[] expectedReturns)
throws MarkowitzDemoException
Advantage of this approach
The distinct advantage of this approach is that in conjunction with the method
minFrontierReturnWeights we are able to evaluate
a point (at the lower end of the extremum of the expected returns) corresponding to
a portfolio on the Efficient Frontier. Where unlike the situation with the optimization
procedures calculateEfficientFrontier and
efficientFrontier we are able to do so with almost no
computational overhead.
expectedReturns - the array of the expected returns of the assets in absolute or relative terms from which the portfolios can be constructed. Where the k-th term corresponds to the expected return of the k-th asset.Note that the units used for the expected return will determine the units of the returned result. Hence, when using this method in conjunction with (double, double, double[][], double[], int, double) calculateEfficientFrontier, for example it is important to ensure that the units for the expected return are used consistently throughout a given application.
MarkowitzDemoExceptionminFrontierReturnWeights(double[])
public double[] minFrontierReturnWeights(double[] expectedReturns)
throws MarkowitzDemoException
Advantage of this approach
The distinct advantage of this approach is that in conjunction with the method
minFrontierReturn we are able to evaluate
a point (at the lower end of the extremum of the expected returns) corresponding to
a portfolio on the Efficient Frontier. Where unlike the situation with the optimization
procedures calculateEfficientFrontier and efficientFrontier
we are able to do so with almost no computational overhead.
expectedReturns - the array of the expected returns of the assets in absolute or relative terms from which the portfolios can be constructed. Where the k-th term corresponds to the expected return of the k-th asset. Note that the units used for the expected return will determine the units of the returned result. Hence, when using this method in conjunction with (double, double, double[][], double[], int, double) calculateEfficientFrontier, for example it is important to ensure that the units for the expected return are used consistently throughout a given application.
MarkowitzDemoExceptionminFrontierReturn(double[])
public double maxFrontierReturn(double[] expectedReturns)
throws MarkowitzDemoException
Advantage of this approach
The distinct advantage of this approach is that in conjunction with the method
minFrontierReturnWeights we are able to evaluate
a point (at the upper end of the extremum of the expected returns) corresponding to
a portfolio on the Efficient Frontier. Where unlike the situation with the optimization
procedures calculateEfficientFrontier and
efficientFrontier we are able to do so with almost no
computational overhead.
expectedReturns - the array of the expected returns of the assets in absolute or relative terms from which the portfolios can be constructed. Where the k-th term corresponds to the expected return of the k-th asset. Note that the units used for the expected return will determine the units of the returned result. It is also important to point out that within any application the units for the expected returns should be used consistently throughout.
MarkowitzDemoExceptionmaxFrontierReturnWeights(double[])
public double[] maxFrontierReturnWeights(double[] expectedReturns)
throws MarkowitzDemoException
Advantage of this approach
The distinct advantage of this approach is that in conjunction with the method
minFrontierReturn we are able to evaluate
a point (at the upper end of the extremum of the expected returns) corresponding to
a portfolio on the Efficient Frontier. Where unlike the situation with the optimization
procedures calculateEfficientFrontier and
efficientFrontier we are able to do so with almost no
computational overhead.
expectedReturns - the array of the expected returns of the assets in absolute or relative terms from which the portfolios can be constructed. Where the k-th term corresponds to the expected return of the k-th asset. Note that the units used for the expected return will determine the units of the returned result. It is also important to point out that within any application the units for the expected returns should be used consistently throughout.
MarkowitzDemoExceptionmaxFrontierReturn(double[])
public double[] efficientFrontier(double expectedReturn,
double[][] covarianceMatrix,
double[] expectedReturns,
double precision)
throws NoSolutionException,
MarkowitzDemoException
[0,1], but you are able to set constraints
for the asset weights by first calling the method setConstraints(double[], double[]).
Unique Features of this Method
Note that though this method is stateless, it is not just a stateless version on the
method efficientFrontier(double, int). In fact this method significantly differs
in that it directly applies minimization algorithms at the desired point and so though it
can be slower than efficientFrontier(double, int), it has the following two distinct
advantages:
calculateEfficientFrontier.
Suitable values of the Expected Return Parameter
For a given set of assets with possibly constrained asset weights there will correspond
to a range of values of the expected return over which the (constrained) Efficient Frontier
exists. Naturally the value of the expected return about which the Efficient Frontier is
evaluated must lie within this range. You are able to evaluate this continuous range of
expected returns for which the Efficient Frontier exists by calling the methods
minFrontierReturn(double[]) and maxFrontierReturn(double[]), in order to evaluate the upper
and lower bounds respectively. If you are considering the constrained case then the
constraints should be set (by calling setConstraints(double[], double[])) before the range of the
expected returns are evaluated.
Evaluation of the Covariance matrix and Expected Returns
You are required to provide as parameters for this method the covariance matrix and the expected
returns of the collection of assets from which the portfolio's on the Efficient Frontier are constructed.
We provide within the AssetParameters class offers procedures which assist in the evaluation
of the covariance matrix or the expected returns using either a historical or scenario based approach.
expectedReturn - the expected return of the portfolio (on the Efficient Frontier) which will be returned. The expected return should be given in relative or absolute terms in accordance with the units used for the given expected returns of the assets from which the portfolio can be constructed.covarianceMatrix - the covariance matrix of all assets from which the (optimal) portfolio can be constructed. We provide methods within the AssetParameters class methods which estimates the expected returns by a historical or scenario based approach.expectedReturns - the array of the expected returns of the assets in absolute or relative terms from which the portfolios can be constructed. Where the k-th term corresponds to the expected return of the k-th asset. Note that the units used for the expected return will determine the units of the returned result. It is also important to point out that within any application the units for the expected returns should be used consistently throughout.precision - this parameters allow the precision required to be set. The higher the precision the more computationally intensive the algorithm will become. The precision must be set to a positive number less than 1; where a number of the magnitude 1E-6 will result in high precision and a number of the magnitude 1E-3 will result in rapid execution. Further details are provided within the Programmer's guide chapter of the PDF documentation.
NoSolutionException - thrown if there are no portfolios with the desired value of the expected return
within the Efficient Frontier constructed. Since this method is direct this means that there does not
exists a portfolio which can be constructed from the given collection of assets for the given desired
expected return. Which means that there does not exist an asset within the collection of assets from
which the portfolios can be constructed which has an expected return which is greater than or equal
to the expected return of the portfolio desired. In order to be able to construct a portfolio with
the desired level of expected return you will need additional assets to be included within the collection
of assets from which the portfolio can be constructed which have an expected return which is greater
than or equal to the expected return desired. When these asset(s) have been made available you will be
able to construct the required on the (new) Efficient Frontier by reapplying this method.
MarkowitzDemoException
public void setUtilityFunctionInterp(double[] expectedReturn,
double[] totalRisk)
throws MarkowitzDemoException
The Role of the Utility Function
The construction of a portfolio with regard to an investors risk - reward profile lies at the core of portfolio theory. The utility function assigns a value judgment to the various risk - reward combinations which will be available to the investor. If we where not aware of a given investors risk preferences then it would not be possible to select a preferred portfolio on the Efficient Frontier. However, if we know information such as the maximum amount of risk which the investor will accept then we can select the portfolio on the Efficient Frontier which corresponds to this level of risk. The utility function offers much more fine grained information concerning this investors risk preferences and allows a value judgment to be assign to various risk-rewards combinations.
Providing the Investors Utility Function
As mentioned above the utility function is generated by interpolating a tabulated
function which is provided as two arrays. The first array corresponds to an ordered sequence
of the various total risk levels of the portfolio and is denote by x[0..,n - 1]
(with x[0] < x[1] < ... < x[n - 1]). The first term of the second array
corresponds to the expected return for the total risk x[0]. The second term of the
second array corresponds to the expected return for the total risk x[1]. The third
term is defined in a similar fashion and so on. This provides n coordinate points
or equivalently a tabulated function which we can interpolate in order to provide a unique utility
function which expresses the investors risk-reward profile.
Finding the investors risk-reward profile in practice
The investors risk-reward utility function is the locus of points at which the investor gets a particular level of satisfaction or utility from a combination of expected return and risk. Clearly, each investor will have their own utility function depending on their individual trade-off between expected return and risk.
Below we give three examples of utility functions interpolation points which correspond to investors
which exhibits a relatively low, medium and high risk tolerance. Each utility function is given on
five points represented a pairs of the form (reward, risk):
(1, 0.1), (2, 0.25, (3, 0.3), (4, 0.45), (5, 0.5)
(1, 0.3), (2, 0.5), (3, 1), (4, 2), (5, 2.2)
(1, 0.75), (2, 1), (3, 2), (4, 3), (5, 4)
The above returns and risk correspond to monthly expected return and corresponding risk with the three investors are prepared to accept.
The relationship between the Interpolation and Polynomial methods of setting the Utility Function
The utility function besides being given as a set of points which are then interpolations can also be
given as a polynomial expression, see setUtilityFunctionPoly. Below we
detail the relationship between these two means of setting the investors utility function.
Note that the two means of setting the utility function namely the interpolation and polynomial procedures are closely related. Moreover we are able to roughly map between these two means of representing the investors utility function in the follow way.
If the interpolation points are known at (xi, yi), for i = 0, 1, ..., n-1
then we can construct the utility function given as a polynomial of order n, by solving the
following n polynomial expressions which will allow us to deduce to values of the coefficients
of the polynomial which takes the same values at the interpolation points:
p(xi) = coefficient[0] + (coefficient[1] * xi) + ... + (coefficient[n-1] * xin-1)
where i = 0, ..., n. Alternatively, if we are given a polynomial p(x) = y, which
represents the utility function of the investor then we are able to read off the interpolation points
at xi, i= 0, ..., n-1, by which the utility function can be defined in accordance with
the interpolation approach. That is, the interpolation points (xi, yi), for
i = 0, 1, ..., n-1, for some xi, i= 0, ..., n-1, are given by:
p(xi) = yi
where i= 0, ..., n-1.
The above procedure illustrates that there is a close relationship between the polynomial and interpolation
ways of defining the utility function. However care should be taken to point out that though they are closely related
they are not equivalent. The reason for this is that the interpolation method uses cubic spline interpolation
in order to construct the utility function from the interpolation points. The polynomial method is general used an
n degree polynomial in order to define the utility function. Therefore, except in the case of the polynomial
method using a cubic polynomial these two approaches can not represent a utility curve which is identical for all
points. However, in practice the above procedure will result in a polynomial and interpolation representation
which agrees on the interpolation points and is generally qualitatively and quantitatively very close for non-interpolation
points.
totalRisk - an array of doubles where the i-th term is the value of the total risk at the i-th interpolation point around which the Investors Utility function is given.expectedReturn - an array of doubles where to i-th term is the value of the expected return at the i-th interpolation points around which the Investors Utility function is given. The expected returns may be given in absolite (i.e. market price) or relative (i.e. percentage) terms. However it is important that the units used here for the expected returns are in accordance with the units used within other methods calls for example calls to calculateEfficientFronrtier, which a given client application.
MarkowitzDemoException
public void setUtilityFunctionPoly(double[] coefficient)
throws MarkowitzDemoException
setUtilityFunctionInterp by which
the utility function can be given. We refer to the polynomial approach as an alternative
approach since for most investors it will be more natural to give the utility function as a
set of risk-rewards sweet spots (around which the utility function is interpolated).
Structure of the polynomial which defines the Utility Function
The polynomial which defines the investors utility function takes the following form:
p(x) = coefficient[0] + (coefficient[1] * xi) + ... + (coefficient[n-1] * xn-1)
where the coefficients[i], i = 0, ..., n-1 are given as a parameter. Now within this representation
the values at the variable x, corresponds to the risk level of a polynomial and the corresponding
value of p(x), is the value of the expected return which to investors demands in order to be
exposed to the chosen level of risk.
The relationship between the Interpolation and Polynomial methods of setting the Utility Function
Note that the two means of setting the utility function namely the interpolation and polynomial procedures are closely related and move over we are able to roughly map between these two means of representing the investors utility function.
If the interpolation points are known at (xi, yi), for i = 0, 1, ..., n-1
then we can construct the utility function given as a polynomial of order n, by solving the
following n polynomial expressions which will allow us to deduce to values of the coefficients
of the polynomial which takes the same values at the interpolation points:
p(xi) = coefficient[0] + (coefficient[1] * xi) + ... + (coefficient[n-1] * xin-1)
where i = 0, ..., n. Alternatively, if we are given a polynomial p(x) = y, which
represents the utility function of the investor then we are able to read off the interpolation points
at xi, i= 0, ..., n-1, by which the utility function can be defined in accordance with
the interpolation approach. That is, the interpolation points (xi, yi), for
i = 0, 1, ..., n-1, for some xi, i= 0, ..., n-1, are given by:
p(xi) = yi
where i= 0, ..., n-1.
The above procedure illustrates that there is a close relationship between the polynomial and interpolation
ways of defining the utility function. However care should be taken to point out that though they are closely
related they are not equivalent. The reason for this is that the interpolation method uses cubic spline
interpolation in order to construct the utility function from the interpolation points. The polynomial method
in general uses an n degree polynomial in order to define the utility function. Therefore, except
in the case of the polynomial method using a cubic polynomial these two approaches can not represent a utility
curve which is identical for all points. However, in practice to above procedure will result in a polynomial
and interpolation representation which agrees on the interpolation points and is generally qualitatively and
quantitatively very close for non-interpolation points.
coefficient - an array of coefficients of the polynomial (as described above) which defines the Investors Utility function.
MarkowitzDemoException
public double[][] optimalPortfolio(double minimumExpectedReturn,
double maximumExpectedReturn,
double[][] covarianceMatrix)
throws PortfolioException,
MarkowitzDemoException
Utility Function
Recall that the utility function represents the investors preferred risk-return
profile which is in accordance with the investors expressed preferences. The utility
function must be set before called this methods by using one of the methods
setUtilityFunctionPoly, or setUtilityFunctionInterp.
Returned set of Portfolios
This method returns a array of dimension 2, which represents these optimal portfolios
which where selected from the Efficient Frontier by the investors utility function.
The array of dimension 2, has the following form: the first term in the array of dimension
2 (i.e. result[0]) is an array which contains the weights of the assets of the
first optimal portfolio selected from the Efficient Frontier, the second term in the array
of dimension 2 (i.e. result[1]) is an array which contains the weights of the
assets of the second optimal portfolio and so on. The number of optimal portfolios found
will correspond to the length of the 2 dimensional array returned.
Methods which should be called Prior to this method
Prior to calling this method you must calculate the Efficient Frontier with
calculateEfficientFrontier and set the investors
utility function using one of setUtilityFunctionPoly
or setUtilityFunctionInterp.
Remark: Care should be taken to ensure that the range over which the Efficient Frontier is evaluated and the investors utility function are given covers the range of the expected returns over which the optimal portfolios are sort.
Setting Constraints on Asset Weights
By default the weights of the assets can take any values within the range [0,1],
however you are able to set upper and lower constraints on each on the weights by called
the method setConstraints before the Efficient Frontier is constructed using
calculateEfficientFrontier.
When the Investors Utility Function does not cross the Efficient Frontier
This methods find the set of optimal portfolio by finding the points at which the Efficient Frontier and the investor's utility function cross. If over the considered range of the expected returns the two curves do not cross then either the investors utility function is above or below the Efficient Frontier over the range of expected returns considered. In these two cases one of the following two exceptions will be thrown:
In the case when the AboveException is thrown the follow two modifications of the problem are equally justified:
setUtilityFunctionInterp or
setUtilityFunctionPoly. Once the investors
utility function has been reset this methods can be re-applied.
Suitable values of the Expected Return Parameter
For a given set of assets with possibly constrained asset weights there will correspond
a range of values of the expected return over which the (constrained) Efficient Frontier
exists. Naturally the range of the expected return about which the optimal portfolios are sort
since these optimal portfolios lie on the Efficient Frontier must lie within this range in which
the Efficient Frontier exists. You are able to evaluate this continuous range of expected returns
for which the Efficient Frontier exists by calling the methods minFrontierReturn(double[]) and
maxFrontierReturn(double[]), in order to evaluate the upper and lower bounds respectively. If you
are considering the constrained case then before evaluating the range of the expected returns for
which the Efficient Frontier exists you should have set the constraints on the asset weights by
scaling setConstraints(double[], double[]).
minimumExpectedReturn - the minimum expected return of the range over which the optimal portfolio(s) in accordance with the investors utility function are sort. The expected return should be given in absolute (i.e. market price) or relative (i.e. percentage) terms in accordance with the units used for the expected returns within the evaluation of the Efficient Frontier.maximumExpectedReturn - the maximum expected return of the range over which the optimal portfolio(s) in accordance with the investors utility function are sort. s The expected return should be given in absolute (i.e. market price) or relative (i.e. percentage) terms in accordance with the units used for the expected returns within the evaluation of the Efficient Frontier.covarianceMatrix - the covariance matrix of the collection of assets from which the (optimal) portfolio can be constructed.
EfficientFrontierNotCalculatedException - thrown if the Efficient Frontier is not been
constructed. That is, the method calculateEfficientFrontier
has not been called. In order remedy the situation please evaluated the Efficient Frontier
using the method calculateEfficientFrontier over a range of
expected returns equal to or larger than the range considered her over which the optimal portfolio
is sort. Once this process is complete you may re-apply this method.
UtilityFunctionNotInitializedException - thrown if Investors Utility function is not set.
In order to set the Investors Utility function you will need to call one of the methods:
setUtilityFunctionInterp or setUtilityFunctionPoly.
Note that the range of the expected returns over which the Investors Utility function is given
should be equal to or larger than the range of expected return used here over which the optimal
portfolio is sort. Once the Investors Utility function has been set of a suitable range you
will be able to re-apply this method.
AboveException - thrown if the investors utility function is above the Efficient Frontier
for all values of the expected return (see above remarks for further explanation).
BelowException - thrown if the investors utility function is below the Efficient Frontier
for all values of the expected return (see above remarks for further explanation).
PortfolioException - thrown if the number of optimal portfolios found is more than 100.
In this instance the investors utility function is probably very close if not identical to the
Efficient Frontier over at least a section of the range of the expected returns considered.
To address this issue to utility function should be refined so that it is more clearly
distinguishable from the Efficient Frontier. Since it is very likely that modulo interpolation
errors the utility function is identical to the Efficient Frontier over a section of the
expected returns considered which causes the method at present in principal to fail. Anyway,
once the Investors Utility function has been refined you will be able to re-apply this method.
MarkowitzDemoException
public double[][] optimalPortfolio(double[][] covarianceMatrix,
double[] expectedReturns)
throws PortfolioException,
MarkowitzDemoException
optimalPortfolio(double, double, double[][]), where the minimum and maximum range of
the expected returns are set in accordance with the methods
maxFrontierReturn and minFrontierReturn.
Remarks:
optimalPortfolio(double, double, double[][]).
For further details concerns the construction of the optimal portfolios we refer the reader
to the documentation of optimalPortfolio(double, double, double[][]).
covarianceMatrix - the covariance matrix of the collection of assets from which the (optimal) portfolio can be constructed.expectedReturns - the array of the expected returns of the assets in absolute or relative terms from which the portfolios can be constructed. Where the k-th term corresponds to the expected return of the k-th asset. Note that the units used for the expected return will determine the units of the returned result. It is also important to point out that within any application the units for the expected returns should be used consistently throughout.
PortfolioException - thrown if the number of optimal portfolios found is more than 100.
In this instance the investors utility function is probably very close if not identical to the
Efficient Frontier over at least a section of the range of the expected returns considered.
To address this issue to utility function should be refined so that it is more clearly
distinguishable from the Efficient Frontier. Since it is very likely that modulo interpolation
errors the utility function is identical to the Efficient Frontier over a section of the
expected returns considered which causes the method at present in principal to fail. Anyway,
once the Investors Utility function has been refined you will be able to re-apply this method.
MarkowitzDemoException
public double[] optimalPortfolioMaxExpected(double minimumExpectedReturn,
double maximumExpectedReturn,
double[][] covarianceMatrix)
throws PortfolioException,
MarkowitzDemoException
Further Illustration
Once the investors utility function is set, it may select none, one or many portfolios on the Efficient Frontier which are in accordance with the investors risk/reward profile. These portfolio(s) will have differing expected returns and this method will return the portfolio from the set selected which has the highest expected return. That is, we evaluate the portfolio which lies on an intersection of the utility function and the Efficient Frontier which represents the portfolio with the highest expected return.
Returned Portfolio
This method returns an array of the weights of the assets within the portfolio with the maximum expected return, within the set of (optimal) portfolio(s) selected from the Efficient Frontier. The first term of the array is the weight of the first asset within the collection of assets from which the portfolios can be selected, the second term is the weight of the second term and so on.
Methods which should be called prior to this method
Before this method is called you will be required to call three methods which set three private fields. These three methods are:
setConstraints - If the weights of the assets are subject to constraints
then the should be set first.
calculateEfficientFrontier - Evaluate the Efficient
Frontier from the collection of assets from which the portfolios can be constructed.
setUtilityFunctionInterp or
setUtilityFunctionPoly - Use either method in order to set the
investors utility function.
When the Investors Utility Function never cross the Efficient Frontier
This methods find the set of optimal portfolio by finding the points at which the Efficient Frontier and the investor's utility function cross. If over the considered range of the expected returns the two curves do not cross then either the investors utility function is above or below the Efficient Frontier over the range of expected returns considered. In these two cases one of the following two exceptions will be thrown:
In the case when the AboveException is thrown the follow two modifications of the problem are equally justified:
setUtilityFunctionInterp or setUtilityFunctionPoly. Once the investors
utility function has been reset this methods can be re-applied.
Suitable values of the Expected Return Parameter
For a given set of assets with possibly constrained asset weights there will correspond
a range of values of the expected return over which the (constrained) Efficient Frontier
exists. Naturally the range of the expected return about which the optimal portfolios are sort
since these optimal portfolios lie on the Efficient Frontier must lie within this range in which
the Efficient Frontier exists. You are able to evaluate this continuous range of expected returns
for which the Efficient Frontier exists by calling the methods minFrontierReturn(double[]) and
maxFrontierReturn(double[]), in order to evaluate the upper and lower bounds respectively. If you
are considering the constrained case then before evaluating the range of which the Efficient
Frontier exists you should have set the constraints on the asset weights by calling
setConstraints(double[], double[]).
minimumExpectedReturn - the minimum expected return of the range over which the optimal portfolio(s) in accordance with the investors utility function are sort. The expected return should be given in absolute (i.e. market price) or relative (i.e. percentage) terms in accordance with the units used for the expected returns within the evaluation of the Efficient Frontier.maximumExpectedReturn - the maximum expected return of the range over which the optimal portfolio(s) in accordance with the investors utility function are sort. s The expected return should be given in absolute (i.e. market price) or relative (i.e. percentage) terms in accordance with the units used for the expected returns within the evaluation of the Efficient Frontier.covarianceMatrix - the covariance matrix of the collection of assets from which the (optimal) portfolio can be constructed.
EfficientFrontierNotCalculatedException - thrown if the Efficient Frontier is not been
constructed. That is, the method calculateEfficientFrontier
has not been called. In order remedy the situation please evaluated the Efficient Frontier
using the method calculateEfficientFrontier over a range of
expected returns equal to or larger than the range considered her over which the optimal portfolio
is sort. Once this process is complete you may re-apply this method.
UtilityFunctionNotInitializedException - thrown if Investors Utility function is not set.
In order to set the Investors Utility function you will need to call one of the methods:
setUtilityFunctionInterp or setUtilityFunctionPoly.
Note that the range of the expected returns over which the Investors Utility function is given
should be equal to or larger than the range of expected return used here over which the optimal
portfolio is sort. Once the Investors Utility function has been set of a suitable range you
will be able to re-apply this method.
AboveException - thrown if the investors utility function is above the Efficient Frontier
for all values of the expected return (see above remarks for further explanation).
BelowException - thrown if the investors utility function is below the Efficient Frontier
for all values of the expected return (see above remarks for further explanation).
PortfolioException - thrown if the number of optimal portfolios found is more than 100.
In this instance the investors utility function is probably very close if not identical to the
Efficient Frontier over at least a section of the range of the expected returns considered.
To address this issue to utility function should be refined so that it is more clearly
distinguishable from the Efficient Frontier. Since it is very likely that modulo interpolation
errors the utility function is identical to the Efficient Frontier over a section of the
expected returns considered which causes the method at present in principal to fail. Anyway,
once the Investors Utility function has been refined you will be able to re-apply this method.
MarkowitzDemoException
public double[][] covarianceMatrix(double[] probability,
double[][] returns)
throws MarkowitzDemoException
AssetParameters.
Returns the covariance matrix for a collection of assets given the probability
distributions of there returns. The distribution of the probability of the various
returns occurring is a discrete probability distribution given by probability.
probability - probability[i] is the probability of market state i occurring.returns - returns[i][j] is the return of the market value of the asset j when the market is in the ith state
MarkowitzDemoException
public double[][] covarianceMatrix(double[][] historicalReturns)
throws MarkowitzDemoException
AssetParameters.
Returns the covariance matrix for a collection of assets when the assets historical returns are known.
historicalReturns - historicalReturns[i][t] is the historical return (increase in market value) for the asset i in the tth period.
MarkowitzDemoException
public double[] expectedReturns(double[] probability,
double[][] returns)
throws MarkowitzDemoException
AssetParameters.
Returns an array containing the expected returns for each asset from a given collection of assets.
probability - probability[i] is the probability of state i to occurreturns - returns[i][j] is the return (increase in market value) of the asset j in the ith state
MarkowitzDemoException
public double[] expectedReturns(double[][] historicalReturns)
throws MarkowitzDemoException
AssetParameters.
Returns an array containing the expected returns for each asset from a given collection of assets.
historicalReturns - historicalReturns[i][t] is the historical return (increase in market value) for the asset i in the tth period.
MarkowitzDemoException
public double portfolioVariance(double[] weight,
double[][] covarianceMatrix)
throws MarkowitzDemoException
AssetParameters.
Evaluates the variance of the portfolio's value.
weight - weight[i] is the weight for asset i. Note that, x[0] + x[1] + ... + x[N - 1]=1.covarianceMatrix - is the covariance matrix of the portfolio's assets
MarkowitzDemoException
public double portfolioRisk(double[] weight,
double[][] covarianceMatrix)
throws MarkowitzDemoException
AssetParameters.
The risk (also known as the volatility or standard deviation) of the portfolio.
weight - weight[i] is the weight for asset i. Note that, x[0] + x[1] + ... + x[N - 1]=1.covarianceMatrix - is the covariance matrix of the portfolio's assets
MarkowitzDemoException
|
WebCab Portfolio Demo v4.2 (J2SE Edition) |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||