Black Litterman Model Excel

The Black Littermanmodel was developed in 1990 at Goldman Sachs by Fischer Black and RobertLitterman and published in 1992. It is a sophisticated portfolio constructionmethod that overcomes the problem of unintuitive, highly-concentratedportfolios, input-sensitivity, and estimation error maximization, in applyingmodern portfolio theory in practice.

The model usesa Bayesian approach to combine the subjective views of an investor regarding theexpected returns of one or more assets with the market equilibrium vector ofexpected returns to form a new, mixed estimate of expected returns. The resultingnew vector of returns leads to intuitive portfolios with sensible portfolioweights. The building of the required inputs is complex, so in this work aretrying to explain it so everybody can use this model. Let’s see now how to useBlack Litterman model in practice.

The inputsof the Black Litterman Model

The Black-Litterman asset allocation model was introduced in Black and Litterman (1990), expanded in Black and Litterman (1991, 1992), and discussed in greater detail in Bevan and Winkelmann (1998), He and Litterman (1999), and Litterman (2003).2 The Black Litterman model combines the CAPM (see Sharpe (1964)), reverse. In order to build the two models, Microsoft Excel is used. Swedish 30-day Treasury Bill is taken as risk-free asset and SIXPRX as a benchmark. Detailed results are presented in Chapter 4. In Black-Litterman model two different views are implemented to see if the model outperforms Markowitz mean-variance model. The Black-Litterman (BL) model is a model in finance proposed by Fischer Black and Robert Litterman. The model was developed in 1990 when both were working at Goldman Sachs. The model offers a simple way for managers to include ‘views’. In fact, the model is an extension of the mean-variance portfolio optimization approach of Markowitz. The allocation from the Black-Litterman model is more diversified, as the pie chart shows. Also, the weights among the assets in the Black-Litterman model agree with the investment analyst views. For example, when you compare the Black-Litterman result with the plain mean-variance optimization result, you can see that the Black-Litterman result.

The Black Littermanmodel is a mathematical model for portfolio allocation, which creates stable,mean-variance efficient portfolios, based on an investor’s unique insights. Theprincipal formula of Black Litterman model is the formula for the new CombinedReturn Vector, which is found by the following expression:

E[R] = [(τΣ)-1 + P’Ω-1P]-1[(τΣ)-1Π + P’Ω-1Q]

Where:

  • E[R] is the new (posterior) CombinedReturn Vector (N x 1 column vector).
  • τ is a scalar (from 0 to 1).
  • Σ is the covariance matrix of excess returns (N x N matrix).
  • P is a matrix that identifies theassets involved in the views (K x N matrix or 1 x N row vector in the specialcase of 1 view).
  • Ω is a diagonal covariance matrix of error terms from the expressedviews representing the uncertainty in each view (K x K matrix).
  • is the ImpliedEquilibrium Return Vector (N x 1 column vector).
  • Q is the View Vector (K x 1 columnvector).

The errorterm (ω) that form thediagonal elements of the covariance matrix of the error term (Ω) is found bythe following expression:

ɯk = (pkΣpk’)τ

Where:

  • pk k is a single 1 x Nrow vector from Matrix P that corresponds to the kth view and Σ is the covariance matrix of excess returns.

In return,the Implied Equilibrium Return Vector is found by the following expression:

Π = λΣwmkt

Where:

  • λ is the risk aversion coefficient.
  • wmkt is the marketcapitalization weight (N x 1 column vector) of the assets.

In returnthe risk aversion coefficient is found by the following expression:

λ = (E[Rm] − Rf) / σ2

Where:

  • E[Rm] is the expectedmarket (or benchmark) total return.
  • Rf is the risk-free rate.
  • σ2 is the variance of the market (orbenchmark) excess returns.

Thevariance of Black Litterman model is found by the following expression:

Litterman

Σp = Σ + [(τΣ)-1 + (P’Ω-1P)]-1

The ExpectedReturn Vector and the variance can now be used as inputs in the mean-variancemodel. So the new optimal “combined”weights are found by the followingexpression:

wp = (λΣ)-1E[R]

