WebCab Portfolio Demo
v4.2
(J2EE Edition)

com.webcab.ejb.finance.portfolio
Interface EasyOptimal

All Superinterfaces:
EJBObject, Remote

public interface EasyOptimal
extends EJBObject

This Enterprise JavaBean presents the key functionality made available from the Markowitz Theory and Capital Asset Pricing Model (CAPM) within this product in an easy to use and quickly understandable form. In particular, we allow the optimal portfolio to be constructed for a given:

  1. Expected return or Risk: for portfolios which are constructed from risky assets and possibly cash which can be borred or lent at the prevailing market rate on cash.
  2. Investors Utility Function: for portfolio which are constructed from risky assets only.

Remarks: For the rationale as to why in the case of portfolios which may hold cash there is no rationale for introduction the investors utility function we refer the interested reader to CapitalMarket.

Two cases corresponding to Markowitz Theory and CAPM

Portfolio Theory roughly speaking considers two cases: one where we can construct the optimal portfolio from (risky) assets only and another case where we are able to construct the optimal portfolio from a combination of (risky) assets with the possibility to either lend or borrow cash to or from the market at a previaling market rate. The first case correspondings to the situation treated by Markowitz Theory adn the second to the situation treated by the Capital Asset Princign Model.

Five Stateless methods for the Five Cases

For these two cases we offer the following functionality:

  1. Markwotiz Theory: No borrowing or lending Cash
    1. markowitzReturn - Finds the weights of the (risky) assets of the portfolio with the lowest risk for a given expected return constructed from the available assets.
    2. markowitzRisk - Finds the weights of the (risky) assets of the portfolio with the greatest expected return for a given risk constructed from the available assets.
    3. markwotizUtility - Finds the weights of the (risky) assets of the portfolio(s) which are selected in accordance with the investors utility functions constructed from the available assets.
  2. CAPM: Can borrow or lend cash at the prevailing Market rate.
    1. capmReturn - Finds the weighting of the cash element and the (risky) assets weightings of the portfolio which has the lowest risk for a given level of return constructed from the available assets.
    2. capmRisk - Finds the weighting of the cash element and the (risky) asset weightings of the portfolio which has the greatest expected return for a given value of risk which can be constructed from the available assets.

Improve Performance and Flexibility

Though this Enterprise JavaBean is easy to use, it does have the draw-back that offer the performance and flexibility of the implementation will be less than clients which can be constructed using the main classes of this Components.

See Also:
in this stateful Enterprise JavaBean you are able to declaratively find the optimal portfolio. By declarative we mean that you are only required to declare the properties of the assets from which the portfolio can be constructed and any market parameters, and then you are able to solve for the optimal portfolio by expected return or risk. That is, you declare the problems only, and are not required to select the method or combination of methods to apply in order to find the optimal portfolio.

Method Summary
 double[] capmReturn(double expectedReturn, double[][] historicalReturns, double[] lowerBounds, double[] upperBounds, double prevailingRate, int interpolationPoints, double precision)
          For an given value of the expected return find the weighting of the cash and (risky) assets of the optimal portfolio which can hold or lend cash at the prevailing market rate.
 double[] capmRisk(double risk, double[][] historicalReturns, double[] lowerBounds, double[] upperBounds, double prevailingRate, int interpolationPoints, double precision)
          For a given value of the risk find the weighting of the cash and (risky) assets of the optimal portfolio which can hold or lend cash at the prevailing market rate.
 double[] markowitzReturn(double expectedReturn, double[] lowerBounds, double[] upperBounds, double[][] historicalreturns, double precision)
          Finds the weights of the (risky) assets of the portfolio with the lowest risk for a given expected return constructed from the available assets.
 double[] markowitzRisk(double risk, double[] lowerBounds, double[] upperBounds, double[][] historicalReturns, int interpolationPoints, double precision)
          Finds the weights of the (risky) assets of the portfolio with the greatest expected return for a given risk constructed from the available assets.
 double[] markowitzUtility(double[] utilityExpectedReturns, double[] utilityRisks, double[] lowerBounds, double[] upperBounds, double[][] historicalReturns, int interpolationPoints, double precision)
          Finds the weights of the (risky) assets of the portfolio(s) which are selected in accordance with the investors utility functions with the highest expected return.
 
