Skip to content
13

Risk budgeting

PortfolioOptimisers.RiskBudgetingResult Type
julia
struct RiskBudgetingResult{__T_jr, __T_prb, __T_fb} <: RiskJuMPOptimisationResult

Result type for Risk Budgeting portfolio optimisation.

Fields

  • jr: Shared JuMP result core, see JuMPOptimisationResult.

  • prb: Processed risk budgeting configuration.

  • fb: Fallback result or estimator.

Property access delegates to the embedded JuMPOptimisationResult; unknown properties forward to prb first, then through jr (including the virtual :w and the pa fall-through).

Related

source
PortfolioOptimisers.factory Method
julia
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                 <:AbstractResult}, args...; kwargs...) -> a

No-op factory function for constructing objects with a uniform interface.

Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.

Arguments

  • a: Indicates no object should be constructed.

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

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

Returns

  • a: The input unchanged.

Examples

julia
julia> factory(nothing, 1, 2; x = 3)

julia> factory(MeanValue())
MeanValue
  w ┴ nothing

Related

source
julia
factory(res::NonFiniteAllocationOptimisationResult, fb::Option{<:OptE_Opt})

Rebuild a continuous optimisation result with an updated fallback optimiser fb.

Every optimisation result carries fb as its last field, so the generic rebuild copies all fields unchanged except the trailing fb. Concrete result types may override this method when rebuilding requires more than swapping fb.

Related

source
julia
factory(
    opt::Union{NonFiniteAllocationOptimisationEstimator, NonFiniteAllocationOptimisationResult},
    _
) -> RandomWeighted{_A, var"#s179", _B, _C, _D, var"#s1791", _E, Bool} where {_A, var"#s179"<:AbstractRNG, _B, _C, _D, var"#s1791"<:WeightFinaliser, _E}

Return opt unchanged.

Default pass-through factory for optimisation estimators and results. Overridden for estimators that carry parameters requiring update at each optimisation step.

Related

source
Base.getproperty Method
julia
getproperty(r::RiskBudgetingResult, sym::Symbol) -> Any

Access properties of RiskBudgetingResult. Unique field prb resolves directly; unknown properties forward into prb first, then delegate to the embedded JuMPOptimisationResult jr (the virtual :w and pa fall-through).

source
PortfolioOptimisers.ProcessedFactorRiskBudgetingAttributes Type
julia
struct ProcessedFactorRiskBudgetingAttributes{__T_rkb, __T_b1, __T_rr} <: AbstractResult

Processed factor risk budgeting attributes for intermediate computations.

Fields

  • rkb: Processed risk budget constraints vector.

  • b1: Factor-level risk budget vector.

  • rr: Regression result used for factor loading estimation.

Related

source
PortfolioOptimisers.ProcessedAssetRiskBudgetingAttributes Type
julia
struct ProcessedAssetRiskBudgetingAttributes{__T_rkb} <: AbstractResult

Processed asset risk budgeting attributes for intermediate computations.

Fields

  • rkb: Processed asset risk budget constraints vector.

Related

source
PortfolioOptimisers.RiskBudgetingFormulation Type
julia
abstract type RiskBudgetingFormulation <: OptimisationAlgorithm

Abstract supertype for risk budgeting optimisation formulations.

Related Types

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(::RiskBudgetingFormulation, args...) -> nothing

Default fallback for risk budgeting formulation view. Returns nothing for formulations that do not require view slicing.

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(x, i, args...; kwargs...) -> nothing_scalar_array_view(x, i)

Universal fallback for port_opt_view. Any value that has no more specific port_opt_view method is treated as leaf data: it is delegated to nothing_scalar_array_view, which slices arrays/VecScalars and passes scalars, nothing, estimators, and algorithms through unchanged. Composed structs that need to recurse into children define their own (more specific) method — emitted by the @vprop tag or hand-written.

The threaded tail args... (typically the returns matrix X for the JuMP families) and any kwargs are accepted and dropped here, so a macro-threaded port_opt_view(child, i, X) never MethodErrors on a leaf field.

Related

source
julia
port_opt_view(::RiskBudgetingFormulation, args...) -> nothing

Default fallback for risk budgeting formulation view. Returns nothing for formulations that do not require view slicing.

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(x, i, args...; kwargs...) -> nothing_scalar_array_view(x, i)

Universal fallback for port_opt_view. Any value that has no more specific port_opt_view method is treated as leaf data: it is delegated to nothing_scalar_array_view, which slices arrays/VecScalars and passes scalars, nothing, estimators, and algorithms through unchanged. Composed structs that need to recurse into children define their own (more specific) method — emitted by the @vprop tag or hand-written.

The threaded tail args... (typically the returns matrix X for the JuMP families) and any kwargs are accepted and dropped here, so a macro-threaded port_opt_view(child, i, X) never MethodErrors on a leaf field.

Related

source
julia
port_opt_view(::RiskBudgetingFormulation, args...) -> nothing

