Black-Litterman Views Generation

PortfolioOptimisers.BlackLittermanViews — Type
struct BlackLittermanViews{__T_P, __T_Q, __T_excl} <: AbstractResult

Black-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 of P.
  • excl: Indices of the views that P and Q do not hold, or nothing. The indices count over all the views that the caller wrote, so excl can be longer than Q.

Constructors

BlackLittermanViews(;    P::MatNum,    Q::VecNum,    excl::Option{<:VecInt} = nothing) -> BlackLittermanViews

Keywords correspond to the struct's fields.

Validation

  • !isempty(P) and !isempty(Q). Raises an IsEmptyError.
  • size(P, 1) == length(Q). Raises a DimensionMismatch.
  • If excl is not nothing:
    • !isempty(excl). Raises an IsEmptyError.
    • allunique(excl). Raises an ArgumentError.
    • Each entry of excl is in 1:(length(Q) + length(excl)). Raises a DomainError.

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 ┴ nothing

Related

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.
source
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

  1. When views is nothing or a BlackLittermanViews, return it unchanged. The caller assembled the pair over its own universe, and this function cannot check it. The method ignores sets, key, datatype, strict and ledger.
  2. When views is a LinearConstraintEstimator, select the key: views.key when it is not nothing, and the key argument otherwise. Do step 3 on views.val with that key.
  3. When views is an EqnType, parse it with parse_equation under the == operator alone. The result is the parsed views lcs. A Black-Litterman view is an equality, so the function accepts no inequality operator.
  4. Replace each group name in lcs by its member assets with replace_group_by_assets, under sets. 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.
  5. Assemble the pair from lcs with get_black_litterman_views, under the key of step 2, and return its result.

Arguments

  • views:

    • nothing or BlackLittermanViews: The method returns it unchanged. The caller assembled a precomputed P over its own universe, and this function cannot check it.
    • EqnType: The method parses the equations, replaces each group by its member assets with sets, and assembles the pair with get_black_litterman_views.
    • LinearConstraintEstimator: The method calls the EqnType method on the val field of the estimator. When the key field of the estimator is not nothing, it takes precedence over the key argument. rebase_linear_constraints uses the same precedence: the argument is the axis that the caller uses, and the field is the override of the user.
  • sets: The UniverseSets that the names and the groups resolve against.

  • key: Key of the universe in sets.dict that names resolve against. If nothing, the caller reads the key from sets.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 to get_black_litterman_views, which states what it raises.

  • ledger: The Departure Ledger of the entry of the fit, or nothing when no caller collects the drops. The method passes it to replace_group_by_assets and to get_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, or nothing when 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 ┴ nothing

Related

source

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).