Skip to content
5

Entropy Pooling

PortfolioOptimisers.H0_EntropyPooling Type
julia
struct H0_EntropyPooling <: AbstractEntropyPoolingAlgorithm end

One-shot entropy pooling. It sets and optimises all the constraints simultaneously. This introduces bias in the posterior probabilities, but is faster.

Related

source
PortfolioOptimisers.H1_EntropyPooling Type
julia
struct H1_EntropyPooling <: AbstractEntropyPoolingAlgorithm end

Uses the initial probabilities to optimise the posterior probabilities at every step. This reduces bias in the posterior probabilities, but is slower.

Related

source
PortfolioOptimisers.H2_EntropyPooling Type
julia
struct H2_EntropyPooling <: AbstractEntropyPoolingAlgorithm end

Uses the previous step's probabilities to optimise the next step's probabilities. This is faster but may introduce bias.

Related

source
PortfolioOptimisers.LogEntropyPooling Type
julia
struct LogEntropyPooling <: AbstractEntropyPoolingOptAlgorithm end

Logarithmic entropy pooling optimisation algorithm.

LogEntropyPooling is a concrete subtype of AbstractEntropyPoolingOptAlgorithm representing the logarithmic entropy pooling optimisation algorithm. This algorithm solves for posterior probabilities by minimising the Kullback-Leibler divergence between the prior and posterior weights, subject to moment and view constraints, using a logarithmic objective.

Related

source
PortfolioOptimisers.ExpEntropyPooling Type
julia
struct ExpEntropyPooling <: AbstractEntropyPoolingOptAlgorithm end

Exponential entropy pooling optimisation algorithm.

ExpEntropyPooling is a concrete subtype of AbstractEntropyPoolingOptAlgorithm representing the exponential entropy pooling optimisation algorithm. This algorithm solves for posterior probabilities by minimising the exponential divergence between the prior and posterior weights, subject to moment and view constraints, using an exponential objective.

Related

source
PortfolioOptimisers.CVaREntropyPooling Type
julia
struct CVaREntropyPooling{T1, T2} <: AbstractEntropyPoolingOptimiser
    args::T1
    kwargs::T2
end

Conditional Value-at-Risk (CVaR) entropy pooling optimiser.

CVaREntropyPooling is a concrete subtype of AbstractEntropyPoolingOptimiser that uses root-finding algorithms from Roots.jl to solve entropy pooling problems with CVaR (Conditional Value-at-Risk) view constraints. This optimiser is designed for scenarios where CVaR views are specified and requires robust numerical methods to find the solution.

Fields

  • args: Tuple of arguments passed to the root-finding algorithm (e.g., Roots.Brent()).

  • kwargs: Named tuple of keyword arguments for the root-finding algorithm.

Constructor

julia
CVaREntropyPooling(; args::Tuple = (Roots.Brent(),), kwargs::NamedTuple = (;))

Keyword arguments correspond to the fields above.

Examples

julia
julia> CVaREntropyPooling()
CVaREntropyPooling
    args ┼ Tuple{Roots.Brent}: (Roots.Brent(),)
  kwargs ┴ @NamedTuple{}: NamedTuple()

Related

source
PortfolioOptimisers.OptimEntropyPooling Type
julia
struct OptimEntropyPooling{T1, T2, T3, T4, T5} <: AbstractEntropyPoolingOptimiser
    args::T1
    kwargs::T2
    sc1::T3
    sc2::T4
    alg::T5
end

Optim.jl-based entropy pooling optimiser.

OptimEntropyPooling is a concrete subtype of AbstractEntropyPoolingOptimiser that uses Optim.jl to solve entropy pooling problems. This optimiser supports both logarithmic and exponential entropy pooling objectives, and allows for flexible configuration of solver arguments, scaling parameters, and algorithm selection.

Fields

  • args: Tuple of arguments passed to the Optim.jl solver.

  • kwargs: Named tuple of keyword arguments for the Optim.jl solver.

  • sc1: Scaling parameter for the objective function.

  • sc2: Slack parameter for relaxing fixed equality constraint penalties so that they can be satisfied more easily.

  • alg: Entropy pooling optimisation algorithm.

Constructor

julia
OptimEntropyPooling(; args::Tuple = (), kwargs::NamedTuple = (;), sc1::Real = 1,
                    sc2::Real = 1e3,
                    alg::AbstractEntropyPoolingOptAlgorithm = ExpEntropyPooling())

Keyword arguments correspond to the fields above.

Validation

  • sc1 >= 0

  • sc2 >= 0

Examples

julia
julia> OptimEntropyPooling()
OptimEntropyPooling
    args ┼ Tuple{}: ()
  kwargs ┼ @NamedTuple{}: NamedTuple()
     sc1 ┼ Int64: 1
     sc2 ┼ Float64: 1000.0
     alg ┴ ExpEntropyPooling()

Related

source
PortfolioOptimisers.JuMPEntropyPooling Type
julia
struct JuMPEntropyPooling{T1, T2, T3, T4, T5} <: AbstractEntropyPoolingOptimiser
    slv::T1
    sc1::T2
    sc2::T3
    so::T4
    alg::T5
end

JuMP.jl-based entropy pooling optimiser.

JuMPEntropyPooling is a concrete subtype of AbstractEntropyPoolingOptimiser that uses JuMP.jl to solve entropy pooling problems. This optimiser supports both logarithmic and exponential entropy pooling objectives, and allows for flexible configuration of solver arguments, scaling parameters, and algorithm selection.

