Black-Litterman Views Generation
PortfolioOptimisers.BlackLittermanViews — Type
struct BlackLittermanViews{__T_P, __T_Q, __T_excl} <: AbstractResultBlack-Litterman views in matrix form: the views matrix P and the view returns Q.
Each row of P holds the coefficients of one view over the names of one axis, assets or factors. The same entry of Q holds the expected return of that view. black_litterman_views assembles the pair from view equations. A caller can also construct the pair, and a Black-Litterman prior estimator then uses it as it is.
Mathematical definition
This type stores the pair $(\mathbf{P}, \boldsymbol{q})$ of the view creation model:
\[\begin{align} \mathbf{P}\,\boldsymbol{\mu}_{e} &= \boldsymbol{q} + \boldsymbol{\nu}\,. \end{align}\]
Where:
- $\mathbf{P}$: $K \times N$ views matrix (each row encodes one view).
- $\boldsymbol{\mu}_{e}$: $N \times 1$ prior expected excess returns vector.
- $\boldsymbol{q}$: $K \times 1$ vector of view expected returns.
- $\boldsymbol{\nu}$: $K \times 1$ estimation error of the views.
Black and Litterman [59] write the estimation error of the views as $\boldsymbol{\varepsilon}$. The name "view creation model" and the symbol $\boldsymbol{\nu}$ come from Cajas [12].
This type does not hold the view uncertainty matrix $\boldsymbol{\Omega}$. calc_omega and bl_preroll make it from $\mathbf{P}$ and from the covariance of the distribution that the views update.
excl holds the indices of the views that the caller wrote and that P and Q do not hold. The indices count over all the views that the caller wrote, so excl can be longer than Q. remove_excl_views reads excl to remove the confidences of those views.
Fields
P: Views matrix,views × n, with one column for each name of the axis that the views update.
Q: View returns, one for each row ofP.
excl: Indices of the views thatPandQdo not hold, ornothing. The indices count over all the views that the caller wrote, soexclcan be longer thanQ.
Constructors
BlackLittermanViews(; P::MatNum, Q::VecNum, excl::Option{<:VecInt} = nothing) -> BlackLittermanViewsKeywords correspond to the struct's fields.
Validation
!isempty(P)and!isempty(Q). Raises anIsEmptyError.size(P, 1) == length(Q). Raises aDimensionMismatch.- If
exclis notnothing:!isempty(excl). Raises anIsEmptyError.allunique(excl). Raises anArgumentError.- Each entry of
exclis in1:(length(Q) + length(excl)). Raises aDomainError.
Examples
julia> BlackLittermanViews(; P = [1 2 3 4; 5 6 7 8], Q = [9; 10])BlackLittermanViews P ┼ 2×4 Matrix{Int64} Q ┼ Vector{Int64}: [9, 10] excl ┴ nothingRelated
References
- [59] F. Black and R. Litterman. Global asset allocation with equities, bonds, and currencies. Goldman, Sachs & Co., Fixed Income Research (1991). Appendix, item 7. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
- [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 5.1.3, Equation 5.5.
PortfolioOptimisers.black_litterman_views — Function
black_litterman_views(views::Option{<:BlackLittermanViews}, args...; kwargs...)
black_litterman_views(views::EqnType, sets::UniverseSets,
key::Option{<:AbstractString} = nothing;
datatype::DataType = Float64, strict::Bool = false,
ledger::Option{<:AbstractVector} = nothing)
black_litterman_views(views::LinearConstraintEstimator, sets::UniverseSets,
key::Option{<:AbstractString} = nothing;
datatype::DataType = Float64, strict::Bool = false,
ledger::Option{<:AbstractVector} = nothing)Assemble Black-Litterman views into a BlackLittermanViews, or return precomputed views unchanged.
The two routes give the same pair. When a caller passes back the BlackLittermanViews that this function assembled from a LinearConstraintEstimator, it gets the same P and the same Q. A caller that precomputes the pair loses only the resolution of names.
Algorithm
- When
viewsisnothingor aBlackLittermanViews, return it unchanged. The caller assembled the pair over its own universe, and this function cannot check it. The method ignoressets,key,datatype,strictandledger. - When
viewsis aLinearConstraintEstimator, select the key:views.keywhen it is notnothing, and thekeyargument otherwise. Do step 3 onviews.valwith that key. - When
viewsis anEqnType, parse it withparse_equationunder the==operator alone. The result is the parsed viewslcs. A Black-Litterman view is an equality, so the function accepts no inequality operator. - Replace each group name in
lcsby its member assets withreplace_group_by_assets, undersets. That function removes the departed members of a group before it divides the coefficient of the group, so the coefficient is divided among the members that remain. - Assemble the pair from
lcswithget_black_litterman_views, under the key of step 2, and return its result.
Arguments
views:nothingorBlackLittermanViews: The method returns it unchanged. The caller assembled a precomputedPover its own universe, and this function cannot check it.EqnType: The method parses the equations, replaces each group by its member assets withsets, and assembles the pair withget_black_litterman_views.LinearConstraintEstimator: The method calls theEqnTypemethod on thevalfield of the estimator. When thekeyfield of the estimator is notnothing, it takes precedence over thekeyargument.rebase_linear_constraintsuses the same precedence: the argument is the axis that the caller uses, and the field is the override of the user.
sets: TheUniverseSetsthat the names and the groups resolve against.key: Key of the universe insets.dictthat names resolve against. Ifnothing, the caller reads the key fromsets.xkey, or from the key of another declared axis when the caller is written against that axis.datatype: The numeric type of the coefficients and of the view returns.strict: Passed toget_black_litterman_views, which states what it raises.ledger: The Departure Ledger of the entry of the fit, ornothingwhen no caller collects the drops. The method passes it toreplace_group_by_assetsand toget_black_litterman_views, so the ledger records a group that loses members and a row that the assembly drops.
Returns
blv::Option{<:BlackLittermanViews}: The assembled views, the input when it is precomputed, ornothingwhen no view is left.
Examples
julia> sets = UniverseSets(; xkey = "nx", dict = Dict("nx" => ["A", "B", "C"]));julia> black_litterman_views(["A + B == 0.05", "C == 0.02"], sets)BlackLittermanViews P ┼ 2×3 LinearAlgebra.Transpose{Float64, Matrix{Float64}} Q ┼ Vector{Float64}: [0.05, 0.02] excl ┴ nothingjulia> lce = LinearConstraintEstimator(; val = ["A == 0.03", "B + C == 0.04"]);julia> black_litterman_views(lce, sets)BlackLittermanViews P ┼ 2×3 LinearAlgebra.Transpose{Float64, Matrix{Float64}} Q ┼ Vector{Float64}: [0.03, 0.04] excl ┴ nothingRelated
BlackLittermanViewsget_black_litterman_viewsparse_equationreplace_group_by_assetsExpands a group name into its member assets.UniverseSetsLinearConstraintEstimatorLc_BLVThe union of the two shapes this function admits.
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).