org.ojalgo.finance.portfolio
Class MarkowitzModel

java.lang.Object
  extended by org.ojalgo.finance.portfolio.MeanVarianceAsset
      extended by org.ojalgo.finance.portfolio.CovarianceBasedModel
          extended by org.ojalgo.finance.portfolio.MarkowitzModel
All Implemented Interfaces:
FinancePortfolio

public final class MarkowitzModel
extends CovarianceBasedModel

The Markowitz model, in this class, is defined as:

min (RAF/2) [w]T[C][w] - [w]T[r]
subject to |[w]| = 1

RAF stands for Risk Aversion Factor. Instead of specifying a desired risk or return level you specify a level of risk aversion that is used to balance the risk and return.

The expected returns for each of the instruments/assets must be excess returns. Otherwise this formulation is wrong.

The total weights of all instruments will always be 100%, but shorting can be allowed or not according to your preference. ( setShortingAllowed(boolean) ) In addition you may set lower and upper limits on any individual instrument. ( setLowerLimit(int, BigDecimal) and setUpperLimit(int, BigDecimal) )

Risk-free asset: That means there is no excess return and zero variance. Don't (try to) include a risk-free asset here.

Do not worry about the minus sign in front of the return part of the objective function - it is handled/negated for you. When you're asked to supply the expected excess returns you should supply precisely that.

Author:
apete

Field Summary
 
Fields inherited from class org.ojalgo.finance.portfolio.MeanVarianceAsset
DEBUG
 
Constructor Summary
MarkowitzModel(CovarianceBasedModel aCovarianceBasedModel, BasicMatrix anExpectedExcessReturns)
           
MarkowitzModel(MarketEquilibrium aMarketEquilibrium, BasicMatrix anExpectedExcessReturns)
           
 
Method Summary
 State getOptimisationState()
           
 void setLowerLimit(int anInstrumentIndex, BigDecimal aLimit)
           
 void setShortingAllowed(boolean aFlag)
           
 void setTargetReturn(BigDecimal aTargetReturn)
           Will set the target return to whatever you input and the target variance to null.
 void setTargetVariance(BigDecimal aTargetVariance)
           Will set the target variance to whatever you input and the target return to null.
 void setUpperLimit(int anInstrumentIndex, BigDecimal aLimit)
           
 String toString()
           
 
Methods inherited from class org.ojalgo.finance.portfolio.CovarianceBasedModel
getCovariances, getImpliedRiskAversion, getInstrumentReturns, getInstrumentWeights, getMeanReturn, getReturnVariance, getRiskAversion, getSymbols, getWeights, setRiskAversion
 
Methods inherited from class org.ojalgo.finance.portfolio.MeanVarianceAsset
getVaR90, getVaR95, getVaR98, getVaR99, getVolatility
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MarkowitzModel

public MarkowitzModel(CovarianceBasedModel aCovarianceBasedModel,
                      BasicMatrix anExpectedExcessReturns)

MarkowitzModel

public MarkowitzModel(MarketEquilibrium aMarketEquilibrium,
                      BasicMatrix anExpectedExcessReturns)
Method Detail

getOptimisationState

public final State getOptimisationState()

setLowerLimit

public final void setLowerLimit(int anInstrumentIndex,
                                BigDecimal aLimit)

setShortingAllowed

public final void setShortingAllowed(boolean aFlag)

setTargetReturn

public final void setTargetReturn(BigDecimal aTargetReturn)

Will set the target return to whatever you input and the target variance to null.

Setting the target return implies that you disregard the risk aversion factor and want the minimum risk portfolio with return that is equal to or greater than the target.

By setting the target return too high it is possible to define an infeasible optimisation problem. It is in fact (in combination with setting lower and upper bounds on the instrument weights) very easy to do so without realising it.

Setting a target return is not recommnded. It's much better to modify the risk aversion factor.

See Also:
setTargetVariance(BigDecimal)

setTargetVariance

public final void setTargetVariance(BigDecimal aTargetVariance)

Will set the target variance to whatever you input and the target return to null.

Setting the target variance implies that you disregard the risk aversion factor and want the maximum return portfolio with risk that is equal to or as close to the target as possible.

A target variance isn't an infeasibility risk the way a return target is. The algorithm will return a solution, but there is no guaranty the portfolio variance is equal to or less than the target (as one may expect).

There is a performance penalty for setting a target variance as the underlying optimisation model has to be solved several (many) times with different pararmeters (different risk aversion factors).

Setting a target variance is not recommnded. It's much better to modify the risk aversion factor.

See Also:
setTargetReturn(BigDecimal)

setUpperLimit

public final void setUpperLimit(int anInstrumentIndex,
                                BigDecimal aLimit)

toString

public String toString()
Overrides:
toString in class Object