Class MarketEquilibrium
- java.lang.Object
-
- org.ojalgo.data.domain.finance.portfolio.MarketEquilibrium
-
public class MarketEquilibrium extends java.lang.Object
MarketEquilibrium translates between the market portfolio weights and the equilibrium excess returns. The only things needed to do those translations are the covariance matrix and the (market) risk aversion factor - that's what you need to supply when you instantiate this class.
This class performs unconstrained optimisation. For each set of asset returns there is an optimal set of weights. It also performs reverse (unconstrained) optimisation producing the "optimal" expected returns given a set of weights.
The name MarketEquilibrium is actually a bit misleading. By altering the risk aversion factor this class can/will describe the weights/returns equilibrium for any investor.
-
-
Field Summary
Fields Modifier and Type Field Description private static java.math.BigDecimal
DEFAULT_RISK_AVERSION
private java.lang.String[]
myAssetKeys
private MatrixR064
myCovariances
private java.math.BigDecimal
myRiskAversion
private static java.lang.String
STRING_ZERO
private static java.lang.String
SYMBOL
-
Constructor Summary
Constructors Constructor Description MarketEquilibrium(java.lang.String[] assetNamesOrKeys, Access2D<?> covarianceMatrix)
MarketEquilibrium(java.lang.String[] assetNamesOrKeys, Access2D<?> covarianceMatrix, java.lang.Comparable<?> riskAversionFactor)
MarketEquilibrium(MarketEquilibrium marketEquilibrium)
MarketEquilibrium(Access2D<?> covarianceMatrix)
MarketEquilibrium(Access2D<?> covarianceMatrix, java.lang.Comparable<?> riskAversionFactor)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description MatrixR064
calculateAssetReturns(MatrixR064 assetWeights)
If the input vector of asset weights are the weights of the market portfolio, then the ouput is the equilibrium excess returns.MatrixR064
calculateAssetWeights(MatrixR064 assetReturns)
If the input vector of returns are the equilibrium excess returns then the output is the market portfolio weights.(package private) Scalar<?>
calculateImpliedRiskAversion(MatrixR064 assetWeights, MatrixR064 assetReturns)
Will calculate the risk aversion factor that is the best fit for an observed pair of market portfolio weights and equilibrium/historical excess returns.static Scalar<?>
calculatePortfolioReturn(MatrixR064 assetWeights, MatrixR064 assetReturns)
Calculates the portfolio return using the input asset weights and returns.Scalar<?>
calculatePortfolioVariance(MatrixR064 assetWeights)
Calculates the portfolio variance using the input instrument weights.void
calibrate(MatrixR064 assetWeights, MatrixR064 assetReturns)
Will set the risk aversion factor to the best fit for an observed pair of market portfolio asset weights and equilibrium/historical excess returns.MarketEquilibrium
clean()
Equivalent to copying, but additionally the covariance matrix will be cleaned of negative and very small eigenvalues to make it positive definite.MarketEquilibrium
copy()
java.lang.String
getAssetKey(int index)
java.lang.String[]
getAssetKeys()
MatrixR064
getCovariances()
Scalar<?>
getRiskAversion()
(package private) boolean
isDefaultRiskAversion()
private static java.lang.String[]
makeSymbols(int count)
void
setRiskAversion(java.lang.Comparable<?> factor)
int
size()
MatrixR064
toCorrelations()
-
-
-
Field Detail
-
DEFAULT_RISK_AVERSION
private static final java.math.BigDecimal DEFAULT_RISK_AVERSION
-
STRING_ZERO
private static final java.lang.String STRING_ZERO
- See Also:
- Constant Field Values
-
SYMBOL
private static final java.lang.String SYMBOL
- See Also:
- Constant Field Values
-
myAssetKeys
private final java.lang.String[] myAssetKeys
-
myCovariances
private final MatrixR064 myCovariances
-
myRiskAversion
private java.math.BigDecimal myRiskAversion
-
-
Constructor Detail
-
MarketEquilibrium
public MarketEquilibrium(Access2D<?> covarianceMatrix)
-
MarketEquilibrium
public MarketEquilibrium(Access2D<?> covarianceMatrix, java.lang.Comparable<?> riskAversionFactor)
-
MarketEquilibrium
public MarketEquilibrium(java.lang.String[] assetNamesOrKeys, Access2D<?> covarianceMatrix)
-
MarketEquilibrium
public MarketEquilibrium(java.lang.String[] assetNamesOrKeys, Access2D<?> covarianceMatrix, java.lang.Comparable<?> riskAversionFactor)
-
MarketEquilibrium
MarketEquilibrium(MarketEquilibrium marketEquilibrium)
-
-
Method Detail
-
calculatePortfolioReturn
public static Scalar<?> calculatePortfolioReturn(MatrixR064 assetWeights, MatrixR064 assetReturns)
Calculates the portfolio return using the input asset weights and returns.
-
makeSymbols
private static java.lang.String[] makeSymbols(int count)
-
calculateAssetReturns
public MatrixR064 calculateAssetReturns(MatrixR064 assetWeights)
If the input vector of asset weights are the weights of the market portfolio, then the ouput is the equilibrium excess returns.
-
calculateAssetWeights
public MatrixR064 calculateAssetWeights(MatrixR064 assetReturns)
If the input vector of returns are the equilibrium excess returns then the output is the market portfolio weights. This is unconstrained optimisation - there are no constraints on the resulting instrument weights.
-
calculatePortfolioVariance
public Scalar<?> calculatePortfolioVariance(MatrixR064 assetWeights)
Calculates the portfolio variance using the input instrument weights.
-
calibrate
public void calibrate(MatrixR064 assetWeights, MatrixR064 assetReturns)
Will set the risk aversion factor to the best fit for an observed pair of market portfolio asset weights and equilibrium/historical excess returns.
-
clean
public MarketEquilibrium clean()
Equivalent to copying, but additionally the covariance matrix will be cleaned of negative and very small eigenvalues to make it positive definite.
-
copy
public MarketEquilibrium copy()
-
getAssetKey
public java.lang.String getAssetKey(int index)
-
getAssetKeys
public java.lang.String[] getAssetKeys()
-
getCovariances
public MatrixR064 getCovariances()
-
getRiskAversion
public Scalar<?> getRiskAversion()
-
setRiskAversion
public void setRiskAversion(java.lang.Comparable<?> factor)
-
size
public int size()
-
toCorrelations
public MatrixR064 toCorrelations()
-
calculateImpliedRiskAversion
Scalar<?> calculateImpliedRiskAversion(MatrixR064 assetWeights, MatrixR064 assetReturns)
Will calculate the risk aversion factor that is the best fit for an observed pair of market portfolio weights and equilibrium/historical excess returns.
-
isDefaultRiskAversion
boolean isDefaultRiskAversion()
-
-