Fields

  • slv: Solver object or vector of solvers for JuMP.jl.

  • sc1: Scaling parameter for the objective function.

  • sc2: Scaling parameter for constraint penalties.

  • so: Scaling parameter for the objective expression.

  • alg: Entropy pooling optimisation algorithm.

Constructor

julia
JuMPEntropyPooling(; slv::Union{<:Solver, <:AbstractVector{<:Solver}}, sc1::Real = 1,
                   sc2::Real = 1e5, so::Real = 1,
                   alg::AbstractEntropyPoolingOptAlgorithm = ExpEntropyPooling())

Keyword arguments correspond to the fields above.

Validation

  • If slv is a vector, !isempty(slv).

  • sc1 >= 0

  • sc2 >= 0

  • so >= 0

Examples

julia
julia> JuMPEntropyPooling(; slv = Solver(; name = :fake_solver, solver = :MySolver))
JuMPEntropyPooling
  slv ┼ Solver
      │          name ┼ Symbol: :fake_solver
      │        solver ┼ Symbol: :MySolver
      │      settings ┼ nothing
      │     check_sol ┼ @NamedTuple{}: NamedTuple()
      │   add_bridges ┴ Bool: true
  sc1 ┼ Int64: 1
  sc2 ┼ Float64: 100000.0
   so ┼ Int64: 1
  alg ┴ ExpEntropyPooling()

Related

source
PortfolioOptimisers.EntropyPoolingPrior Type
julia
struct EntropyPoolingPrior{T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15,
                           T16} <: AbstractLowOrderPriorEstimator_AF
    pe::T1
    mu_views::T2
    var_views::T3
    cvar_views::T4
    sigma_views::T5
    sk_views::T6
    kt_views::T7
    rho_views::T8
    var_alpha::T9
    cvar_alpha::T10
    sets::T11
    ds_opt::T12
    dm_opt::T13
    opt::T14
    w::T15
    alg::T16
end

Entropy pooling prior estimator for asset returns.

EntropyPoolingPrior is a low order prior estimator that computes the mean and covariance of asset returns using entropy pooling. It supports moment and view constraints (mean, variance, CVaR, covariance, skewness, kurtosis, correlation), flexible confidence specification, and composable optimisation algorithms. The estimator integrates asset sets, view constraints, and multiple entropy pooling algorithms (Optim.jl, JuMP.jl, CVaR root-finding), and allows for custom prior weights and solver configuration.

Fields

  • pe: Prior estimator for asset returns.

  • mu_views: Mean view constraints.

  • sigma_views: Variance view constraints.

  • cvar_views: CVaR view constraints.

  • sigma_views: Covariance view constraints.

  • sk_views: Skewness view constraints.

  • kt_views: Kurtosis view constraints.

  • rho_views: Correlation view constraints.

  • var_alpha: Confidence level for VaR (Value at Risk) views.

  • cvar_alpha: Confidence level for CVaR (Conditional Value at Risk) views.

  • sets: Asset sets.

  • ds_opt: CVaR entropy pooling optimiser.

  • dm_opt: Optim.jl-based entropy pooling optimiser.

  • opt: Main entropy pooling optimiser.

  • w: Prior weights.

  • alg: Entropy pooling algorithm.

Constructor

julia
EntropyPoolingPrior(; pe::AbstractLowOrderPriorEstimator_A_F_AF = EmpiricalPrior(),
                    mu_views::Union{Nothing, <:LinearConstraintEstimator} = nothing,
                    var_views::Union{Nothing, <:LinearConstraintEstimator} = nothing,
                    cvar_views::Union{Nothing, <:LinearConstraintEstimator} = nothing,
                    sigma_views::Union{Nothing, <:LinearConstraintEstimator} = nothing,
                    sk_views::Union{Nothing, <:LinearConstraintEstimator} = nothing,
                    kt_views::Union{Nothing, <:LinearConstraintEstimator} = nothing,
                    rho_views::Union{Nothing, <:LinearConstraintEstimator} = nothing,
                    var_alpha::Real = 0.05, cvar_alpha::Real = 0.05,
                    sets::Union{Nothing, <:AssetSets} = nothing,
                    ds_opt::Union{Nothing, <:CVaREntropyPooling} = nothing,
                    dm_opt::Union{Nothing, <:OptimEntropyPooling} = nothing,
                    opt::Union{<:OptimEntropyPooling, <:JuMPEntropyPooling} = OptimEntropyPooling(),
                    w::Union{Nothing, <:ProbabilityWeights} = nothing,
                    alg::AbstractEntropyPoolingAlgorithm = H1_EntropyPooling())

Keyword arguments correspond to the fields above.

Validation

  • If any view constraint is provided, sets must not be nothing.

  • If not nothing, 0 < var_alpha < 1.

  • If not nothing, 0 < cvar_alpha < 1.

  • If w is provided, it must be non-empty and match the number of observations.

Details

  • If w is provided, it is normalised to sum to 1; otherwise, uniform weights are used when prior is called.

  • If var_views is provided without var_alpha, defaults to 0.05.

  • If cvar_views is provided without cvar_alpha, defaults to 0.05.

Examples

julia
julia> EntropyPoolingPrior(; sets = AssetSets(; key = "nx", dict = Dict("nx" => ["A", "B", "C"])),
                           mu_views = LinearConstraintEstimator(;
                                                                val = ["A == 0.03",
                                                                       "B + C == 0.04"]))
