|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectorg.ojalgo.finance.portfolio.FinancePortfolio
org.ojalgo.finance.portfolio.MarkowitzModel
public final class MarkowitzModel
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.
| Constructor Summary | |
|---|---|
MarkowitzModel(org.ojalgo.finance.portfolio.EquilibriumModel anEquilibriumModel)
|
|
MarkowitzModel(MarketEquilibrium aMarketEquilibrium,
BasicMatrix anExpectedExcessReturns)
|
|
| Method Summary | |
|---|---|
org.ojalgo.finance.portfolio.MarkowitzModel.LowerUpper |
addConstraint(BigDecimal aLower,
BigDecimal anUpper,
int... someInstrumentIndeces)
|
void |
clearAllConstraints()
|
BasicMatrix |
getAssetReturns()
|
List<SimpleAsset> |
getAssets()
|
BasicMatrix |
getAssetWeights()
|
BasicMatrix |
getCovariances()
|
BigDecimal |
getImpliedRiskAversion(BasicMatrix aWeightsVctr,
BasicMatrix aReturnsVctr)
|
double |
getMeanReturn()
The mean/expected return of this instrument. |
State |
getOptimisationState()
|
double |
getReturnVariance()
The instrument's return variance. |
BigDecimal |
getRiskAversion()
|
String[] |
getSymbols()
|
List<BigDecimal> |
getWeights()
This method returns a list of the weights of the Portfolio's contained assets. |
void |
setLowerLimit(int anInstrumentIndex,
BigDecimal aLimit)
|
void |
setRiskAversion(Number aFactor)
|
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.FinancePortfolio |
|---|
forecast, getSharpeRatio, getValueAtRisk, getVolatility, normalise, shift |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MarkowitzModel(org.ojalgo.finance.portfolio.EquilibriumModel anEquilibriumModel)
public MarkowitzModel(MarketEquilibrium aMarketEquilibrium,
BasicMatrix anExpectedExcessReturns)
| Method Detail |
|---|
public org.ojalgo.finance.portfolio.MarkowitzModel.LowerUpper addConstraint(BigDecimal aLower,
BigDecimal anUpper,
int... someInstrumentIndeces)
public final void clearAllConstraints()
public final State getOptimisationState()
public final void setLowerLimit(int anInstrumentIndex,
BigDecimal aLimit)
public final void setShortingAllowed(boolean aFlag)
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.
setTargetVariance(BigDecimal)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.
setTargetReturn(BigDecimal)
public final void setUpperLimit(int anInstrumentIndex,
BigDecimal aLimit)
public String toString()
toString in class Objectpublic final BasicMatrix getAssetReturns()
public List<SimpleAsset> getAssets()
public final BasicMatrix getAssetWeights()
public final BasicMatrix getCovariances()
public final BigDecimal getImpliedRiskAversion(BasicMatrix aWeightsVctr,
BasicMatrix aReturnsVctr)
public final double getMeanReturn()
FinancePortfolio
getMeanReturn in class FinancePortfoliopublic final double getReturnVariance()
FinancePortfolio
getReturnVariance in class FinancePortfoliopublic final BigDecimal getRiskAversion()
public final String[] getSymbols()
public final List<BigDecimal> getWeights()
FinancePortfolio
getWeights in class FinancePortfoliopublic final void setRiskAversion(Number aFactor)
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||