Default fallback for risk budgeting formulation view. Returns nothing for formulations that do not require view slicing.

source
PortfolioOptimisers.LogRiskBudgeting Type
julia
struct LogRiskBudgeting{T} <: RiskBudgetingFormulation

Log-barrier formulation for Risk Budgeting.

Uses a logarithmic objective to enforce the risk budget constraints. Can provide an optional orthant vector to allow for negative weights in specific assets.

Fields

  • z: Optional orthant vector of ±1 defining which assets can have negative weights (-1) or must be positive (+1). If nothing, all assets have positive weights.

Constructors

julia
LogRiskBudgeting(;
    z::Option{<:VecInt} = nothing
) -> LogRiskBudgeting

Keywords correspond to the struct's fields.

Validation

  • If z is provided: !isempty(z) and all(x -> abs(x) == 1, z).

Related

source
PortfolioOptimisers.MixedIntegerRiskBudgeting Type
julia
struct MixedIntegerRiskBudgeting <: RiskBudgetingFormulation

Mixed-integer formulation for Risk Budgeting.

Uses binary variables and big-M constraints to enforce the risk budget constraints. This can find the minimal risk portfolio which meets the risk budgeting constraints by exploring all possible sign combinations of weights. This can be very expensive for large universes.

Related Types

source
PortfolioOptimisers.RiskBudgetingAlgorithm Type
julia
abstract type RiskBudgetingAlgorithm <: OptimisationAlgorithm

Abstract supertype for risk budgeting algorithm specifications.

Related Types

source
PortfolioOptimisers.AssetRiskBudgeting Type
julia
struct AssetRiskBudgeting{__T_rkb, __T_sets, __T_alg} <: RiskBudgetingAlgorithm

Asset-level Risk Budgeting algorithm.

AssetRiskBudgeting specifies the risk budget as a vector of asset-level risk targets, optionally grouped by asset sets.

Fields

  • rkb: Risk budget estimator or result.

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

  • alg: Risk budget algorithm.

Constructors

julia
AssetRiskBudgeting(;
    rkb::Option{<:RkbE_Rkb} = nothing,
    sets::Option{<:AssetSets} = nothing,
    alg::RiskBudgetingFormulation = LogRiskBudgeting()
) -> AssetRiskBudgeting

Keywords correspond to the struct's fields.

Validation

  • If rkb is a RiskBudgetEstimator: !isnothing(sets).

Related

source
PortfolioOptimisers.FactorRiskBudgeting Type
julia
struct FactorRiskBudgeting{__T_re, __T_rkb, __T_sets, __T_flag} <: RiskBudgetingAlgorithm

Factor-level Risk Budgeting algorithm.

FactorRiskBudgeting specifies the risk budget at the factor level, using a factor model regression to decompose risk across factors and an idiosyncratic component.

Fields

  • re: Regression estimator.

  • rkb: Risk budget estimator or result.

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

  • flag: Algorithm selection flag.

Constructors

julia
FactorRiskBudgeting(;
    re::RegE_Reg = StepwiseRegression(),
    rkb::Option{<:RkbE_Rkb} = nothing,
    sets::Option{<:AssetSets} = nothing,
    flag::Bool = true
) -> FactorRiskBudgeting

Keywords correspond to the struct's fields.

Validation

  • If rkb is a RiskBudgetEstimator: !isnothing(sets).

Related

source
PortfolioOptimisers.RiskBudgeting Type
julia
struct RiskBudgeting{__T_opt, __T_r, __T_rba, __T_wi, __T_fb} <: RiskJuMPOptimisationEstimator

Risk Budgeting (RB) portfolio optimiser.

RiskBudgeting allocates portfolio weights so that each asset (or factor) contributes a specified fraction of the total portfolio risk. It uses a logarithmic or mixed-integer formulation and can be combined with any risk measure.

Fields

  • opt: JuMP optimiser configuration.

  • r: Risk measure or vector of risk measures.

  • rba: Risk budget algorithm.

  • wi: Initial portfolio weights for warm-starting the solver.

  • fb: Fallback result or estimator.

Constructors

julia
RiskBudgeting(;
    opt::JuMPOptimiser = JuMPOptimiser(),
    r::RM_VecRM = Variance(),
    rba::RiskBudgetingAlgorithm = AssetRiskBudgeting(),
    wi::Option{<:VecNum} = nothing,
    fb::Option{<:OptE_Opt} = nothing
) -> RiskBudgeting

Keywords correspond to the struct's fields.

Validation

  • If r is a vector: !isempty(r).

  • If wi is provided: !isempty(wi).

Mathematical definition

Risk budgeting allocates weights so that each asset i contributes a target fraction bi of total portfolio risk:

wiρ(w)wi=biρ(w),i=1Nbi=1,bi0.

The logarithmic formulation (LogRiskBudgeting) solves the equivalent convex problem:

minwρ(w)i=1Nbilnwis.t.w>0.