EntropyPoolingPrior
           pe ┼ EmpiricalPrior
              │        ce ┼ PortfolioOptimisersCovariance
              │           │   ce ┼ Covariance
              │           │      │    me ┼ SimpleExpectedReturns
              │           │      │       │   w ┴ nothing
              │           │      │    ce ┼ GeneralCovariance
              │           │      │       │   ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true)
              │           │      │       │    w ┴ nothing
              │           │      │   alg ┴ Full()
              │           │   mp ┼ DefaultMatrixProcessing
              │           │      │       pdm ┼ Posdef
              │           │      │           │   alg ┴ UnionAll: NearestCorrelationMatrix.Newton
              │           │      │   denoise ┼ nothing
              │           │      │    detone ┼ nothing
              │           │      │       alg ┴ nothing
              │        me ┼ SimpleExpectedReturns
              │           │   w ┴ nothing
              │   horizon ┴ nothing
     mu_views ┼ LinearConstraintEstimator
              │   val ┴ Vector{String}: ["A == 0.03", "B + C == 0.04"]
    var_views ┼ nothing
   cvar_views ┼ nothing
  sigma_views ┼ nothing
     sk_views ┼ nothing
     kt_views ┼ nothing
    rho_views ┼ nothing
    var_alpha ┼ nothing
   cvar_alpha ┼ nothing
         sets ┼ AssetSets
              │    key ┼ String: "nx"
              │   dict ┴ Dict{String, Vector{String}}: Dict("nx" => ["A", "B", "C"])
       ds_opt ┼ nothing
       dm_opt ┼ nothing
          opt ┼ OptimEntropyPooling
              │     args ┼ Tuple{}: ()
              │   kwargs ┼ @NamedTuple{}: NamedTuple()
              │      sc1 ┼ Int64: 1
              │      sc2 ┼ Float64: 1000.0
              │      alg ┴ ExpEntropyPooling()
            w ┼ nothing
          alg ┴ H1_EntropyPooling()

Related

source
PortfolioOptimisers.prior Function
julia
prior(pe::EntropyPoolingPrior{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                              <:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                              <:Union{<:H1_EntropyPooling, <:H2_EntropyPooling}},
      X::AbstractMatrix; F::Union{Nothing, <:AbstractMatrix} = nothing, dims::Int = 1,
      strict::Bool = false, kwargs...)

Compute entropy pooling prior moments for asset returns with iterative constraint enforcement.

prior estimates the mean and covariance of asset returns using the entropy pooling framework, supporting iterative constraint enforcement via the H1_EntropyPooling and H2_EntropyPooling algorithms. It integrates moment and view constraints (mean, variance, CVaR, skewness, kurtosis, correlation), flexible confidence specification, and composable optimisation algorithms. The method iteratively applies constraints, updating prior weights and moments at each step, and ensures that higher moment views do not inadvertently alter lower moments.

Arguments

  • pe: Entropy pooling prior estimator with iterative algorithm .

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

  • F: Optional factor matrix (default: nothing).

  • dims: Dimension along which to compute moments.

  • If true, throws error for missing assets; otherwise, issue warnings.

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

Returns

  • pr::LowOrderPrior: Result object containing asset returns, posterior mean vector, posterior covariance matrix, weights, effective number of scenarios, Kullback-Leibler divergence, and optional factor moments.

Validation

  • dims in (1, 2).

  • If any view constraint is provided, !isnothing(sets).

  • If prior weights pe.w are provided, length(pe.w) == T, where T is the number of observations.

Details

  • If isnothing(pe.w), prior weights are initialised to 1/T where T is the number of observations; otherwise, provided weights are normalised.

  • Constraints are enforced iteratively, from lower to higher moments.

  • Moment and view constraints are parsed and added to the constraint dictionary.

  • The initial weights for each stage is selected according to pe.alg.

  • At each stage, the prior weights are updated by solving the entropy pooling optimisation with the current set of constraints. If present, the CVaR views are also enforced at every stage.

  • Lower moments are fixed as needed to prevent distortion by higher moment views. If asset i has a view enforced on moment N that uses moments n < N to compute, then all moments n for asset i are fixed.

  • The final result includes the effective number of scenarios and Kullback-Leibler divergence between prior and posterior weights.

Related

source
PortfolioOptimisers.prior Method
julia
prior(pe::EntropyPoolingPrior{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                              <:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                              <:H0_EntropyPooling}, X::AbstractMatrix;
      F::Union{Nothing, <:AbstractMatrix} = nothing, dims::Int = 1, strict::Bool = false,
      kwargs...)

Compute entropy pooling prior moments for asset returns with single-shot constraint enforcement.

prior estimates the mean and covariance of asset returns using the entropy pooling framework, enforcing all moment and view constraints in a single optimisation step via the H0_EntropyPooling algorithm. This approach is fast but may distort lower moments when higher moment views are present, as all constraints are applied simultaneously.

Arguments

  • pe: Entropy pooling prior estimator with single-shot algorithm.

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

  • F: Optional factor matrix.

  • dims: Dimension along which to compute moments,

  • strict: If true, throws error for missing assets; otherwise, issues warnings.

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

Returns

  • pr::LowOrderPrior: Result object containing asset returns, posterior mean vector, posterior covariance matrix, weights, effective number of scenarios, Kullback-Leibler divergence, and optional factor moments.

Validation

  • dims in (1, 2).

  • If any view constraint is provided, !isnothing(pe.sets).

  • If prior weights pe.w are provided, length(pe.w) == T, where T is the number of observations

