Skip to content
18

Factor risk contribution

PortfolioOptimisers.FactorRiskContributionResult Type
julia
struct FactorRiskContributionResult{__T_jr, __T_rr, __T_frc_plr, __T_fb} <: RiskJuMPOptimisationResult

Result type for Factor Risk Contribution portfolio optimisation.

Fields

  • jr: Shared JuMP result core, see JuMPOptimisationResult.

  • rr: Regression result.

  • frc_plr: Factor risk contribution placeholder result.

  • fb: Fallback result or estimator.

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

Constructors

julia
FactorRiskContributionResult(;
    jr::JuMPOptimisationResult, rr::AbstractRegressionResult,
    frc_plr::Option{<:AbstractPhylogenyConstraintResult}, fb::Option{<:OptE_Opt}
) -> FactorRiskContributionResult

Keywords correspond to the struct's fields.

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.

factory and port_opt_view are the two propagation mechanisms in this library. They are duals: factory threads runtime values (prior moments, observation weights, previous portfolio weights) down through a composed struct tree; port_opt_view threads an index selection (a subset of assets or observations) down through the same tree.

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},
    _
) -> SubsetResamplingResult

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
PortfolioOptimisers.factor_risk_contribution_td_defaults Function
julia
factor_risk_contribution_td_defaults(

) -> @NamedTuple{re::StepwiseRegression{PValue{Float64}, ForwardSelection, LinearModel{@NamedTuple{}}}, r::Variance{RiskMeasureSettings{Float64, Nothing, Bool}, Nothing, Nothing, Nothing, SquaredSOCRiskExpr}, obj::MinimumRisk}

Return the static defaults of the FactorRiskContribution fields that may hold a TimeDependent.

Shared by the constructor's test-substitution pass and time_dependent_field_defaults, so the fold-less value of a field is declared once. Fields whose static default is nothing are omitted.

Related

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

Default property access for RiskJuMPOptimisationResult: unique fields resolve directly; everything else delegates to the embedded JuMPOptimisationResult jr.

source
PortfolioOptimisers.FactorRiskContribution Type
julia
struct FactorRiskContribution{__T_opt, __T_re, __T_r, __T_obj, __T_frc_ple, __T_sets, __T_wi, __T_flag, __T_fb} <: RiskJuMPOptimisationEstimator

Factor Risk Contribution (FRC) portfolio optimiser.

FactorRiskContribution allocates portfolio weights so that each factor (and the idiosyncratic component) contributes a target proportion to the total portfolio risk. It combines factor regression with a JuMP-based risk budgeting optimisation.

Mathematical definition

Factor model:

ri=αi+Fβi+εi.

Factor risk contribution for factor k:

RCk=βk,wR(w)βk,w,βk,w=wβk.

Where:

  • ri: Return vector of asset i.

  • αi: Intercept (idiosyncratic return) for asset i.

  • F: Factor returns matrix.

  • βi: Factor loading vector for asset i.

  • εi: Idiosyncratic residual for asset i.

  • RCk: Risk contribution of factor k.

  • βk,w: Portfolio-level exposure to factor k.

  • R(w): Portfolio risk measure.

  • w: Portfolio weight vector.

Fields

  • opt: JuMP optimiser configuration.

  • re: Regression estimator.

  • r: Risk measure or vector of risk measures.

  • obj: Portfolio objective function.

  • frc_ple: Factor risk contribution placeholder constraints.

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

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

  • flag: Algorithm selection flag.

  • fb: Fallback result or estimator.

Constructors

julia
FactorRiskContribution(;
    opt::JuMPOptimiser,
    re::TD{<:RegE_Reg} = StepwiseRegression(),
    r::TD{<:RM_VecRM} = Variance(),
    obj::TD{<:ObjectiveFunction} = MinimumRisk(),
    frc_ple::TD_Option{<:PlCE_PhC_VecPlCE_PlC} = nothing,
    sets::TD_Option{<:AssetSets} = nothing,
    wi::TD_Option{<:VecNum} = nothing,
    flag::Bool = false,
    fb::TDO_Option{<:OptE_Opt} = nothing
) -> FactorRiskContribution

Keywords correspond to the struct's fields. Fields typed TD, TD_Option or TDO_Option may hold a TimeDependent per-fold schedule instead of a static value: the factor model, risk measure, objective, placeholder constraints, asset sets, warm start and fallback are problem definition, so a cross-validation fold loop resolves them per fold, and a fold-less optimise runs with each at its static default. flag is execution control and stays static.

Validation

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

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

  • fb schedules: bind !== :nearest.

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

  • opt: Recursively updated via factory.

  • r: Recursively updated via factory.

  • fb: Recursively updated via factory.

Related

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

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

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    frc::FactorRiskContribution,
    i,
    X::AbstractMatrix{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}},
    args...
) -> FactorRiskContribution{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_wn2, __T_wnp, __T_wninf, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict}, _A, _B, _C, _D, _E, _F, Bool} 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_wn2, __T_wnp, __T_wninf, __T_l1, __T_l2, __T_linf, __T_lp, __T_brt, __T_cle_pr, __T_strict, _A, _B, _C, _D, _E, _F}

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

source
PortfolioOptimisers.set_factor_risk_contribution_constraints! Method
julia
set_factor_risk_contribution_constraints!(model, re, ...)

Add factor risk contribution constraints to the JuMP model.

Sets up the factor-level risk budgeting constraints in the optimisation model, using the regression result or estimator re to specify factor loadings.

Arguments

  • model: JuMP model.

  • re: Regression result or estimator (RegE_Reg).

  • Additional risk and budget parameters.

Returns

  • nothing.

Related

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

Run the Factor Risk Contribution portfolio optimisation.

Arguments

  • frc: The factor risk contribution optimiser to use.

  • rd: The returns result to use. If isa(frc.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