Black-Litterman Prior
PortfolioOptimisers.BlackLittermanPrior — Type
struct BlackLittermanPrior{__T_pe, __T_mp, __T_views, __T_sets, __T_views_conf, __T_rf, __T_tau, __T_x_src} <: AbstractLowOrderPriorEstimator_AFBlack-Litterman prior estimator for asset returns.
BlackLittermanPrior is a low order prior estimator. It fits the wrapped prior pe, and it updates the asset mean and covariance of that prior with views on the assets. The views are view equations in a LinearConstraintEstimator, or a precomputed BlackLittermanViews. views_conf sets the confidence of the views, tau scales the uncertainty of the prior mean, and rf shifts the posterior mean. mp processes the posterior covariance.
Black and Litterman [59] state the posterior mean as the precision-weighted blend of the prior and the views. The library computes the equivalent update form of Walters [152]. Black and Litterman [59] give no posterior covariance. The library returns the prior covariance plus the posterior covariance of the mean, which is the convention of Walters [152]. He and Litterman [153] set the view uncertainty to $\tau\,\mathrm{Diag}(\mathbf{P}\mathbf{\Sigma}\mathbf{P}^\intercal)$. The library does the same when views_conf is nothing. Cajas [12] sets tau to 1/T, which is the library default. A confidence v in views_conf scales that uncertainty by 1/v - 1. This is the closed form of Walters [152] for the method of Idzorek [154], which finds the uncertainty of each view by a numerical search for the weight tilt that the confidence asks for. Idzorek [154] also gives the meaning of the confidence: the fraction of the full tilt towards the view.
Fields
pe: Prior estimator.
mp: Matrix processing estimator.
views: The views, aLinearConstraintEstimatorof view equations or a precomputedBlackLittermanViews.
sets: Sets used to map estimator values to assets.
views_conf: The confidence of the views, in(0, 1), ornothing. A number is one confidence for all the views, and a vector holds one confidence for each view that the caller wrote. Ifnothing, the view uncertainty has no confidence scale, seecalc_omega.
rf: Risk-free rate. The Black-Litterman update compares the prior mean with the view returns, so it uses the total-return scale of the views. A mean from a wrapped prior estimator has that scale. An equilibrium mean is only a risk premium, and the rate converts it before the update. A member with no equilibrium branch has no mean to convert, and it adds the rate to the posterior asset expected returns. In both cases the estimator adds the rate once. It does not change the wrapped prior estimators, so a risk-free rate that one of them applied stays in its mean.
tau: The scale of the uncertainty of the prior mean,tau > 0. Ifnothing, the estimator uses1/T, whereTis the number of observations.
x_src: The source of the returns that the prior fits on,nothingor anAbstractReturnsSource.nothingandDataSourceread the asset returnsrd.X.ExcessSourcereads the returns in excess of the benchmark,rd.X - rd.B, the Excess Frame, and refuses returns data with no benchmark.nothingmeans that the caller stated no source, so an optimiser that holds a reader of the Excess Frame warns about a prior atnothing, and not about a prior atDataSource(). A prior reads no prior, so it refusesPriorSource. A prior inside another estimator, such as thepeof aFactorPrior, keepsnothing, and the outer estimator states the source.
Constructors
BlackLittermanPrior(; pe::Onl{<:AbstractLowOrderPriorEstimator_A_F_AF} = EmpiricalPrior(; me = EquilibriumExpectedReturns() ), mp::AbstractMatrixProcessingEstimator = MatrixProcessing(), views::Lc_BLV, sets::Option{<:UniverseSets} = nothing, views_conf::Option{<:Num_VecNum} = nothing, rf::Number = 0.0, tau::Option{<:Number} = nothing, x_src::Option{<:AbstractReturnsSource} = nothing) -> BlackLittermanPriorKeywords correspond to the struct's fields.
Composition: what this estimator forwards
The views update the assets. The estimator forwards the full result of the wrapped prior, with three changes. mu and sigma become the posterior. The estimator drops chol, because the posterior covariance replaces the covariance that chol factorises. Black-Litterman does not change the observation axis, so w, ens, kld and ow still describe the axis that the wrapped prior fitted them over. rr and the factor block fpr are structural: they come from data that the views do not change.
mu and sigma of the result are the Black-Litterman posterior, but w holds the observation weights of the wrapped prior, with no change. Black-Litterman makes no posterior over the observations, so no other weights agree with the update. Without w, a reader uses the unweighted empirical distribution, which is further from the intent of the caller than the weights that the caller computed. Thus pr.w, pr.ens, pr.kld and pr.ow describe the prior, not the posterior.
When the wrapped prior has a factor block, pr.fpr describes the prior factor distribution, but pr.mu is a posterior asset mean, so pr.mu != pr.rr.M * pr.fpr.mu + pr.rr.b. The block is still true as a structure, because the regression uses data that Black-Litterman does not change. But as a distribution it does not agree with the asset block. The estimator has no better block to report: the views update the assets, so the estimator does not compute a posterior factor distribution.
The other members are different. FactorBlackLittermanPrior and BayesianBlackLittermanPrior apply their views to the factors and report the posterior factor block, so mu == rr.M * fpr.mu + rr.b holds exactly for both. AugmentedBlackLittermanPrior also reports a posterior factor block, but its blocks do not agree, for a different reason that its own warning states.
Validation
- If
viewsis aLinearConstraintEstimator,!isnothing(sets). - If
views_confis notnothing,assert_bl_views_confchecks it. - If
tauis notnothing,tau > 0. x_srcisnothing,DataSource()orExcessSource(), seeassert_returns_source.- The
x_srcofpeisnothing, because the prior picks the returns that it reads, seeassert_inner_reader.
Propagated parameters
factory passes its arguments on to these @fprop fields:
pe: Recursively updated throughfactory.
View parameters
port_opt_view takes the view of these @vprop fields at the selected indices:
pe: Recursively viewed throughport_opt_view.sets: Sliced to the selected indices throughport_opt_view.
Examples
julia> BlackLittermanPrior(; sets = UniverseSets(; xkey = "nx", dict = Dict("nx" => ["A", "B", "C"])), views = LinearConstraintEstimator(; val = ["A == 0.03", "B + C == 0.04"]))BlackLittermanPrior pe ┼ EmpiricalPrior │ ce ┼ PortfolioOptimisersCovariance │ │ ce ┼ Covariance │ │ │ me ┼ SimpleExpectedReturns │ │ │ │ w ┴ nothing │ │ │ ce ┼ GeneralCovariance │ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true) │ │ │ │ w ┴ nothing │ │ │ alg ┼ FullMoment() │ │ │ w ┴ nothing │ │ mp ┼ MatrixProcessing │ │ │ pdm ┼ Posdef │ │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton │ │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ │ │ dn ┼ nothing │ │ │ dt ┼ nothing │ │ │ alg ┼ nothing │ │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg) │ me ┼ EquilibriumExpectedReturns │ │ ce ┼ PortfolioOptimisersCovariance │ │ │ ce ┼ Covariance │ │ │ │ me ┼ SimpleExpectedReturns │ │ │ │ │ w ┴ nothing │ │ │ │ ce ┼ GeneralCovariance │ │ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true) │ │ │ │ │ w ┴ nothing │ │ │ │ alg ┼ FullMoment() │ │ │ │ w ┴ nothing │ │ │ mp ┼ MatrixProcessing │ │ │ │ pdm ┼ Posdef │ │ │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton │ │ │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ │ │ │ dn ┼ nothing │ │ │ │ dt ┼ nothing │ │ │ │ alg ┼ nothing │ │ │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg) │ │ w ┼ nothing │ │ l ┴ Int64: 1 │ horizon ┼ nothing │ fill_limit ┼ nothing │ x_src ┴ nothing mp ┼ MatrixProcessing │ pdm ┼ Posdef │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ dn ┼ nothing │ dt ┼ nothing │ alg ┼ nothing │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg) views ┼ LinearConstraintEstimator │ val ┼ Vector{String}: ["A == 0.03", "B + C == 0.04"] │ key ┴ nothing sets ┼ UniverseSets │ xkey ┼ String: "nx" │ uxkey ┼ String: "ux" │ tfkey ┼ String: "nf" │ utfkey ┼ String: "uf" │ cfkey ┼ String: "ncf" │ ucfkey ┼ String: "ucf" │ nikey ┼ String: "ni" │ dict ┴ Dict{String, Vector{String}}: Dict("nx" => ["A", "B", "C"]) views_conf ┼ nothing rf ┼ Float64: 0.0 tau ┼ nothing x_src ┴ nothingRelated
AbstractLowOrderPriorEstimator_AFEmpiricalPriorBlackLittermanViewsUniverseSetsLowOrderPriorpriorfactoryport_opt_view
References
- [59] F. Black and R. Litterman. Global asset allocation with equities, bonds, and currencies. Goldman, Sachs & Co., Fixed Income Research (1991). Appendix, items 7 and 8. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
- [153] G. He and R. Litterman. The Intuition Behind Black-Litterman Model Portfolios. Technical Report (Goldman Sachs Investment Management Research, 1999). Footnote 6.
- [152] J. Walters. The Black-Litterman model in detail. SSRN Electronic Journal (2011). Equations 25 to 27, 41 and 44. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
- [154] T. Idzorek. A step-by-step guide to the Black-Litterman model: incorporating user-specified confidence levels. In: Forecasting Expected Returns in the Financial Markets (Academic Press, 2007); pp. 17–38. Section 3.2.
- [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 5.1.3, Equation 5.6, and Section 5.1.2, footnote 1.
PortfolioOptimisers.prior — Function
prior(pe::BlackLittermanPrior, X::MatNum, F::Option{<:MatNum} = nothing,
pnl::Option{<:AssetPanel} = nothing;
dims::Int = 1, strict::Bool = false, kwargs...)Fit the Black-Litterman posterior of the asset returns.
When pe.tau is nothing, tau is 1/T, where T is the effective number of observations of the mean of the wrapped prior, eoc[1] of its result. It is the number of rows of X in that result when the result states no count. pe.rf changes the result once, on the posterior asset expected returns. apply_rf states that rule.
Mathematical definition
The Black-Litterman posterior combines the prior $(\boldsymbol{\Pi}, \tau \mathbf{\Sigma})$ with the views $(\mathbf{P}, \boldsymbol{q}, \mathbf{\Omega})$. The equations below are the precision form. vanilla_posteriors computes the inverse-free form, which is algebraically equal:
\[\begin{align} \hat{\boldsymbol{\mu}}_{BL} &= \left[(\tau\mathbf{\Sigma})^{-1} + \mathbf{P}^\intercal \mathbf{\Omega}^{-1} \mathbf{P}\right]^{-1} \left[(\tau\mathbf{\Sigma})^{-1} \boldsymbol{\Pi} + \mathbf{P}^\intercal \mathbf{\Omega}^{-1} \boldsymbol{q}\right]\,. \end{align}\]
\[\begin{align} \hat{\mathbf{\Sigma}}_{BL} &= \mathbf{\Sigma} + \left[(\tau\mathbf{\Sigma})^{-1} + \mathbf{P}^\intercal \mathbf{\Omega}^{-1} \mathbf{P}\right]^{-1}\,. \end{align}\]
Where:
- $\boldsymbol{\Pi}$:
N × 1prior (equilibrium) expected returns. - $\mathbf{\Sigma}$:
N × Nprior covariance matrix. - $\tau$: Scaling parameter for the uncertainty in the prior.
- $\mathbf{P}$:
K × Nviews matrix (each row is one view). - $\boldsymbol{q}$:
K × 1views vector. - $\mathbf{\Omega}$:
K × Kviews uncertainty matrix.
Algorithm
- Orient
XandFwithdims_oriented, toobservations × assetsandobservations × factors. - When
pe.viewsresolves names, check that the length of the asset universe is equal to the number of columns ofX, withassert_bl_views_axis. A precomputedBlackLittermanViewsresolves no name, so this step does not check it.bl_prerollchecks its width in step 6. - Fit the wrapped prior
pe.peon(X, F). The result isprior_model. - Derive the Investable Mask and the reduced view universe with
investable_views. Refuse a precomputed view matrix over a universe with a departed asset, withassert_bl_precomputed_universe. - View the fitted prior at the mask with
investable_prior, and readposterior_X,prior_muandprior_sigmafrom that result. - Assemble the views and their uncertainty with
bl_preroll, over the reducedprior_sigma, withTequal to the number of rows ofprior_model.X. The result isP,Q,tauandomega, ornothingwhen no view is left. The axis keeps its default,:xkey, because these views update the assets. - Run the master equations with
vanilla_posteriors. The result isposterior_muandposterior_sigmaover the investable assets. - Add
pe.rftoposterior_muwithapply_rf. This is the one site that adds it. - Process
posterior_sigmain place withsample_matrix_processing!, underpe.mp,posterior_Xand the count of the covariance of the wrapped prior frommoment_observation_count. Do this before the expansion, because a factorisation exists only for the reduced block. - Report the departures once with
announce_bl_departures. - Write both posteriors back onto the full asset universe with
expand_moment, so a non-investable asset carriesNaNinmuand on the diagonal ofsigma. - Forward the whole of
prior_modelwithforward_prior, replacingmuandsigmaby the expanded pair and droppingchol.
Arguments
pe: Black-Litterman prior estimator.X: Asset returns matrix (observations × assets).F: Optional factor matrix.pnl: OptionalAssetPanel, the panel that the returns data held. A wrapping prior forwards it unchanged, so that it can compose an estimator that is fitted on a panel. An estimator that reads no panel ignores it.dims: Dimension along which the computation runs.strict: Iftrue, a view name that does not resolve raises an error. Iffalse, it warns. The method also passesstrictto the wrapped prior.kwargs...: More keyword arguments, for the wrapped prior and for the matrix processing.
Validation
dims in (1, 2).- If
pe.viewsis aLinearConstraintEstimator,length(pe.sets.dict[pe.sets.xkey]) == size(X, 2). Raises aDimensionMismatch. - If
pe.setsisnothing, each asset of the result of the wrapped prior is investable, seeassert_bl_precomputed_universe. - The number of columns of a precomputed
Pis equal to the number of investable assets, seebl_preroll.
Returns
pr::LowOrderPrior: The result of the wrapped prior, with the posterior mean inmu, the posterior covariance insigma, andchol = nothing.
Related
BlackLittermanPriorLowOrderPriorpriorbl_prerollAssemblesP,Q,tauandomega, and resolvespe.tauto1/Twhen the estimator carries none.calc_omegavanilla_posteriorsapply_rfforward_prior
References
- [12]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
- [59]
- F. Black and R. Litterman. Global asset allocation with equities, bonds, and currencies (Goldman, Sachs & Co., Fixed Income Research, Oct 1991).
- [152]
- J. Walters. The Black-Litterman model in detail. SSRN Electronic Journal (2011).
- [153]
- G. He and R. Litterman. The Intuition Behind Black-Litterman Model Portfolios (Goldman Sachs Investment Management Research, 1999).
- [154]
- T. Idzorek. A step-by-step guide to the Black-Litterman model: incorporating user-specified confidence levels. In: Forecasting Expected Returns in the Financial Markets (Academic Press, 2007); pp. 17–38.