WebCab Portfolio Web Services for .NET v5.0 Demo

Markowitz.CalculateEfficientFrontier Method (Double, Double, Double[][], Double[], Int32, Double)

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.

public void CalculateEfficientFrontier(
   double minimumExpectedReturn,
   double maximumExpectedReturn,
   double[][] covarianceMatrix,
   double[] expectedReturns,
   int numberInterpolationPoints,
   double precision
);

Parameters

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.

Remarks

Note that the weights of the assets from which the portfolio may be constructed may be subject to constraints (see notes below).

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 XML Web service we offer the two methods MinFrontierReturn and MaxFrontierReturn 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:

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 XML Web services private fields. The setting of this private field (that is, the calling of this method) is required in order to use the following methods:

  1. GetEfficientFrontierExpectedReturns - Evaluates the expected returns of the portfolios at the points at which the Efficient Frontier is known.
  2. GetEfficientFrontierAssetWeights - Evaluates the asset weights of a portfolios at the points at which the Efficient Frontier is known.
  3. GetEfficientFrontierPortfolioRisks - Evaluates the risks of the portfolio at the points at which the Efficient Frontier is known.
  4. 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.
  5. EfficientFrontier - Evaluates the asset weights of the portfolio at an arbitrary point of the Efficient Frontier via interpolation.
  6. OptimalPortfolio - Evaluates the optimal portfolio(s) on the Efficient Frontier with respect to the Investors Utility function.
  7. 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 XML Web service procedures which assist in there evaluation of the covariance matrix and the expected returns via either a historical or scenario approach.

Exceptions

Exception TypeCondition
NoSolutionExceptionThrown 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.

See Also

Markowitz Class | Portfolio Namespace | Markowitz.CalculateEfficientFrontier Overload List