Methods inherited from interface javax.ejb.EJBObject
getEJBHome, getHandle, getPrimaryKey, isIdentical, remove
 

Method Detail

markowitzReturn

public double[] markowitzReturn(double expectedReturn,
                                double[] lowerBounds,
                                double[] upperBounds,
                                double[][] historicalreturns,
                                double precision)
                         throws ReferencedServiceException,
                                EasyOptimalDemoException,
                                RemoteException
Finds the weights of the (risky) assets of the portfolio with the lowest risk for a given expected return constructed from the available assets.

Parameters:
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.
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.
precision - this parameters allow the level of the precision required to be set, where the small the parameters the (generally) higher the precision.
ReferencedServiceException
EasyOptimalDemoException
RemoteException

markowitzRisk

public double[] markowitzRisk(double risk,
                              double[] lowerBounds,
                              double[] upperBounds,
                              double[][] historicalReturns,
                              int interpolationPoints,
                              double precision)
                       throws InterpolationException,
                              ReferencedServiceException,
                              EasyOptimalDemoException,
                              RemoteException
Finds the weights of the (risky) assets of the portfolio with the greatest expected return for a given risk constructed from the available assets.

Parameters:
risk - the risk for which the corresponding optimal portfolio will be found.
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.
historicalReturns - This array of dimension two is the historical returns in absolute (i.e. market price) or relative (i.e. percentage change) terms of the assets from which the optimal portfolio can be constructed. The n-th element of the 2-dimensional array is an array, where the k-th term on this array is the historical return of the n-th assets in the k-th period before the present periods return.
interpolationPoints - the number of tabulation point which are used to represent the Efficient Frontier.
precision - this parameters allow the level of the precision required to be set, where the small the parameters the (generally) higher the precision.
InterpolationException
ReferencedServiceException
EasyOptimalDemoException
RemoteException

markowitzUtility

public double[] markowitzUtility(double[] utilityExpectedReturns,
                                 double[] utilityRisks,
                                 double[] lowerBounds,
                                 double[] upperBounds,
                                 double[][] historicalReturns,
                                 int interpolationPoints,
                                 double precision)
                          throws ReferencedServiceException,
                                 EasyOptimalDemoException,
                                 RemoteException
Finds the weights of the (risky) assets of the portfolio(s) which are selected in accordance with the investors utility functions with the highest expected return.

Utility Function

The utility function is generated by interpolating a tabulated function which is provided by two array utilityExpectedReturns and utilityRisk. The array utilityRisk, 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 array utilityExpectedReturns 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.

For further details concerning the nature of the utility function and how it can be discovered from the investors risk/reward preferences we refer the reader to setUtilityFunctionInterp, or the accompanying PDF documentation.

Asset Weight Constraints

The parameters lowerBounds, and upperBounds allow constraints to be placed on the weights of the assets from which the optimal portfolio can be constructed. For example, if we set:

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. Then the weights of each of the assets from which the optimal portfolio is constructed must lie within the interval [0.1, 0.5]. Note that the sum of the weights of all portfolio (included the optimal portfolio) musy sum to 1.

If you not wish to place explicit constraints of the weights of the assets then you should set:

lowerBounds = {0, 0, 0,...., 0}
upperBounds = {1, 1, 1, ..., 1}

where each of the arrays above has the same number of terms of the number of assets.

For further details concerning the use and purpose of the asset weights constraints we refer the reader to setConstraints, or the accompanying PDF documentation.

Expected Returns

The expected returns of the assets from which the optimal portfolio can be constructed will need to be supplied in absolute (i.e. expected final market price) or relative terms (i.e. expected returns as a percentage). Which ever convension is used for the expected returns the weights of the optimal portfolio returned will be unchanged.

