org.akutan.blacklitterman
Class BlackLitterman

java.lang.Object
  extended by org.akutan.blacklitterman.BlackLitterman
Direct Known Subclasses:
FusaiMeucci, HeLitterman, IdzorekBLExample, KrishnanMains

public class BlackLitterman
extends java.lang.Object

This class encapsulates the top level Black-Litterman functionality in terms of backing the risk aversion out of the market portfolio, and then on to calculating the expected return with views.

Since:
24 April 2006

Field Summary
protected  boolean modifyVariance
          Flag indicating if posterior variance should also be calculcated, this flag must be enabled to match He and Litterman, 1999.
 
Constructor Summary
BlackLitterman()
          Constructs
 
Method Summary
 BLResults applyBL(java.lang.String[] assets, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D pi, BLViews views, double tau, double delta, cern.colt.matrix.DoubleMatrix1D w)
          Called to apply the Black-Litterman model to the inputs in order to derive a posterior view of the asset returns and covariances.
 BLResults applyBL(java.lang.String[] assets, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D pi, BLViews views, double tau, double delta, cern.colt.matrix.DoubleMatrix1D w, cern.colt.matrix.DoubleMatrix1D refW)
          Called to apply the Black-Litterman model to the inputs in order to derive a posterior view of the asset returns and covariances.
 double computeDelta(double risk_premium, double sigma_m)
          Called to compute the risk aversion of the market portfolio.
protected  cern.colt.matrix.DoubleMatrix1D computeEr(cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D pi, BLViews views, double tau)
          Called to apply the Black-Litterman transform to the inputs to compute a new excess return vector assuming 100% certainty in the estimates.
protected  cern.colt.matrix.DoubleMatrix1D computeImpliedWeights(double delta, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D mu)
          Given the risk aversion coefficient, the covariance matrix and the excess returns we can calculate the implied weights.
 double computeInterval(double confidence, double width)
          This function is called to compute the variance of a distribution given a confidence level and a width.
 double computeKLIC(BLResults results)
          Computes the Kullback-Leibler information criteria as a measure of the distance between the prior and the posterior distributions.
protected  cern.colt.matrix.DoubleMatrix1D computeLambda(BLViews views, double tau, cern.colt.matrix.DoubleMatrix1D wEq, cern.colt.matrix.DoubleMatrix1D wStar)
          Computes the He-Litterman Lambda value when posterior variance varies
protected  cern.colt.matrix.DoubleMatrix1D computeLambdaN(BLViews views, double tau, double delta, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D pi)
          Computes the He-Litterman Lambda value when posterior variance does not vary.
 cern.colt.matrix.DoubleMatrix2D computePartialTevSensitities(double delta, BLResults results)
          Computes the partial sensitivites of the tracking error
 double computeTev(BLResults results)
          Computes the standard tracking error of the active weights.
 cern.colt.matrix.DoubleMatrix1D computeTevSensitities(double lambda, BLResults results)
          Computes the sensitivites of the tracking error from the Braga-Natale paper.
protected  cern.colt.matrix.DoubleMatrix2D computeV(cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D pi, BLViews views, double tau)
          Computes the posterior variance using a robust formula which works for any value of the view variance.
 double getViewVariance(double confidence, double width)
          Given the confidence specified as a decimal (area under the cdf) and the total width of the region specified in units, the variance is returned in units squared.
 boolean isModifyVariance()
          State of the modifyVariance flag
protected  double maxValue(cern.colt.matrix.DoubleMatrix2D m)
          Little helper function that runs through the matrix and finds the maximum absolute value for any entry.
 double mehalanobisDistance(double tau, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D mu, cern.colt.matrix.DoubleMatrix1D x)
          Called to compute the Mehalanobis distance (multidimensional Z-score) for this return vector given the mean return and variance matrix.
 double overallProbability(double tau, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D mu, cern.colt.matrix.DoubleMatrix1D x)
          Called to compute a probability for the updated returns given that the mehalanobis distance will be distributed as a Chi squared with n degrees of freedom.
 cern.colt.matrix.DoubleMatrix1D reverseOptimize(double delta, double rf, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D w)
          Computes market implied excess returns given the following parameters
 cern.colt.matrix.DoubleMatrix1D sensitivities(BLViews views, double tau, cern.colt.matrix.DoubleMatrix2D V, cern.colt.matrix.DoubleMatrix1D mu, cern.colt.matrix.DoubleMatrix1D x)
          Called to compute the sensitivities of the Mahalanobis Distance to the various views.
 void setModifyVariance(boolean modifyVariance)
          Sets state of the modifyVariance flag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

modifyVariance

protected boolean modifyVariance
Flag indicating if posterior variance should also be calculcated, this flag must be enabled to match He and Litterman, 1999.

Constructor Detail

BlackLitterman

public BlackLitterman()
Constructs

Method Detail

isModifyVariance

public boolean isModifyVariance()
State of the modifyVariance flag