The modeldoes not require that investors specify views on all assets, so in this casethe formula of the Combined Return Vector is:

E[R] = Π

Now the expected returns of the Black Litterman model coincide with the implied equilibrium returns.

The implementation of Black Litterman model

The following diagram (Idzorek 2005), summarizes the procedure for implementing the Black Litterman model.

There aremany software that can be used to implement the Black Litterman model inpracites, but for many of them it is necessary to pay a lot of money. The implementationof the model can be done using Excel but it is not simple to do.

The Black-Litterman (BL) model [1] takes a Bayesian approach to asset allocation.Specifically, it combines a prior estimate of returns (for example, the market-impliedreturns) with views on certain assets, to produce a posterior estimate of expectedreturns. The advantages of this are:

  • You can provide views on only a subset of assets and BL will meaningfully propagate it,taking into account the covariance with other assets.
  • You can provide confidence in your views.
  • Using Black-Litterman posterior returns results in much more stable portfolios thanusing mean-historical return.

Essentially, Black-Litterman treats the vector of expected returns itself as a quantity tobe estimated. The Black-Litterman formula is given below:

[E(R) = [(tau Sigma)^{-1} + P^T Omega^{-1} P]^{-1}[(tau Sigma)^{-1} Pi + P^T Omega^{-1} Q]]
  • (E(R)) is a Nx1 vector of expected returns, where N is the number of assets.
  • (Q) is a Kx1 vector of views.
  • (P) is the KxN picking matrix which maps views to the universe of assets.Essentially, it tells the model which view corresponds to which asset(s).
  • (Omega) is the KxK uncertainty matrix of views.
  • (Pi) is the Nx1 vector of prior expected returns.
  • (Sigma) is the NxN covariance matrix of asset returns (as always)
  • (tau) is a scalar tuning constant.

Though the formula appears to be quite unwieldy, it turns out that the formula simply representsa weighted average between the prior estimate of returns and the views, where the weightingis determined by the confidence in the views and the parameter (tau).

Similarly, we can calculate a posterior estimate of the covariance matrix:

[hat{Sigma} = Sigma + [(tau Sigma)^{-1} + P^T Omega^{-1} P]^{-1}]

Though the algorithm is relatively simple, BL proved to be a challenge from a softwareengineering perspective because it’s not quite clear how best to fit it into PyPortfolioOpt’sAPI. The full discussion can be found on a Github issue thread,but I ultimately decided that though BL is not technically an optimizer, it didn’t make sense tosplit up its methods into expected_returns or risk_models. I have thus made it an independentmodule and owing to the comparatively extensive theory, have given it a dedicated documentation page.I’d like to thank Felipe Schneider for his multiplecontributions to the Black-Litterman implementation. A full example of its usage, including the acquistionof market cap data for free, please refer to the cookbook recipe.

Tip

Thomas Kirschenmann has built a neat interactive Black-Litterman toolon top of PyPortfolioOpt, which allows you to visualise BL outputs and compare optimization objectives.

Priors¶

Litterman

You can think of the prior as the “default” estimate, in the absence of any information.Black and Litterman (1991) [2] provide the insight that a natural choice for this prioris the market’s estimate of the return, which is embedded into the market capitalisationof the asset.

Every asset in the market portfolio contributes a certain amount of risk to the portfolio.Standard theory suggests that investors must be compensated for the risk that they take, sowe can attribute to each asset an expected compensation (i.e prior estimate of returns). Thisis quantified by the market-implied risk premium, which is the market’s excess return dividedby its variance:

To calculate the market-implied returns, we then use the following formula:

[Pi = delta Sigma w_{mkt}]

Here, (w_{mkt}) denotes the market-cap weights. This formula is calculating the totalamount of risk contributed by an asset and multiplying it with the market price of risk,resulting in the market-implied returns vector (Pi). We can use PyPortfolioOpt to calculatethis as follows:

There is nothing stopping you from using any prior you see fit (but it must have the same dimensionality as the universe).If you think that the mean historical returns are a good prior,you could go with that. But a significant body of research shows that mean historical returns are a completely uninformativeprior.