Details

  • If isnothing(pe.w), prior weights are initialised to 1/T where T is the number of observations; otherwise, provided weights are normalised.

  • All constraints are parsed and added to the constraint dictionary at once. This means that lower moments may be distorted by higher moment views, since they cannot be fixed at any point.

  • A single optimisation is performed to solve for the posterior weights, enforcing all constraints at once.

  • The final result includes the effective number of scenarios and Kullback-Leibler divergence between prior and posterior weights.

Related

source
PortfolioOptimisers.AbstractEntropyPoolingOptimiser Type
julia
abstract type AbstractEntropyPoolingOptimiser <: AbstractEstimator end

Abstract supertype for entropy pooling optimisers.

AbstractEntropyPoolingOptimiser is the base type for all optimisers that compute entropy pooling weights subject to moment and view constraints. All concrete entropy pooling optimisers should subtype this type to ensure a consistent interface for entropy pooling routines and integration with portfolio optimisation workflows.

Related

source
PortfolioOptimisers.AbstractEntropyPoolingAlgorithm Type
julia
abstract type AbstractEntropyPoolingAlgorithm <: AbstractAlgorithm end

Abstract supertype for entropy pooling algorithms.

AbstractEntropyPoolingAlgorithm is the base type for all algorithms used in entropy pooling optimisation routines. All concrete entropy pooling algorithms should subtype this type to ensure a consistent interface for entropy pooling methods and integration with portfolio optimisation workflows.

Related

source
PortfolioOptimisers.AbstractEntropyPoolingOptAlgorithm Type
julia
abstract type AbstractEntropyPoolingOptAlgorithm <: AbstractAlgorithm end

Abstract supertype for entropy pooling optimisation algorithms.

AbstractEntropyPoolingOptAlgorithm is the base type for all optimisation algorithms used in entropy pooling routines. All concrete entropy pooling optimisation algorithms should subtype this type to ensure a consistent interface for entropy pooling optimisation and integration with portfolio optimisation workflows.

Related

source
PortfolioOptimisers.get_epw Function
julia
get_epw(alg::Union{<:H0_EntropyPooling, <:H1_EntropyPooling}, w0::AbstractWeights,
        wi::AbstractWeights)

Select entropy pooling weights according to the specified algorithm.

get_epw returns the appropriate weights for entropy pooling based on the chosen algorithm. For H1_EntropyPooling, it returns the initial prior weights w0. For H2_EntropyPooling, it returns the updated weights wi. This function is used internally to manage the flow of weights in multi-stage entropy pooling routines.

Arguments

  • alg: Entropy pooling algorithm .

  • w0: Initial prior weights.

  • wi: Updated weights from previous step.

Returns

  • w::AbstractWeights: Selected weights for the current entropy pooling step.

Examples

julia
julia> using StatsBase

julia> w0 = pweights([0.25, 0.25, 0.25, 0.25]);

julia> wi = pweights([0.1, 0.2, 0.3, 0.4]);

julia> PortfolioOptimisers.get_epw(H1_EntropyPooling(), w0, wi)
4-element ProbabilityWeights{Float64, Float64, Vector{Float64}}:
 0.25
 0.25
 0.25
 0.25

julia> PortfolioOptimisers.get_epw(H2_EntropyPooling(), w0, wi)
4-element ProbabilityWeights{Float64, Float64, Vector{Float64}}:
 0.1
 0.2
 0.3
 0.4

Related

source
PortfolioOptimisers.add_ep_constraint! Function
julia
add_ep_constraint!(epc::AbstractDict, lhs::AbstractMatrix, rhs::AbstractVector, key::Symbol)

Add an entropy pooling view constraint to the constraint dictionary.

add_ep_constraint! normalises and adds a constraint to the entropy pooling constraint dictionary epc. If a constraint with the same key already exists, it concatenates the new constraint to the existing one. This function is used internally to build the set of linear constraints for entropy pooling optimisation.

Arguments

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • lhs: Left-hand side constraint matrix.

  • rhs: Right-hand side constraint vector.

  • key: Constraint type key (:eq, :ineq, :feq, :cvar_eq).

Returns

  • nothing: The function mutates epc in-place.

Related

source
PortfolioOptimisers.replace_prior_views Function
julia
replace_prior_views(res::ParsingResult, pr::AbstractPriorResult, sets::AssetSets,
                    key::Symbol; alpha::Union{Nothing, <:Real} = nothing,
                    strict::Bool = false)

Replace prior references in view parsing results with their corresponding prior values.

replace_prior_views scans a parsed view constraint ParsingResult for references to prior values (e.g., prior(A)), and replaces them with the actual prior value from the provided prior result object. This ensures that prior-based terms in view constraints are treated as constants and not as variables in the optimisation. If an asset referenced in a prior is not found in the asset set, a warning is issued (or an error if strict=true). If all variables in the view are prior references, an error is thrown.

Arguments

  • res: Parsed view constraint containing variables and coefficients.

  • pr: Prior result object containing prior values.

  • sets: Asset set mapping asset names to indices.

  • key: Moment type key (:mu, :var, :cvar, etc.).

  • alpha: Optional confidence level for VaR/CVaR views.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • res::ParsingResult: Updated parsing result with prior references replaced by their values.

Details

  • Prior references are matched using the pattern prior(<asset>).

  • The right-hand side of the constraint is adjusted by subtracting the prior value times its coefficient.

  • Variables corresponding to prior references are removed from the constraint.

  • Throws an error if no non-prior variables remain.

Related

source
julia
replace_prior_views(res::AbstractVector{<:ParsingResult}, args...; kwargs...)

Broadcast prior reference replacement across multiple view constraints.

replace_prior_views applies replace_prior_views to each element of a vector of parsed view constraints, replacing prior references with their corresponding prior values. This enables efficient batch processing of multiple view constraints in entropy pooling routines.