Where:

  • wi: Portfolio weight of asset i.

  • ρ(w): Portfolio risk measure.

  • bi: Risk budget (target risk fraction) for asset i.

  • N: Number of assets.

  • w: Portfolio weight vector.

Related

source
PortfolioOptimisers.needs_previous_weights Method
julia
needs_previous_weights(opt::RiskBudgeting) -> Any

Return true if any sub-estimator of opt requires previous portfolio weights (JuMP optimiser, risk measure, or fallback).

source
PortfolioOptimisers.factory Method
julia
factory(
    rb::RiskBudgeting,
    w::AbstractVector
) -> RiskBudgeting{JuMPOptimiser{__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict}, _A, <:RiskBudgetingAlgorithm} where {__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict, _A}

Build an updated RiskBudgeting with all estimators that track previous weights updated via factory using w.

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    rb::RiskBudgeting,
    i,
    X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    args...
) -> RiskBudgeting{JuMPOptimiser{__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict}, _A, <:RiskBudgetingAlgorithm} where {__T_pe, __T_slv, __T_wb, __T_bgt, __T_sbgt, __T_lt, __T_st, __T_lcse, __T_cte, __T_gcarde, __T_sgcarde, __T_smtx, __T_sgmtx, __T_slt, __T_sst, __T_sglt, __T_sgst, __T_tn, __T_fees, __T_sets, __T_tr, __T_ple, __T_ret, __T_sca, __T_ccnt, __T_cobj, __T_sc, __T_so, __T_ss, __T_card, __T_scard, __T_nea, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict, _A}

Return a cluster-sliced copy of RiskBudgeting for asset index set i and returns matrix X.

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(r, i)

Return a view or subset of a risk budgeting algorithm for cluster index i.

Used in hierarchical optimisation to slice risk budget and asset set configurations for each cluster.

Arguments

Returns

  • Sliced risk budgeting algorithm.

Related

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(r::FactorRiskBudgeting, i)

Return a view of a FactorRiskBudgeting algorithm for cluster index i.

Slices the regression estimator for the given cluster while keeping the risk budget, asset sets, and idiosyncratic flag unchanged.

Arguments

  • r::FactorRiskBudgeting: Factor-level risk budgeting algorithm.

  • i: Cluster or asset index.

Returns

  • FactorRiskBudgeting with the regression estimator sliced to cluster i.

Related

source
PortfolioOptimisers._set_risk_budgeting_constraints! Method
julia
_set_risk_budgeting_constraints!(model, rb, ...)

Internal function to set risk budgeting constraints in the JuMP model.

Configures the equality constraints ensuring each asset's marginal risk contribution equals its budget target.

Arguments

  • model: JuMP model.

  • rb: RiskBudgeting optimiser configuration.

  • Additional risk and budget parameters.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_budgeting_constraints! Function
julia
set_risk_budgeting_constraints!(model, rb, pr, wb, args...)

Add risk budgeting constraints and weight variables to the JuMP model.

Dispatches based on the risk budgeting algorithm and formulation. Sets up weight variables, logarithmic risk budget constraints, and weight bounds for the specified formulation (log, MIP, or factor-based).

Arguments

  • model::JuMP.Model: JuMP optimisation model.

  • rb::RiskBudgeting: Risk budgeting estimator configuration.

  • pr::AbstractPriorResult: Prior result with asset moments.

  • wb::WeightBounds: Weight bounds configuration.

  • args...: Additional arguments (e.g. returns data for factor risk budgeting).

Returns

  • Processed risk budgeting attributes.

Related

source
PortfolioOptimisers.set_rb_mip_w! Function
julia
set_rb_mip_w!(model::JuMP.Model, X::MatNum)

Create long and short weight variables for MIP risk budgeting in the JuMP model.

Registers long lw, short sw weight variables and the derived expressions w = lw - sw and w_obj = lw + sw.

Arguments

  • model::JuMP.Model: JuMP optimisation model.

  • X::MatNum: Asset returns matrix (used to determine number of assets).

Returns

  • nothing.

Related

source
PortfolioOptimisers.optimise Function
julia
optimise(rb::RiskBudgeting{<:Any, <:Any, <:Any, <:Any, Nothing},
         rd::ReturnsResult = ReturnsResult(); dims::Int = 1,
         str_names::Bool = false, save::Bool = true, kwargs...) -> RiskBudgetingResult

Run the Risk Budgeting portfolio optimisation.

Arguments

  • rb: The risk budgeting optimiser to use.

  • rd: The returns result to use. If isa(rb.opt.pe, AbstractPriorResult), rd is not necessary if doing a standalone optimisation, but may be required/desired by fallbacks and/or clusterisation.

  • dims: The dimension along which observations advance in time.

  • str_names: Whether to use string names for the assets in the optimisation.

  • save: Whether to save the JuMP model in the optimisation result.

  • kwargs: Additional keyword arguments passed to the optimisation function.

Related

source