Black

Note

You don’t technically have to provide a prior estimate to the Black-Litterman model. This is particularly usefulif your views (and confidences) were generated by some proprietary model, in which case BL is essentially a clever wayof mixing your views.

Views¶

In the Black-Litterman model, users can either provide absolute or relative views. Absolute views are statements like:“AAPL will return 10%” or “XOM will drop 40%”. Relative views, on the other hand, are statements like “GOOG will outperform FB by 3%”.

These views must be specified in the vector (Q) and mapped to the asset universe via the picking matrix (P). A briefexample of this is shown below, though a comprehensive guide is given by Idzorek.Let’s say that our universe is defined by the ordered list: SBUX, GOOG, FB, AAPL, BAC, JPM, T, GE, MSFT, XOM. We want to representfour views on these 10 assets, two absolute and two relative:

  1. SBUX will drop 20% (absolute)
  2. MSFT will rise by 5% (absolute)
  3. GOOG outperforms FB by 10%
  4. BAC and JPM will outperform T and GE by 15%

The corresponding views vector is formed by taking the numbers above and putting them into a column:

The picking matrix is more interesting. Remember that its role is to link the views (which mention 8 assets) to the universe of 10assets. Arguably, this is the most important part of the model because it is what allows us to propagate our expectations (andconfidences in expectations) into the model:

A brief explanation of the above:

  • Each view has a corresponding row in the picking matrix (the order matters)
  • Absolute views have a single 1 in the column corresponding to the ticker’s order in the universe.
  • Relative views have a positive number in the nominally outperforming asset columns and a negative numberin the nominally underperforming asset columns. The numbers in each row should sum up to 0.

PyPortfolioOpt provides a helper method for inputting absolute views as either a dict or pd.Series –if you have relative views, you must build your picking matrix manually:

Confidence matrix and tau¶

The confidence matrix is a diagonal covariance matrix containing the variances of each view. One heuristic for calculating(Omega) is to say that is proportional to the variance of the priors. This is reasonable - quantities that movearound a lot are harder to forecast! Hence PyPortfolioOpt does not require you to input a confidence matrix, and defaults to:

Alternatively, we provide an implementation of Idzorek’s method [1]. This allows you to specify your view uncertainties aspercentage confidences. To use this, choose omega='idzorek' and pass a list of confidences (from 0 to 1) into the view_confidencesparameter.

You are of course welcome to provide your own estimate. This is particularly applicable if your views are the outputof some statistical model, which may also provide the view uncertainty.

Another parameter that controls the relative weighting of the priors views is (tau). There is a lot to be said about tuningthis parameter, with many contradictory rules of thumb. Indeed, there has been an entire paper written on it [3]. We choosethe sensible default (tau = 0.05).

Note

If you use the default estimate of (Omega), or omega='idzorek', it turns out that the value of (tau) does not matter. Thisis a consequence of the mathematics: the (tau) cancels in the matrix multiplications.

Output of the BL model¶

The BL model outputs posterior estimates of the returns and covariance matrix. The default suggestion in the literature is tothen input these into an optimizer (see General Efficient Frontier). A quick alternative, which is quite useful for debugging, isto calculate the weights implied by the returns vector [4]. It is actually the reverse of the procedure we used to calculate thereturns implied by the market weights.

In PyPortfolioOpt, this is available under BlackLittermanModel.bl_weights(). Because the BlackLittermanModel classinherits from BaseOptimizer, this follows the same API as the EfficientFrontier objects:

Documentation reference¶

The black_litterman module houses the BlackLittermanModel class, whichgenerates posterior estimates of expected returns given a prior estimate and user-suppliedviews. In addition, two utility functions are defined, which calculate:

  • market-implied prior estimate of returns
  • market-implied risk-aversion parameter
class pypfopt.black_litterman.BlackLittermanModel(cov_matrix, pi=None, absolute_views=None, Q=None, P=None, omega=None, view_confidences=None, tau=0.05, risk_aversion=1, **kwargs)[source]