Returns:
true if the modifyVariance flag is true

setModifyVariance

public void setModifyVariance(boolean modifyVariance)
Sets state of the modifyVariance flag

Parameters:
modifyVariance - New value for modifyVariance flag

computeTev

public double computeTev(BLResults results)
Computes the standard tracking error of the active weights. From the paper TEV Sensitivity to Views in Black-Litterman Model, by Braga and Natale.

Parameters:
results - Container of Black-Litterman model results
Returns:
The TEV metric for the results specified.

computeTevSensitities

public cern.colt.matrix.DoubleMatrix1D computeTevSensitities(double lambda,
                                                             BLResults results)
Computes the sensitivites of the tracking error from the Braga-Natale paper.

Parameters:
lambda - The risk aversion parameter
results - Container of Black-Litterman model results.
Returns:
Vector of sensitivites by asset

computeKLIC

public double computeKLIC(BLResults results)
Computes the Kullback-Leibler information criteria as a measure of the distance between the prior and the posterior distributions. Note that in order for this function to evaluate, all the weights must be > 0.

Parameters:
results - Container of Black-Litterman model results.
Returns:
The KLIC metric

computePartialTevSensitities

public cern.colt.matrix.DoubleMatrix2D computePartialTevSensitities(double delta,
                                                                    BLResults results)
Computes the partial sensitivites of the tracking error

Parameters:
delta - Risk aversion coefficient
results - The BL results
Returns:
The matrix of TEV partial sensitivies (by asset by TODO)

computeInterval

public double computeInterval(double confidence,
                              double width)
This function is called to compute the variance of a distribution given a confidence level and a width.

Parameters:
confidence - Expressed in percent
width - of return confidence internal Expressed in percent
Returns:
The standard deviation required for a normal distribution

mehalanobisDistance

public double mehalanobisDistance(double tau,
                                  cern.colt.matrix.DoubleMatrix2D V,
                                  cern.colt.matrix.DoubleMatrix1D mu,
                                  cern.colt.matrix.DoubleMatrix1D x)
Called to compute the Mehalanobis distance (multidimensional Z-score) for this return vector given the mean return and variance matrix.

Parameters:
tau - Parameter of uncertainty of the prior estimates of the returns
V - Covariance matrix of the returns
mu - Vector of prior estimates of the returns
x - Vector of posterior estimates of the returns (to be measured).
Returns:
Mehalanobis Distance of the posterior estimates from the prior estimates

overallProbability

public double overallProbability(double tau,
                                 cern.colt.matrix.DoubleMatrix2D V,
                                 cern.colt.matrix.DoubleMatrix1D mu,
                                 cern.colt.matrix.DoubleMatrix1D x)
Called to compute a probability for the updated returns given that the mehalanobis distance will be distributed as a Chi squared with n degrees of freedom. This is from the paper by Fusai and Meucci.

Parameters:
tau - Parameter of uncertainty of the prior estimates of the returns
V - Covariance matrix for the assets
mu - Vector of prior estimates of the returns
x - Vector of posterior estimates of the returns (to be measured).
Returns:
Overall probability of that the posterior estimates are consistent with the covariance matrix and prior estimates.

sensitivities

public cern.colt.matrix.DoubleMatrix1D sensitivities(BLViews views,
                                                     double tau,
                                                     cern.colt.matrix.DoubleMatrix2D V,
                                                     cern.colt.matrix.DoubleMatrix1D mu,
                                                     cern.colt.matrix.DoubleMatrix1D x)
Called to compute the sensitivities of the Mahalanobis Distance to the various views. This is from the paper by Fuasi and Meucci.

Parameters:
views - Container of the views
tau - Parameter of uncertainty of the prior estimates of the returns
V - Covariance matrix for the assets
mu - Vector of prior estimates of the returns
x - Vector of posterior estimates of the returns (to be measured).
Returns:
Vector of sensitivites of the Mehalanobis Distance to the individual views

getViewVariance

public double getViewVariance(double confidence,
                              double width)
Given the confidence specified as a decimal (area under the cdf) and the total width of the region specified in units, the variance is returned in units squared.

Parameters:
confidence -
width -
Returns:
The variance of the view given the confidence interval

computeDelta

public double computeDelta(double risk_premium,
                           double sigma_m)
Called to compute the risk aversion of the market portfolio.

Parameters:
risk_premium - Expected risk premium of market portfolio over the risk free rate (percent).
sigma_m - Standard deviation of the market portfolio (percent).
Returns:
lamdba (risk aversion coefficient for Black-Litterman)

reverseOptimize

public cern.colt.matrix.DoubleMatrix1D reverseOptimize(double delta,
                                                       double rf,
                                                       cern.colt.matrix.DoubleMatrix2D V,
                                                       cern.colt.matrix.DoubleMatrix1D w)
Computes market implied excess returns given the following parameters

