Skip to content
18

Black-Litterman Prior

PortfolioOptimisers.BlackLittermanPrior Type
julia
struct BlackLittermanPrior{__T_pe, __T_mp, __T_views, __T_sets, __T_views_conf, __T_rf, __T_tau} <: AbstractLowOrderPriorEstimator_AF

Black-Litterman prior estimator for asset returns.

BlackLittermanPrior is a low order prior estimator that computes the mean and covariance of asset returns using the Black-Litterman model. It combines a prior estimator, matrix post-processing, user or algorithmic views, asset sets, view confidences, risk-free rate, and a blending parameter tau. The estimator supports both direct and constraint-based views, and allows for flexible confidence specification and matrix processing.

Fields

  • pe: Prior estimator.

  • mp: Matrix processing estimator.

  • views: Views estimator or result.

  • sets: Sets used to map estimator values to features.

  • views_conf: Views confidence estimator or result.

  • rf: Risk-free rate.

  • tau: Blending parameter controlling the weight given to the prior relative to the views.

Constructors

julia
BlackLittermanPrior(;
    pe::AbstractLowOrderPriorEstimator_A_F_AF = EmpiricalPrior(;
        me = EquilibriumExpectedReturns()
    ),
    mp::AbstractMatrixProcessingEstimator = MatrixProcessing(),
    views::Lc_BLV,
    sets::Option{<:AssetSets} = nothing,
    views_conf::Option{<:Num_VecNum} = nothing,
    rf::Number = 0.0,
    tau::Option{<:Number} = nothing
) -> BlackLittermanPrior

Keywords correspond to the struct's fields.

Validation

Examples

