Skip to content
13

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 ┴ Full()
             │           │   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 ┴ Full()
             │           │      │   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.factory Method
julia
factory(
    pe::BlackLittermanPrior,
    w::Union{DynamicAbstractWeights, AbstractWeights}
) -> BlackLittermanPrior{_A, var"#s179", _B, _C, _D, <:Number} where {_A, var"#s179"<:AbstractMatrixProcessingEstimator, _B, _C, _D}

Return a new BlackLittermanPrior estimator with observation weights w applied to the underlying prior estimator.

Related

source
Base.getproperty Method
julia
getproperty(obj::BlackLittermanPrior, sym::Symbol) -> Any

Access properties of BlackLittermanPrior. Exposes :me and :ce from the embedded prior estimator obj.pe for transparent access.

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.port_opt_view Method
julia
port_opt_view(
    pr::BlackLittermanPrior,
    i,
    args...
) -> BlackLittermanPrior{_A, var"#s179", _B, _C, _D, <:Number} where {_A, var"#s179"<:AbstractMatrixProcessingEstimator, _B, _C, _D}

Return a new BlackLittermanPrior estimator restricted to the assets at index i.

Related

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

Compute the Black-Litterman view uncertainty matrix Ω.

This method constructs the view uncertainty matrix Ω for the Black-Litterman model when no explicit view confidences are provided (views_conf = nothing). The uncertainty for each view is set to the variance of the projected prior covariance, i.e., Ω = LinearAlgebra.diag(P * Σ * P'), where P is the view matrix and Σ is the prior covariance matrix.

Mathematical definition

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

Ω=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: Indicates no view confidence is specified, LinearAlgebra.Diagonal(P * sigma * transpose(P)).

    • ::Number: Scalar confidence level applied uniformly to all views, (1/v - 1) * LinearAlgebra.Diagonal(P * sigma * transpose(P)), where v is the view confidence level.

    • ::VecNum: Vector of confidence levels for each view, (1 ./ v - 1) * Diag(P * Σ * P').

  • P: The view matrix (views × assets).

  • sigma: The prior covariance matrix (assets × assets).

Returns

  • omega::Diagonal: Diagonal matrix of view uncertainties.

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"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    _::Nothing
) -> AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}

Remove excluded views from views_conf.

Returns views_conf unchanged (no exclusions).

Related

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

Remove excluded views from views_conf.

Returns a view of views_conf with indices in excl removed.

Related

source