A BlackLittermanModel object (inheriting from BaseOptimizer) contains requiresa specific input format, specifying the prior, the views, the uncertainty in views,and a picking matrix to map views to the asset universe. We can then computeposterior estimates of returns and covariance. Helper methods have been providedto supply defaults where possible.

Instance variables:

  • Inputs:

    • cov_matrix - np.ndarray
    • n_assets - int
    • tickers - str list
    • Q - np.ndarray
    • P - np.ndarray
    • pi - np.ndarray
    • omega - np.ndarray
    • tau - float
  • Output:

    • posterior_rets - pd.Series
    • posterior_cov - pd.DataFrame
    • weights - np.ndarray

Black Litterman Model Excel Pdf

Public methods:

  • default_omega() - view uncertainty proportional to asset variance
  • idzorek_method() - convert views specified as percentages into BL uncertainties
  • bl_returns() - posterior estimate of returns
  • bl_cov() - posterior estimate of covariance
  • bl_weights() - weights implied by posterior returns
  • portfolio_performance() calculates the expected return, volatilityand Sharpe ratio for the allocated portfolio.
  • set_weights() creates self.weights (np.ndarray) from a weights dict
  • clean_weights() rounds the weights and clips near-zeros.
  • save_weights_to_file() saves the weights to csv, json, or txt.
__init__(cov_matrix, pi=None, absolute_views=None, Q=None, P=None, omega=None, view_confidences=None, tau=0.05, risk_aversion=1, **kwargs)[source]
Parameters:
  • cov_matrix (pd.DataFrame or np.ndarray) – NxN covariance matrix of returns
  • pi (np.ndarray, pd.Series, optional) – Nx1 prior estimate of returns, defaults to None.If pi=”market”, calculate a market-implied prior (requires market_capsto be passed).If pi=”equal”, use an equal-weighted prior.
  • absolute_views (pd.Series or dict, optional) – a colleciton of K absolute views on a subset of assets,defaults to None. If this is provided, we do not need P, Q.
  • Q (np.ndarray or pd.DataFrame, optional) – Kx1 views vector, defaults to None
  • P (np.ndarray or pd.DataFrame, optional) – KxN picking matrix, defaults to None
  • omega (np.ndarray or Pd.DataFrame, or string, optional) – KxK view uncertainty matrix (diagonal), defaults to NoneCan instead pass “idzorek” to use Idzorek’s method (requiresyou to pass view_confidences). If omega=”default” or None,we set the uncertainty proportional to the variance.
  • view_confidences (np.ndarray, pd.Series, list, optional) – Kx1 vector of percentage view confidences (between 0 and 1),required to compute omega via Idzorek’s method.
  • tau (float, optional) – the weight-on-views scalar (default is 0.05)
  • risk_aversion (positive float, optional) – risk aversion parameter, defaults to 1
  • market_caps (np.ndarray, pd.Series, optional) – (kwarg) market caps for the assets, required if pi=”market”
  • risk_free_rate (float, defaults to 0.02) – (kwarg) risk_free_rate is needed in some methods

Caution

You must specify the covariance matrix and either absolute views or both Q and P, except in the special casewhere you provide exactly one view per asset, in which case P is inferred.

bl_cov()[source]

Calculate the posterior estimate of the covariance matrix,given views on some assets. Based on He and Litterman (2002).It is assumed that omega is diagonal. If this is not the case,please manually set omega_inv.

Black Litterman Model Excel

Returns:posterior covariance matrix
Return type:pd.DataFrame
bl_returns()[source]

Calculate the posterior estimate of the returns vector,given views on some assets.

Returns:posterior returns vector
Return type:pd.Series
Model

Black Litterman Model Excel 2017

bl_weights(risk_aversion=None)[source]

Compute the weights implied by the posterior returns, given themarket price of risk. Technically this can be applied to anyestimate of the expected returns, and is in fact a special caseof mean-variance optimization

Parameters:risk_aversion (positive float, optional) – risk aversion parameter, defaults to 1
Returns:asset weights implied by returns
Return type:OrderedDict
static default_omega(cov_matrix, P, tau)[source]

