Black-Litterman
Calculate the Black-Litterman expected returns and the weights they lead to. The starting point is the return the market implies through its capitalization weights: the excess return Π = δΣw_mkt at which holding the market is optimal, plus the risk free rate, so the Implied Return is a total return. Views then move these returns towards the investor’s expectations, in proportion to the confidence in each view. The result avoids the extreme weights that historical average returns give.
Views are absolute ({“AAPL”: 0.10}: AAPL returns 10% a year in total, risk free rate included) or relative ({“AAPL-MSFT”: 0.02}: AAPL beats MSFT by 2% a year). Without a confidence, a view is as uncertain as the variance of the view portfolio scaled by tau; a confidence c scales that by (1 - c) / c, Idzorek’s confidence method in the closed form of Walters (2014). The weights are the mean-variance portfolio of the Black-Litterman returns with the same risk aversion. Without views, or with relative views only, the risk free rate shifts every return by the same amount and leaves the weights unchanged; an absolute view is compared with the implied total return, so there it matters.
The risk aversion is 2.5 by default, the value He and Litterman (1999) use for the world market, or the one the benchmark implies with risk_aversion=”market”: δ = (E[r_m] - r_f) / σ²_m, the benchmark’s annualized average excess return over its annualized variance on the same periods as the assets.
The Posterior Volatility is the square root of the diagonal of the posterior covariance matrix Σ + M (He and Litterman, 1999), with M = ((τΣ)⁻¹ + P’Ω⁻¹P)⁻¹ the uncertainty that remains in the Black-Litterman returns: the volatility to expect for each asset once the estimation error of its return is counted too. The weights use Σ itself, so that without views they are the market weights.
For more information, see the following papers:
- Black, F. and Litterman, R. (1992). “Global Portfolio Optimization.” Financial Analysts Journal, 48(5), 28-43.
- He, G. and Litterman, R. (1999). “The Intuition Behind Black-Litterman Model Portfolios.” Goldman Sachs Investment Management Research.
- Idzorek, T. (2005). “A Step-by-Step Guide to the Black-Litterman Model: Incorporating User-Specified Confidence Levels.” Working paper.
- Walters, J. (2014). “The Black-Litterman Model in Detail.” https://ssrn.com/abstract=1314585
Also known as: BL model, equilibrium returns with views.
Black-Litterman in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_black_litterman_weights as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["AAPL", "MSFT", "JNJ", "XOM"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.portfolio.get_black_litterman_weights(
views={"XOM": 0.10, "AAPL-MSFT": 0.02}
)
Or, after setting up the Finance Toolkit MCP, ask:
What Black-Litterman weights do Apple, Microsoft, Johnson & Johnson and ExxonMobil get with the views that ExxonMobil returns 10% and Apple beats Microsoft by 2 percentage points, based on 2021 to 2025?
Which returns:
| Market Weight | Implied Return | Black-Litterman Return | Posterior Volatility | Weight | |
|---|---|---|---|---|---|
| AAPL | 0.4861 | 0.1751 | 0.1772 | 0.2846 | 0.4727 |
| MSFT | 0.3834 | 0.1538 | 0.1556 | 0.2631 | 0.3768 |
| JNJ | 0.0647 | 0.0511 | 0.0522 | 0.1714 | 0.016 |
| XOM | 0.0658 | 0.0697 | 0.0847 | 0.2736 | 0.1345 |
Parameters
get_black_litterman_weights accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
views | dict[str, float] | None | The annualized views, absolute views as total returns, as described above. Defaults to None, which returns the market implied returns. | None, which returns the market implied returns |
view_confidences | dict[str, float] | None | The confidence per view, between 0 and 1. Defaults to None, which sets each view’s uncertainty to the variance of the view scaled by tau. | None, which sets each view's uncertainty to the variance of the view scaled by tau |
market_weights | dict[str, float] | None | The market weight per asset. Defaults to None, which uses the market capitalizations of the assets. | None, which uses the market capitalizations of the assets |
risk_aversion | float | str | The risk aversion δ of the market, or “market” for the one the benchmark implies, (E[r_m] - r_f) / σ²_m, with the benchmark’s arithmetic average return and variance (ddof=1) per period both annualized by the number of periods in a year. Defaults to 2.5. | 2.5 |
tau | float | The uncertainty of the implied returns relative to the covariance matrix. Defaults to 0.05. | 0.1 |
period | str | The frequency of the returns the covariance matrix is estimated from. Defaults to “daily”. | "weekly" |
covariance | str | The estimator of the covariance matrix: “sample” (ddof=1), “ledoit_wolf” (towards the scaled identity, Ledoit and Wolf, 2004), “ledoit_wolf_constant_correlation” (towards the average correlation, Ledoit and Wolf, 2004), “ledoit_wolf_single_factor” (towards the covariance that the benchmark as a single factor implies, Ledoit and Wolf, 2003), “oas” (Chen et al., 2010), “semicovariance” (the co-movement below a zero return, Estrada, 2007), “exponential” (recent periods weigh most, RiskMetrics) or “denoised” (the eigenvalues of the correlation matrix that random returns could produce averaged, Laloux et al., 2000). The shrinkage and denoised estimators stabilize the weights when there are many assets compared to the number of periods. Defaults to “sample”. | "sample" |
covariance_span | int | The span in periods of the “exponential” covariance; the weight of a period halves after about span / 2.9 periods. Defaults to 180. | 180 |
minimum_weight | float | dict[str, float] | The lowest weight of every asset, or per asset, e.g. {“AAPL”: 0.05} (the others keep 0); a negative value allows short positions. Defaults to 0. | 0 |
maximum_weight | float | dict[str, float] | The highest weight of every asset, or per asset, e.g. {“AAPL”: 0.3} (the others keep 1). Defaults to 1. | 1 |
sector_bounds | dict[str, tuple[float, float]] | None | The minimum and maximum total weight per sector, e.g. {“Technology”: (0, 0.4)}, with the sector of each asset from its company profile. Defaults to None. | None |
country_bounds | dict[str, tuple[float, float]] | None | The minimum and maximum total weight per country, named in full or by its two-letter code, e.g. {“United States”: (0, 0.6)}, with the country of each asset from its company profile. Defaults to None. | None |
net_exposure | float | The sum of the weights: 1 for a fully invested portfolio, 0 for a market neutral one (which needs a negative minimum_weight). Defaults to 1. | 1 |
gross_exposure | float | None | The highest sum of the absolute weights, which limits the leverage of a long-short portfolio, e.g. 1.6 for a 130/30 portfolio. Defaults to None, no limit. | None, no limit |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the Toolkit’s rounding. | 2 |