Remark: The reason why the weights of the assets of the optimal portfolio are invariant to the units used for the expected returns is that the weights are unit-less and hence during the computation of the assets weights the units used for the expected returns will (in a sense) be `canceled out'.

The nature of the utility Function

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. The k-th term of the each of this methods parameters represent such a point within the risk reward space. By providing a set of such pairs we are able to represent the risk - reward profile of the investor.

For further details including examples of the investors utility function we refer the reder to setUtilityFunctionInterp, and the accompanying PDF documentation.

Parameters:
utilityExpectedReturns - 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.
utilityRisks - 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.
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.
historicalReturns - This array of dimension two is the historical returns in absolute (i.e. market price) or relative (i.e. percentage change) terms of the assets from which the optimal portfolio can be constructed. The n-th element of the 2-dimensional array is an array, where the k-th term on this array is the historical return of the n-th assets in the k-th period before the present periods return.
interpolationPoints - the number of tabulation point which are used to represent the Efficient Frontier.
precision - this parameters allow the level of the precision required to be set, where the small the parameters the (generally) higher the precision.
ReferencedServiceException
EasyOptimalDemoException
RemoteException

capmReturn

public double[] capmReturn(double expectedReturn,
                           double[][] historicalReturns,
                           double[] lowerBounds,
                           double[] upperBounds,
                           double prevailingRate,
                           int interpolationPoints,
                           double precision)
                    throws ReferencedServiceException,
                           EasyOptimalDemoException,
                           RemoteException
For an given value of the expected return find the weighting of the cash and (risky) assets of the optimal portfolio which can hold or lend cash at the prevailing market rate.

Structure of the Returned Array

The length of the array of doubles returned is n+1, where n is the number of (risky) assets from which the portfolio can be constructed. The first term of the array is the weighting of the cash element within the optimal portfolio, and the k+1 element is the weighting of the k (risky) asset available.

Parameters:
expectedReturn - the value of the expected return of the optimal portfolio (i.e. the portfolio with the lower risk) found. 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.
historicalReturns - This array of dimension two is the historical returns in absolute (i.e. market price) or relative (i.e. percentage change) terms of the assets from which the optimal portfolio can be constructed. The n-th element of the 2-dimensional array is an array, where the k-th term on this array is the historical return of the n-th assets in the k-th period before the present periods return.
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.
precision - this parameters allow the level of the precision required to be set, where the small the parameters the (generally) higher the precision. A reasonable value to take for the precision is 1E-12, or 0.000000000001.
ReferencedServiceException
EasyOptimalDemoException
RemoteException

capmRisk

public double[] capmRisk(double risk,
                         double[][] historicalReturns,
                         double[] lowerBounds,
                         double[] upperBounds,
                         double prevailingRate,
                         int interpolationPoints,
                         double precision)
                  throws ReferencedServiceException,
                         EasyOptimalDemoException,
                         RemoteException
For a given value of the risk find the weighting of the cash and (risky) assets of the optimal portfolio which can hold or lend cash at the prevailing market rate.

Structure of the Returned Array

The length of the array of doubles returned is n+1, where n is the number of (risky) assets from which the portfolio can be constructed. The first term of the array is the weighting of the cash element within the optimal portfolio, and the k+1 element is the weighting of the k (risky) asset available.

Parameters:
risk - the value of the risk of the optimal portfolio (i.e. the portfolio with the lower risk) found.
historicalReturns - This array of dimension two is the historical returns in absolute (i.e. market price) or relative (i.e. percentage change) terms of the assets from which the optimal portfolio can be constructed. The n-th element of the 2-dimensional array is an array, where the k-th term on this array is the historical return of the n-th assets in the k-th period before the present periods return.
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.
precision - this parameters allow the level of the precision required to be set, where the small the parameters the (generally) higher the precision. A reasonable value to take for the precision is 1E-12, or 0.000000000001.
ReferencedServiceException
EasyOptimalDemoException
RemoteException

WebCab Portfolio Demo
v4.2
(J2EE Edition)