Parameters:
delta - Market portfolio implied risk aversion
rf - Long run risk free rate
V - Long run covariance matrix for the individual assets
w - Current equilibrium weights of the assets in the market portfolio
Returns:
Vector of implied excess returns from unconstrained reverse optimization

computeImpliedWeights

protected cern.colt.matrix.DoubleMatrix1D computeImpliedWeights(double delta,
                                                                cern.colt.matrix.DoubleMatrix2D V,
                                                                cern.colt.matrix.DoubleMatrix1D mu)
Given the risk aversion coefficient, the covariance matrix and the excess returns we can calculate the implied weights.

Parameters:
delta - The risk aversion coefficient
V - The matrix of asset return covariances
mu - The vector of mean expected asset returns
Returns:
Vector of implied weights

applyBL

public BLResults applyBL(java.lang.String[] assets,
                         cern.colt.matrix.DoubleMatrix2D V,
                         cern.colt.matrix.DoubleMatrix1D pi,
                         BLViews views,
                         double tau,
                         double delta,
                         cern.colt.matrix.DoubleMatrix1D w)
Called to apply the Black-Litterman model to the inputs in order to derive a posterior view of the asset returns and covariances. Also computes the implied weights for the unconstrained minimum variance portfolio.

Parameters:
assets - Array of asset names
V - Matrix of asset return covariances
pi - Vector of expected asset mean returns
views - Structure of investors views
tau - Confidence in the prior
delta - Risk aversion coefficient
w - Equilibrium asset weights
Returns:
A structure containing the results of applying the investors views to the prior.

applyBL

public BLResults applyBL(java.lang.String[] assets,
                         cern.colt.matrix.DoubleMatrix2D V,
                         cern.colt.matrix.DoubleMatrix1D pi,
                         BLViews views,
                         double tau,
                         double delta,
                         cern.colt.matrix.DoubleMatrix1D w,
                         cern.colt.matrix.DoubleMatrix1D refW)
Called to apply the Black-Litterman model to the inputs in order to derive a posterior view of the asset returns and covariances. Also computes the implied weights for the unconstrained minimum variance portfolio.

Parameters:
assets - Array of asset names
V - Matrix of asset return covariances
pi - Vector of expected asset mean returns
views - Structure of investors views
tau - Confidence in the prior
delta - Risk aversion coefficient
w - Equilibrium asset weights
Returns:
A structure containing the results of applying the investors views to the prior.

computeLambda

protected cern.colt.matrix.DoubleMatrix1D computeLambda(BLViews views,
                                                        double tau,
                                                        cern.colt.matrix.DoubleMatrix1D wEq,
                                                        cern.colt.matrix.DoubleMatrix1D wStar)
Computes the He-Litterman Lambda value when posterior variance varies

Parameters:
views - Structure of investors views
tau - Confidence in the prior/equilibrium returns
wEq - Vector of equilibrium asset weights
wStar - Vector of asset weights after views have been applied.
Returns:
Vector of lambda values (variance of views)

computeLambdaN

protected cern.colt.matrix.DoubleMatrix1D computeLambdaN(BLViews views,
                                                         double tau,
                                                         double delta,
                                                         cern.colt.matrix.DoubleMatrix2D V,
                                                         cern.colt.matrix.DoubleMatrix1D pi)
Computes the He-Litterman Lambda value when posterior variance does not vary.

Parameters:
views - Structure of investors views
tau - Confidence in prior/equilibrium returns
delta - Risk aversion coefficient
V - Matrix of covariances of asset returns
pi - Vector of expected mean asset returns
Returns:
Vector of Lambda values, variance of the view for each view

maxValue

protected double maxValue(cern.colt.matrix.DoubleMatrix2D m)
Little helper function that runs through the matrix and finds the maximum absolute value for any entry.

Parameters:
m - Input matrix
Returns:
maximum value in any cell in the matrix

computeV

protected cern.colt.matrix.DoubleMatrix2D computeV(cern.colt.matrix.DoubleMatrix2D V,
                                                   cern.colt.matrix.DoubleMatrix1D pi,
                                                   BLViews views,
                                                   double tau)
Computes the posterior variance using a robust formula which works for any value of the view variance.

Parameters:
V - Covariance matrix of expected returns
pi - Market equilibrium returns
views - List of user views
tau - Confidence parameter for the prior covariance
Returns:
New covariance matrix adjusted by the views

computeEr

protected cern.colt.matrix.DoubleMatrix1D computeEr(cern.colt.matrix.DoubleMatrix2D V,
                                                    cern.colt.matrix.DoubleMatrix1D pi,
                                                    BLViews views,
                                                    double tau)
Called to apply the Black-Litterman transform to the inputs to compute a new excess return vector assuming 100% certainty in the estimates.

Parameters:
V - Matrix of covariances of asset returns
pi - Vector of asset mean expected returns
views - Structure of investors views
tau - Confidence in the prior/equilibrium returns
Returns:
Vector of asset returns after views have been applied.