Arguments

Returns

  • res::Vector{<:ParsingResult}: Vector of updated parsing results with prior references replaced by their values.

Related

source
julia
replace_prior_views(res::ParsingResult, pr::AbstractPriorResult, sets::AssetSets;
                    strict::Bool = false)

Replace correlation prior references in view parsing results with their corresponding prior values.

replace_prior_views scans a parsed correlation view constraint (ParsingResult) for references to prior values (e.g., prior(A, B)), and replaces them with the actual prior correlation value from the provided prior result object. This ensures that prior-based terms in correlation view constraints are treated as constants and not as variables in the optimisation. If an asset referenced in a prior is not found in the asset set, a warning is issued (or an error if strict=true). If all variables in the view are prior references, an error is thrown.

Arguments

  • res: Parsed correlation view constraint containing variables and coefficients.

  • pr: Prior result object containing prior correlation values.

  • sets: Asset set mapping asset names to indices.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • res::RhoParsingResult: Updated parsing result with prior references replaced by their values and correlation indices.

Details

  • Prior references are matched using the pattern prior(<asset1>, <asset2>).

  • The right-hand side of the constraint is adjusted by subtracting the prior correlation value times its coefficient.

  • Variables corresponding to prior references are removed from the constraint.

  • Throws an error if no non-prior variables remain.

  • Returns a RhoParsingResult containing the updated variables, coefficients, operator, right-hand side, equation string, and correlation indices.

Related

source
PortfolioOptimisers.get_pr_value Function
julia
get_pr_value(pr::AbstractPriorResult, i::Integer, ::Val{:mu}, args...)

Extract the mean (expected return) for asset i from a prior result.

get_pr_value returns the mean value for the asset indexed by i from the prior result object pr. This method is used internally to replace prior references in view constraints and for moment extraction in entropy pooling and other prior-based routines.

Arguments

  • pr: Prior result containing asset return information.

  • i: Index of the asset.

  • ::Val{:mu}: Dispatch tag for mean extraction.

  • args...: Additional arguments (ignored).

Returns

  • mu::Real: Mean (expected return) for asset i.

Related

source
julia
get_pr_value(pr::AbstractPriorResult, i::Integer, ::Val{:var}, alpha::Real)

Extract the Value-at-Risk (VaR) for asset i from a prior result.

get_pr_value computes the VaR at confidence level alpha for the asset indexed by i from the prior result object pr. This method uses the asset return samples in pr and applies the VaR calculation, typically using the empirical quantile.

Arguments

  • pr: Prior result containing asset return information.

  • i: Index of the asset.

  • ::Val{:var}: Dispatch tag for VaR extraction.

  • alpha: Confidence level (e.g., 0.05 for 5% VaR).

Returns

  • var::Real: Value-at-Risk for asset i at level alpha.

Related

source
julia
get_pr_value(pr::AbstractPriorResult, i::Integer, ::Val{:cvar}, alpha::Real)

Compute the Conditional Value-at-Risk (CVaR) for asset i from a prior result.

get_pr_value extracts the CVaR at confidence level alpha for the asset indexed by i from the prior result object pr. This method assumes the prior result contains the necessary asset return information (mean, covariance, or samples) to compute CVaR, typically under a normality assumption.

Arguments

  • pr: Prior result containing asset return information.

  • i: Index of the asset.

  • ::Val{:cvar}: Dispatch tag for CVaR computation.

  • alpha: Confidence level.

Returns

  • cvar::Real: Conditional Value-at-Risk for asset i at level alpha.

Related

source
julia
get_pr_value(pr::AbstractPriorResult, i::Integer, ::Val{:sigma}, args...)

Extract the variance for asset i from a prior result.

get_pr_value returns the variance (diagonal element of the covariance matrix) for the asset indexed by i from the prior result object pr. This method is used internally to replace prior references in view constraints and for moment extraction in entropy pooling and other prior-based routines.

Arguments

  • pr: Prior result containing asset return information.

  • i: Index of the asset.

  • ::Val{:sigma}: Dispatch tag for variance extraction.

  • args...: Additional arguments (ignored).

Returns

  • sigma::Real: Variance for asset i.

Related

source
julia
get_pr_value(pr::AbstractPriorResult, i::Integer, j::Integer, args...)

Extract the prior correlation value between assets i and j from a prior result.

get_pr_value returns the correlation coefficient between the assets indexed by i and j from the prior result object pr. This method is used internally to replace prior references in correlation view constraints and for moment extraction in entropy pooling and other prior-based routines.

Arguments

  • pr: Prior result containing asset return information.

  • i: Index of the first asset.

  • j: Index of the second asset.

  • args...: Additional arguments (ignored).

Returns

  • rho::Real: Correlation coefficient between assets i and j.

Related

source
julia
get_pr_value(pr::AbstractPriorResult, i::Integer, ::Val{:skew}, args...)

Extract the skewness for asset i from a prior result.

get_pr_value returns the skewness of the asset indexed by i from the prior result object pr. This method is used internally to replace prior references in view constraints and for higher moment extraction in entropy pooling and other prior-based routines.

Arguments

  • pr: Prior result containing asset return information.

  • i: Index of the asset.

  • ::Val{:skew}: Dispatch tag for skewness extraction.

  • args...: Additional arguments (ignored).

Returns

  • skew::Real: Skewness for asset i.

Related

source
julia
get_pr_value(pr::AbstractPriorResult, i::Integer, ::Val{:kurtosis}, args...)

