WebCab Portfolio Web Services for .NET v5.0 Demo

Markowitz.OptimalPortfolio Method 

Evaluates the set of (possibly constrained) portfolios on the Efficient Frontier which are optimal with respect to the investors utility function.

public double[][] OptimalPortfolio(
   double minimumExpectedReturn,
   double maximumExpectedReturn,
   double[][] covarianceMatrix
);

Parameters

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.

Return Value

The optimal portfolio(s) on the Efficient Frontier with respect to the Investors Utility function. If no optimal portfolio was found (i.e. no portfolio was selected from the Efficient Frontier by the investors utility function intersecting) then this method will return an empty array of dimension 2.

Remarks

In practice, what this means is that we find the portfolios which corresponds to the intersection between the Efficient Frontier and the investors utility function.

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:

  1. AboveException - Thrown when the investors utility function is above the Efficient Frontier over the range of the expected return. In this instance the investors is prepared to accept more risk for any value of the expected return, than the risk of the portfolio on the Efficient Frontier with the same value of the expected return. Therefore, any portfolio on the Efficient Frontier would satisfy the investors risk tolerance but no finite set of (optimal) portfolios exist which are selected from the Efficient Frontier by the investors utility function.
  2. BelowException - Thrown when the investors utility function is below the Efficient Frontier over the range of the expected return. In this instance for all values of the expected return the investor is not prepared to take the risk sufficient in order to obtain that level of expected return. Therefore, in this instance not only is there no optimal portfolio but there is in fact no possible portfolio which the investor would be prepared to hold.

In the case when the AboveException is thrown the follow two modifications of the problem are equally justified:

  1. Change Utility Function: Either shift the investors utility function down along the risk axis or along the expected return axis by re-setting the utility function private fields using one of SetUtilityFunctionInterp or SetUtilityFunctionPoly. Once the investors utility function has been reset this methods can be re-applied.
  2. Returns Portfolio: Return the portfolio of the Efficient Frontier which has the maximum expected return with the range considered. The rationale being that since the investor is prepared to hold any of the portfolios over the range of the expected returns for which it is considered. The assumption of the Markowitz model would lead us to believe that the investor would wish to maximize his expected return and select the portfolio with the highest expected return.

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 and MaxFrontierReturn, 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.

Exceptions

Exception TypeCondition
EfficientFrontierNotCalculatedExceptionThrown 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.
UtilityFunctionNotInitializedExceptionThrown 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.
AboveExceptionThrown if the investors utility function is above the Efficient Frontier for all values of the expected return (see above remarks for further explanation).
BelowExceptionThrown if the investors utility function is below the Efficient Frontier for all values of the expected return (see above remarks for further explanation).
PortfolioExceptionThrown 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.

See Also

Markowitz Class | Portfolio Namespace