julia
julia> BlackLittermanPrior(; sets = AssetSets(; key = "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()
             │           │   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()
             │           │      │   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
          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 ┼ AssetSets
             │    key ┼ String: "nx"
             │   ukey ┼ String: "ux"
             │   dict ┴ Dict{String, Vector{String}}: Dict("nx" => ["A", "B", "C"])
  views_conf ┼ nothing
          rf ┼ Float64: 0.0
         tau ┴ nothing

Related

source
PortfolioOptimisers.prior Function
julia
prior(pe::BlackLittermanPrior, X::MatNum;
      F::Option{<:MatNum} = nothing, dims::Int = 1, strict::Bool = false,
      kwargs...)

Compute the Black-Litterman prior moments for asset returns.

prior estimates the mean and covariance of asset returns using the Black-Litterman model, combining a prior estimator, matrix post-processing, user or algorithmic views, asset sets, view confidences, risk-free rate, and blending parameter tau. The method supports both direct and constraint-based views, flexible confidence specification, and matrix processing.

Mathematical definition

The Black-Litterman posterior distribution combines the prior (Π,τΣ) with investor views (P,q,Ω):

μ^BL=[(τΣ)1+PΩ1P]1[(τΣ)1Π+PΩ1q].Σ^BL=Σ+[(τΣ)1+PΩ1P]1.

Where:

  • Π: N × 1 prior (equilibrium) expected returns.

  • Σ: N × N prior covariance matrix.

  • τ: Scaling parameter for the uncertainty in the prior.

  • P: K × N views matrix (each row is one view).

  • q: K × 1 views vector.

  • Ω: K × K views uncertainty matrix.

Arguments

  • pe: Black-Litterman prior estimator.

  • X: Asset returns matrix (observations × assets).

  • F{Nothing, <:MatNum}: Optional factor matrix (default: nothing).

  • dims: Dimension along which to perform the computation.

  • strict: If true, enforce strict validation of views and sets. Default is false.

  • kwargs...: Additional keyword arguments passed to underlying estimators and matrix processing.

Returns

  • pr::LowOrderPrior: Result object containing asset returns, posterior mean vector, and posterior covariance matrix.

Validation

  • dims in (1, 2).

  • length(pe.sets.dict[pe.sets.key]) == size(X, 2).

Details

  • If dims == 2, X and F are transposed to ensure assets are in columns.

  • The prior model is computed using the embedded prior estimator pe.pe.

  • Views are extracted using black_litterman_views, which returns the view matrix P and view returns vector Q.

  • tau defaults to 1/T if not specified, where T is the number of observations.

  • The view uncertainty matrix omega is computed using calc_omega.

  • The posterior mean and covariance are computed using vanilla_posteriors.

  • Matrix processing is applied to the posterior covariance and asset returns using the embedded matrix processing estimator pe.mp.

Related

source
PortfolioOptimisers.calc_omega Function
julia
calc_omega(views_conf::Option{<:Num_VecNum}, P::MatNum,
           sigma::MatNum) -> LinearAlgebra.Diagonal

Compute the Black-Litterman view uncertainty matrix Ω.

Mathematical definition

Let P be the K×N view matrix and Σ the N×N prior covariance matrix. The view uncertainty matrix Ω for each views_conf variant is:

Ω=Diag(PΣP)(no confidence).Ω=(1v1)Diag(PΣP)(scalar confidence v).Ω=Diag((1v1)diag(PΣP))(vector confidence v).

Where:

  • Ω: K×K diagonal view uncertainty matrix.

  • P: K×N views matrix.

  • Σ: N×N prior covariance matrix.

  • v: Scalar view confidence level.

  • v: K×1 vector of view confidence levels.

  • : Element-wise multiplication.

Arguments

  • views_conf:

    • ::Nothing: No confidence specified; Ω = Diag(P * sigma * P').

    • ::Number: Scalar confidence v; Ω = (1/v - 1) * Diag(P * sigma * P').

    • ::VecNum: Per-view confidences v; Ω = Diag((1 ./ v .- 1) .* diag(P * sigma * P')).

  • P: Views loading matrix views × assets.

  • sigma: Covariance matrix features × features.

Returns

  • omega::LinearAlgebra.Diagonal: Diagonal view uncertainty matrix views × views.

Related

source
PortfolioOptimisers.bl_preroll Function
julia
bl_preroll(
    views,
    sets,
    views_conf,
    prior_sigma,
    pe_tau,
    T,
    datatype,
    strict
) -> NamedTuple{(:P, :Q, :tau, :omega), <:NTuple{4, Any}}

Pre-compute shared Black-Litterman inputs from views, prior covariance, and blending parameters.

Extracts the view matrix P, view returns vector Q, and excluded indices from views and sets via black_litterman_views, resolves tau, filters excluded rows from views_conf via remove_excl_views, and computes the scaled uncertainty matrix omega = tau * Ω via calc_omega.

Arguments

  • views: Views estimator or result.

  • sets: Sets used to map estimator values to features.

  • views_conf: Views confidence estimator or result.

  • prior_sigma::MatNum: Prior covariance matrix of asset returns assets × assets.

  • pe_tau::Option{<:Number}: Optional user-specified blending parameter. If nothing, defaults to 1/T.

  • T::Integer: Number of observations used to compute the default tau = 1/T.

  • datatype: Data type to use for the result in case val is nothing.

  • strict: Whether to throw an error if sets does not contain the desired value in sets.dict[key].

Returns

  • (; P, Q, tau, omega): Named tuple where:
    • P::MatNum: View matrix views × assets.

    • Q::VecNum: View returns vector views × 1.

    • tau::Number: Resolved blending parameter.

    • omega::LinearAlgebra.Diagonal: Scaled view uncertainty matrix tau * Ω.

Related

source
PortfolioOptimisers.vanilla_posteriors Function
julia
vanilla_posteriors(tau::Number, rf::Number, prior_mu::VecNum,
                   prior_sigma::MatNum, omega::MatNum, P::MatNum,
                   Q::VecNum)

Compute the Black-Litterman posterior mean and covariance for asset returns.

vanilla_posteriors implements the standard Black-Litterman update equations, combining the prior mean and covariance with user or algorithmic views. The function returns the posterior mean and covariance matrix, incorporating the blending parameter tau, risk-free rate rf, view uncertainty matrix omega, view matrix P, and view returns vector Q.

Mathematical definition

Let Π be the prior mean, Σ the prior covariance, τ the scaling parameter, P the view matrix, q the view vector, and Ω the view uncertainty matrix:

μ^BL=Π+τΣP(PτΣP+Ω)1(qPΠ)+rf.Σ^BL=Σ+τΣτΣP(PτΣP+Ω)1PτΣ.

Where:

  • μ^BL: Black-Litterman posterior mean vector.

  • Σ^BL: Black-Litterman posterior covariance matrix.

  • Π: N×1 prior (equilibrium) expected returns.

  • Σ: N×N prior covariance matrix.

  • τ: Scaling parameter for the uncertainty in the prior.

  • P: K×N views matrix.

  • q: K×1 views vector.

  • Ω: K×K view uncertainty matrix.

  • rf: Risk-free rate.

Arguments

  • tau: Scalar blending parameter for prior and views.

  • rf: Risk-free rate to add to the posterior mean.

  • prior_mu: Prior mean vector of asset returns.

  • prior_sigma: Prior covariance matrix of asset returns.

  • omega: View uncertainty matrix.

  • P: View matrix (views × assets).

  • Q: Vector of view returns (views).

Returns

  • posterior_mu::VecNum: Posterior mean vector of asset returns.

  • posterior_sigma::Matrix{<:Number}: Posterior covariance matrix of asset returns.

Related

source
PortfolioOptimisers.remove_excl_views Function
julia
remove_excl_views(
    views_conf::Union{Nothing, Number},
    args...
) -> Union{Nothing, Number}

Remove excluded views from views_conf.

Returns views_conf unchanged when excl is nothing or views_conf is scalar. Filters views_conf by removing indices in excl when both are vectors.

Related

source
julia
remove_excl_views(
    views_conf::AbstractVector{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}},
    _::Nothing
) -> AbstractVector{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}}

Remove excluded views from views_conf.

Returns views_conf unchanged (no exclusions).

Related

source
julia
remove_excl_views(
    views_conf::AbstractVector{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}},
    excl::AbstractVector{<:Integer}
) -> Any

Remove excluded views from views_conf.

Returns a view of views_conf with indices in excl removed.

Related

source