Extract the kurtosis for asset i from a prior result.

get_pr_value returns the kurtosis of the asset indexed by i from the prior result object pr. This method is used internally to replace prior references in view constraints and for higher moment extraction in entropy pooling and other prior-based routines.

Arguments

  • pr: Prior result containing asset return information.

  • i: Index of the asset.

  • ::Val{:kurtosis}: Dispatch tag for kurtosis extraction.

  • args...: Additional arguments (ignored).

Returns

  • kurtosis::Real: Kurtosis for asset i.

Related

source
PortfolioOptimisers.ep_mu_views! Function
julia
ep_mu_views!(mu_views::Nothing, args...; kwargs...)

No-op pass-through for mean view constraints when none are specified.

ep_mu_views! is an internal API compatibility method that does nothing when mean view constraints (mu_views) are not provided (mu_views = nothing). This allows higher-level entropy pooling routines to uniformly call ep_mu_views! without special-casing the absence of mean views.

Arguments

  • mu_views::Nothing: Indicates that no mean view constraints are specified.

  • args...: Additional positional arguments (ignored).

  • kwargs...: Additional keyword arguments (ignored).

Returns

  • nothing: No operation is performed.

Related

source
julia
ep_mu_views!(mu_views::LinearConstraintEstimator, epc::AbstractDict,
             pr::AbstractPriorResult, sets::AssetSets; strict::Bool = false)

Parse and add mean (expected return) view constraints to the entropy pooling constraint dictionary.

ep_mu_views! parses mean view equations from a LinearConstraintEstimator, replaces any prior references with their actual values, and constructs the corresponding linear constraints for entropy pooling. The constraints are then added to the entropy pooling constraint dictionary epc. This method is used internally by entropy pooling routines to enforce mean views in the optimisation.

Arguments

  • mu_views: Mean view constraints.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • pr: Prior result containing asset return information.

  • sets: Asset set mapping asset names to indices.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • nothing: The function mutates epc in-place.

Details

  • Parses view equations and replaces groupings by assets.

  • Replaces prior references in views with their actual prior values.

  • Converts parsed views to linear constraints and adds them to epc.

  • Supports both equality and fixed equality constraints.

Related

source
PortfolioOptimisers.fix_mu! Function
julia
fix_mu!(epc::AbstractDict, fixed::AbstractVector, to_fix::AbstractVector,
        pr::AbstractPriorResult)

Add constraints to fix the mean of specified assets in entropy pooling.

fix_mu! identifies assets in to_fix that are not yet fixed (i.e., not present in fixed), and adds constraints to the entropy pooling constraint dictionary epc to fix their mean to the prior value. This ensures that higher moment views (e.g., variance, skewness, kurtosis, correlation) do not inadvertently alter the mean of these assets. The function updates fixed in-place to reflect the newly fixed assets.

Arguments

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • fixed: Boolean vector indicating which assets have their mean fixed.

  • to_fix: Boolean vector indicating which assets should have their mean fixed.

  • pr: Prior result containing asset return information.

Returns

  • nothing: The function mutates epc and fixed in-place.

Details

  • Adds a fixed equality constraint (:feq) for each asset in to_fix that is not yet fixed.

  • Uses the prior mean values from pr.mu for the constraint right-hand side.

Related

source
PortfolioOptimisers.ep_var_views! Function
julia
ep_var_views!(var_views::Nothing, args...; kwargs...)

No-op pass-through for variance view constraints when none are specified.

ep_var_views! is an internal API compatibility method that does nothing when variance view constraints (var_views) are not provided (var_views = nothing). This allows higher-level entropy pooling routines to uniformly call ep_var_views! without special-casing the absence of variance views.

Arguments

  • var_views::Nothing: Indicates that no variance view constraints are specified.

  • args...: Additional positional arguments (ignored).

  • kwargs...: Additional keyword arguments (ignored).

Returns

  • nothing: No operation is performed.

Related

source
julia
ep_var_views!(var_views::LinearConstraintEstimator, epc::AbstractDict,
              pr::AbstractPriorResult, sets::AssetSets, alpha::Real; strict::Bool = false)

Parse and add variance (VaR) view constraints to the entropy pooling constraint dictionary.

ep_var_views! parses variance (VaR) view equations from a LinearConstraintEstimator, replaces any prior references with their actual values, and constructs the corresponding linear constraints for entropy pooling. The constraints are then added to the entropy pooling constraint dictionary epc. This method validates that only single-asset, non-negative, and unit-coefficient views are allowed, and throws informative errors for invalid or extreme views.

Arguments

  • var_views: Variance (VaR) view constraints.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • pr: Prior result containing asset return information.

  • sets: Asset set mapping asset names to indices.

  • alpha: Confidence level for VaR.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • nothing: The function mutates epc in-place.

Details

  • Parses view equations and replaces groupings by assets.

  • Replaces prior references in views with their actual prior values.

  • Converts parsed views to linear constraints and adds them to epc.

  • Validates that only equality and inequality constraints with unit coefficients are present.

  • Throws errors for negative or multi-asset views, or if the view is more extreme than the worst realisation.

Related

source
PortfolioOptimisers.entropy_pooling Function
julia
entropy_pooling(w::AbstractVector, epc::AbstractDict, opt::OptimEntropyPooling)

Solve the dual of the exponential entropy pooling formulation using Optim.jl.

entropy_pooling computes posterior probabilities by minimising the exponential divergence between prior and posterior weights, subject to moment and view constraints. The optimisation is performed using Optim.jl, supporting box constraints and slack variables for relaxed equality constraints. This method is used internally by EntropyPoolingPrior when the optimiser is an OptimEntropyPooling.