If the uncertainty matrix omega is not provided, we calculate using the method ofHe and Litterman (1999), such that the ratio omega/tau is proportional to thevariance of the view portfolio.

Returns:KxK diagonal uncertainty matrix
Return type:np.ndarray
static idzorek_method(view_confidences, cov_matrix, pi, Q, P, tau, risk_aversion=1)[source]

Use Idzorek’s method to create the uncertainty matrix given user-specifiedpercentage confidences. We use the closed-form solution described byJay Walters in The Black-Litterman Model in Detail (2014).

Parameters:view_confidences (np.ndarray, pd.Series, list,, optional) – Kx1 vector of percentage view confidences (between 0 and 1),required to compute omega via Idzorek’s method.
Returns:KxK diagonal uncertainty matrix
Return type:np.ndarray

Black Litterman Model Excel Example

optimize(risk_aversion=None)[source]

Alias for bl_weights for consistency with other methods.

portfolio_performance(verbose=False, risk_free_rate=0.02)[source]

After optimising, calculate (and optionally print) the performance of the optimalportfolio. Currently calculates expected return, volatility, and the Sharpe ratio.This method uses the BL posterior returns and covariance matrix.

Parameters:
  • verbose (bool, optional) – whether performance should be printed, defaults to False
  • risk_free_rate (float, optional) – risk-free rate of borrowing/lending, defaults to 0.02.The period of the risk-free rate should correspond to thefrequency of expected returns.
Raises:

ValueError – if weights have not been calcualted yet

Returns:

expected return, volatility, Sharpe ratio.

Return type:

(float, float, float)

pypfopt.black_litterman.market_implied_prior_returns(market_caps, risk_aversion, cov_matrix, risk_free_rate=0.02)[source]

Compute the prior estimate of returns implied by the market weights.In other words, given each asset’s contribution to the risk of the marketportfolio, how much are we expecting to be compensated?

[Pi = delta Sigma w_{mkt}]
Parameters:
  • market_caps ({ticker: cap} dict or pd.Series) – market capitalisations of all assets
  • risk_aversion (positive float) – risk aversion parameter
  • cov_matrix (pd.DataFrame) – covariance matrix of asset returns
  • risk_free_rate (float, optional) – risk-free rate of borrowing/lending, defaults to 0.02.You should use the appropriate time period, correspondingto the covariance matrix.
Returns:

prior estimate of returns as implied by the market caps

Return type:

pd.Series

pypfopt.black_litterman.market_implied_risk_aversion(market_prices, frequency=252, risk_free_rate=0.02)[source]

Calculate the market-implied risk-aversion parameter (i.e market price of risk)based on market prices. For example, if the market has excess returns of 10% a yearwith 5% variance, the risk-aversion parameter is 2, i.e you have to be compensated 2xthe variance.

Parameters:
  • market_prices (pd.Series with DatetimeIndex.) – the (daily) prices of the market portfolio, e.g SPY.
  • frequency (int, optional) – number of time periods in a year, defaults to 252 (the numberof trading days in a year)
  • risk_free_rate (float, optional) – risk-free rate of borrowing/lending, defaults to 0.02.The period of the risk-free rate should correspond to thefrequency of expected returns.
Raises:

TypeError – if market_prices cannot be parsed

Returns:

market-implied risk aversion

Return type:

float

References¶

Model
[1](1, 2) Idzorek T. A step-by-step guide to the Black-Litterman model: Incorporating user-specified confidence levels. In: Forecasting Expected Returns in the Financial Markets. Elsevier Ltd; 2007. p. 17–38.
[2]Black, F; Litterman, R. Combining investor views with market equilibrium. The Journal of Fixed Income, 1991.
[3]Walters, Jay, The Factor Tau in the Black-Litterman Model (October 9, 2013). Available at SSRN: https://ssrn.com/abstract=1701467 or http://dx.doi.org/10.2139/ssrn.1701467

Black Litterman Model Excel Download

[4]Walters J. The Black-Litterman Model in Detail (2014). SSRN Electron J.;(February 2007):1–65.

Comments are closed.