Arguments

  • w: Prior weights (length = number of observations).

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • `opt: Optim.jl-based entropy pooling optimiser with exponential objective.

    • ::OptimEntropyPooling{<:Any, <:Any, <:Any, <:Any, <:ExpEntropyPooling}: use the exponential formulation.

    • ::OptimEntropyPooling{<:Any, <:Any, <:Any, <:Any, <:LogEntropyPooling}: use the logarithmic formulation.

Returns

  • pw::ProbabilityWeights: Posterior probability weights satisfying the constraints.

Details

  • Constructs the constraint matrix and bounds from epc.

  • Relaxes fixed equality constraints via slack variables to make the problem more tractable.

  • Throws an error if optimisation fails.

Related

source
julia
entropy_pooling(w::AbstractVector, epc::AbstractDict, opt::JuMPEntropyPooling)

Solve the primal of the exponential entropy pooling formulation using JuMP.jl.

entropy_pooling computes posterior probabilities by minimising the exponential divergence between prior and posterior weights, subject to moment and view constraints. The optimisation is performed using JuMP.jl, supporting relative entropy cones and slack variables for relaxed equality constraints. This method is used internally by EntropyPoolingPrior when the optimiser is a JuMPEntropyPooling.

Arguments

  • w: Prior weights (length = number of observations).

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • opt: JuMP.jl-based entropy pooling optimiser with exponential objective.

    • ::JuMPEntropyPooling{<:Any, <:Any, <:Any, <:Any, <:ExpEntropyPooling}: use the exponential formulation.

    • ::JuMPEntropyPooling{<:Any, <:Any, <:Any, <:Any, <:LogEntropyPooling}: use the logarithmic formulation.

Returns

  • pw::ProbabilityWeights: Posterior probability weights satisfying the constraints.

Details

  • Constructs the JuMP model with exponential objective and constraints from epc.

  • Relaxes fixed equality constraints by adding norm one cone bounded slack variables to make the problem more tractable.

  • Throws an error if optimisation fails.

Related

source
PortfolioOptimisers.ep_cvar_views_solve! Function
julia
ep_cvar_views_solve!(cvar_views::Nothing, epc::AbstractDict, ::Any, ::Any, ::Real,
                     w::AbstractWeights, opt::AbstractEntropyPoolingOptimiser, ::Any, ::Any;
                     kwargs...)

Solve entropy pooling views when no CVaR views are specified.

ep_cvar_views_solve! is an internal API compatibility method that solves the entropy pooling problem when no Conditional Value-at-Risk (CVaR) view constraints are present (cvar_views = nothing). It simply delegates to the main entropy pooling solver using the provided prior weights, constraint dictionary, and optimiser.

Arguments

  • cvar_views: Indicates that no CVaR view constraints are specified.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • w: Prior probability weights.

  • opt: Entropy pooling optimiser.

  • kwargs...: Additional keyword arguments forwarded to the solver.

Returns

  • pw::ProbabilityWeights: Posterior probability weights satisfying the constraints.

Details

  • This method is used for API compatibility when CVaR views are not present.

  • Calls entropy_pooling with the provided arguments.

Related

source
julia
ep_cvar_views_solve!(cvar_views::LinearConstraintEstimator, epc::AbstractDict,
                     pr::AbstractPriorResult, sets::AssetSets, alpha::Real,
                     w::AbstractWeights, opt::AbstractEntropyPoolingOptimiser,
                     ds_opt::Union{Nothing, <:CVaREntropyPooling},
                     dm_opt::Union{Nothing, <:OptimEntropyPooling}; strict::Bool = false)

Solve the entropy pooling problem with Conditional Value-at-Risk (CVaR) view constraints.

ep_cvar_views_solve! parses and validates CVaR view constraints, replaces prior references, and constructs the corresponding entropy pooling constraint system. It then solves for posterior probability weights using either root-finding (for single CVaR view) or optimisation (for multiple views), depending on the number of constraints and the provided optimiser. Throws informative errors if views are infeasible or too extreme.

Arguments

  • cvar_views: CVaR view constraints.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • pr: Prior result containing asset return information.

  • sets: Asset set mapping asset names to indices.

  • alpha: Confidence level for CVaR.

  • w: Prior probability weights.

  • opt: Main entropy pooling optimiser.

  • ds_opt: CVaR-specific optimiser (for single view).

  • dm_opt: General optimiser (for multiple views).

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • pw::ProbabilityWeights: Posterior probability weights satisfying CVaR view constraints.

Details

  • Parses CVaR view equations and replaces prior references.

  • Validates that only equality constraints are present and that each view targets a single asset.

  • Checks that views are not too extreme i.e. not greater than the worst realisation.

  • For a single CVaR view, uses root-finding via CVaREntropyPooling.

  • For multiple CVaR views, uses optimisation via OptimEntropyPooling.

  • Throws errors if optimisation fails or views are infeasible.

Related

source
PortfolioOptimisers.ep_sigma_views! Function
julia
ep_sigma_views!(sigma_views::LinearConstraintEstimator, epc::AbstractDict,
                pr::AbstractPriorResult, sets::AssetSets; strict::Bool = false)

Parse and add variance (sigma) view constraints to the entropy pooling constraint dictionary.

ep_sigma_views! parses variance view equations from a LinearConstraintEstimator, replaces any prior references with their actual values, and constructs the corresponding quadratic constraints for entropy pooling. The constraints are then added to the entropy pooling constraint dictionary epc. This method returns a boolean vector indicating which assets require their mean to be fixed to the prior value, ensuring that variance views do not inadvertently alter the mean.

Arguments

  • sigma_views: Variance view constraints.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • pr: Prior result containing asset return information.

  • sets: Asset set mapping asset names to indices.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • to_fix::BitVector: Boolean vector indicating which assets require their mean to be fixed.

Details

  • Parses view equations and replaces groupings by assets.

  • Replaces prior references in views with their actual prior values.

  • Converts parsed views to quadratic constraints and adds them to epc.

  • Returns a boolean vector for assets that need their mean fixed due to variance constraints.

Related

source
PortfolioOptimisers.fix_sigma! Function
julia
fix_sigma!(epc::AbstractDict, fixed::AbstractVector, to_fix::AbstractVector,
           pr::AbstractPriorResult)

Add constraints to fix the variance of specified assets in entropy pooling.

fix_sigma! identifies assets in to_fix that are not yet fixed (i.e., not present in fixed), and adds constraints to the entropy pooling constraint dictionary epc to fix their variance to the prior value. This ensures that higher moment views (e.g., skewness, kurtosis, correlation) do not inadvertently alter the variance of these assets. The function updates fixed in-place to reflect the newly fixed assets.

Arguments

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • fixed: Boolean vector indicating which assets have their variance fixed.

  • to_fix: Boolean vector indicating which assets should have their variance fixed.

  • pr: Prior result containing asset return information.

Returns

  • nothing: The function mutates epc and fixed in-place.

Details

  • Adds a fixed equality constraint (:feq) for each asset in to_fix that is not yet fixed.

  • Uses the prior variance values from diag(pr.sigma) for the constraint right-hand side.

Related

source
PortfolioOptimisers.ep_rho_views! Function
julia
ep_rho_views!(rho_views::LinearConstraintEstimator, epc::AbstractDict,
              pr::AbstractPriorResult, sets::AssetSets; strict::Bool = false)

Parse and add correlation view constraints to the entropy pooling constraint dictionary.

ep_rho_views! parses correlation view equations from a LinearConstraintEstimator, replaces any prior references with their actual values, and constructs the corresponding linear constraints for entropy pooling. The constraints are then added to the entropy pooling constraint dictionary epc. This method returns a boolean vector indicating which assets require their mean and variance to be fixed to the prior value, ensuring that correlation views do not inadvertently alter lower moments.

Arguments

  • rho_views: Correlation view constraints.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • pr: Prior result containing asset return information.

  • sets: Asset set mapping asset names to indices.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • to_fix::BitVector: Boolean vector indicating which assets require their mean and variance to be fixed.

Details

  • Parses view equations and replaces groupings by assets.

  • Replaces prior references in views with their actual prior correlation values.

  • Converts parsed views to linear constraints and adds them to epc.

  • Returns a boolean vector for assets that need their mean and variance fixed due to correlation constraints.

Related

source
PortfolioOptimisers.ep_sk_views! Function
julia
ep_sk_views!(skew_views::LinearConstraintEstimator, epc::AbstractDict,
             pr::AbstractPriorResult, sets::AssetSets; strict::Bool = false)

Parse and add skewness view constraints to the entropy pooling constraint dictionary.

ep_sk_views! parses skewness view equations from a LinearConstraintEstimator, replaces any prior references with their actual values, and constructs the corresponding linear constraints for entropy pooling. The constraints are then added to the entropy pooling constraint dictionary epc. This method returns a boolean vector indicating which assets require their mean and variance to be fixed to the prior value, ensuring that skewness views do not inadvertently alter lower moments.

Arguments

  • skew_views: Skewness view constraints.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • pr: Prior result containing asset return information.

  • sets: Asset set mapping asset names to indices.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • to_fix::BitVector: Boolean vector indicating which assets require their mean and variance to be fixed.

Details

  • Parses view equations and replaces groupings by assets.

  • Replaces prior references in views with their actual prior skewness values.

  • Converts parsed views to linear constraints and adds them to epc.

  • Returns a boolean vector for assets that need their mean and variance fixed due to skewness constraints.

Related

source
PortfolioOptimisers.ep_kt_views! Function
julia
ep_kt_views!(kurtosis_views::LinearConstraintEstimator, epc::AbstractDict,
             pr::AbstractPriorResult, sets::AssetSets; strict::Bool = false)

Parse and add kurtosis view constraints to the entropy pooling constraint dictionary.

ep_kt_views! parses kurtosis view equations from a LinearConstraintEstimator, replaces any prior references with their actual values, and constructs the corresponding linear constraints for entropy pooling. The constraints are then added to the entropy pooling constraint dictionary epc. This method returns a boolean vector indicating which assets require their mean and variance to be fixed to the prior value, ensuring that kurtosis views do not inadvertently alter lower moments.

Arguments

  • kurtosis_views: Kurtosis view constraints.

  • epc: Dictionary of entropy pooling constraints, mapping keys to (lhs, rhs) pairs.

  • pr: Prior result containing asset return information.

  • sets: Asset set mapping asset names to indices.

  • strict: If true, throws error for missing assets; otherwise, issue warnings.

Returns

  • to_fix::BitVector: Boolean vector indicating which assets require their mean and variance to be fixed.

Details

  • Parses view equations and replaces groupings by assets.

  • Replaces prior references in views with their actual prior kurtosis values.

  • Converts parsed views to linear constraints and adds them to epc.

  • Returns a boolean vector for assets that need their mean and variance fixed due to kurtosis constraints.

Related

source