Skip to content
13

Moment Risk Constraints

PortfolioOptimisers.calc_risk_constraint_target Function
julia
calc_risk_constraint_target(
    _::Union{HighOrderMoment{var"#s9246", var"#s2432", Nothing, var"#s2431"}, LowOrderMoment{var"#s9246", var"#s2432", Nothing, var"#s2431"}} where {var"#s9246", var"#s2432", var"#s2431"},
    w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    mu::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    args...
) -> Any

Compute the target return used as the reference level for lower/upper moment risk constraints.

Dispatches on the type of r.mu: when nothing, uses the prior mean vector mu; when a VecNum, uses r.mu; when a VecScalar, combines the vector and scalar parts with k; when a scalar Number, scales it by k.

Arguments

  • r::LoHiOrderMoment: Risk measure carrying the target specification.

  • w: Portfolio weight vector.

  • mu::VecNum: Prior mean return vector.

  • k: Leverage/scale variable from the model.

Returns

  • The scalar target return used as the lower moment reference.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::LowOrderMoment{<:Any, <:Any, <:Any, <:FirstLowerMoment},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> Any

Add first lower moment, mean absolute deviation, or second moment risk constraints to model.

Each overload introduces auxiliary non-negative variables (semi-deviations or lower exceedances) for T observations, computes an observation-weighted mean, and adds an inequality constraint linking the auxiliary variables to the portfolio returns minus the target. The second-moment overload additionally supports full and lower-half formulations and multiple variance encodings via set_second_moment_risk!.

Mathematical definition

First lower moment / semi-deviation:

FLM(w)=1Tt=1Tzt,ztμwr^t,zt0.

Where:

  • FLM(w): First lower moment.

  • T: Number of observations.

  • zt0: Auxiliary variables capturing deviations below the mean.

  • μ: Expected returns vector.

  • r^t=xtw: Portfolio return at time t.

Mean absolute deviation:

MAD(w)=1Tt=1Tzt,zt|r^tμw|,zt0.

Where:

  • MAD(w): Mean absolute deviation.

  • T: Number of observations.

  • zt0: Auxiliary variables capturing absolute deviations.

  • μ: Expected returns vector.

  • r^t=xtw: Portfolio return at time t.

where r^t=xtw is the net portfolio return at time t.

Arguments

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

  • i: Constraint index for unique variable and constraint naming.

  • r::LowOrderMoment: Risk measure instance.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr::AbstractPriorResult: Prior result containing X (returns matrix) and mu.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::LowOrderMoment{<:Any, <:Any, <:Any, <:MeanAbsoluteDeviation},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> Any

Add JuMP risk constraints for LowOrderMoment with MeanAbsoluteDeviation semi-deviation to model.

Introduces auxiliary mad variables and adds constraints encoding the mean absolute deviation of portfolio returns relative to the target benchmark. Registers the risk expression and upper-bound constraint.

Arguments

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

  • i: Constraint index for unique variable and constraint naming.

  • r::LowOrderMoment{<:Any, <:Any, <:Any, <:MeanAbsoluteDeviation}: The MAD risk measure.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::LowOrderMoment{<:Any, <:Any, <:Any, <:SecondMoment},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> Any

Add JuMP risk constraints for LowOrderMoment with SecondMoment (semi-variance / semi-deviation) to model.

Introduces a sqrt_second_moment variable and adds SOC or quadratic constraints encoding the second central moment of portfolio returns relative to the target benchmark. Registers the risk expression and upper-bound constraint.

Arguments

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

  • i: Constraint index for unique variable and constraint naming.

  • r::LowOrderMoment{<:Any, <:Any, <:Any, <:SecondMoment}: The second-moment risk measure.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_second_moment_risk! Function
julia
set_second_moment_risk!(
    model::Model,
    _::QuadRiskExpr,
    _,
    factor::Number,
    second_moment,
    key::Symbol,
    args...
) -> Tuple{Any, Any}

Build the second-moment risk JuMP expression in one of four encodings.

The QuadRiskExpr overload encodes variance as a quadratic dot product. The RSOCRiskExpr overload uses a rotated second-order cone to encode the squared norm. The SquaredSOCRiskExpr overload squares an existing SOC variable. The SOCRiskExpr overload returns the SOC variable directly (standard deviation form). All methods return the risk expression and a scaling factor.

Arguments

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

  • i: Constraint index for unique variable and constraint naming.

  • factor::Number: Variance correction factor (e.g. 1 / (T - 1)).

  • second_moment: Return deviation vector or matrix.

  • key::Symbol: Symbol used to name constraints or expressions in the model.

  • keyt, keyc: Symbols for the auxiliary variable and its constraint.

  • tsecond_moment: Pre-existing SOC variable (used by SquaredSOC/SOC overloads).

Returns

  • A 2-tuple (r_expr, factor) of the risk JuMP expression and its scaling factor.

Related

source
PortfolioOptimisers.second_moment_bound_val Function
julia
second_moment_bound_val(
    _::SecondMomentFormulation,
    ub::Frontier,
    factor::Number
) -> Frontier{<:Integer, <:Number, LinearBound}

Convert an upper-bound value to the appropriate scale for the second-moment bounding variable.

Scales ub by inv(factor) and, when the formulation is not SOCRiskExpr, applies a square-root transformation to convert from variance to standard-deviation units. Returns nothing when ub is nothing.

Arguments

  • alg::SecondMomentFormulation: Second-moment risk formulation (e.g. SOCRiskExpr).

  • ub: Upper bound value (scalar, vector, Frontier, or nothing).

  • factor::Number: Variance correction factor.

Returns

  • The rescaled upper bound, or nothing when ub is nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::LowOrderMoment{<:Any, <:Any, <:Any, <:EvenMoment},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> VariableRef

Add even-moment risk constraints to model for LowOrderMoment with EvenMoment.

Introduces auxiliary variables even_moment_u, even_moment_t, and even_moment_risk, and adds a chain of power cone constraints encoding the 2p-th central (full) or lower (semi) even moment of portfolio returns relative to the target. Registers the risk expression and upper-bound constraint.

Mathematical definition

The 2p-th even moment is encoded via the following power cone formulation (full variant):

optw,u,s,rrs.t.t=1Tutr(utTd,r,st)Kpow(1p),t=1,,T(st,k,r^tμ)Kpow(12),t=1,,T.

For the semi variant, lower-deviation variables dt0 with r^tμ+dt0 replace the centred returns in the innermost power cone.

Where:

  • r: Even-moment risk variable.

  • u: T × 1 auxiliary variable vector.

  • s: T × 1 auxiliary variable vector.

  • Td=Tddof: Effective sample size.

  • T: Number of observations.

  • k: Budget-scaling / homogenisation variable.

  • p: Order parameter; the moment order is 2p.

  • r^t=xtw: Portfolio return at time t.

  • μ: Target return.

  • Kpow(α): Power cone {(a,b,c):aαb1α|c|,a,b0}.

Arguments

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

  • i: Constraint index for unique variable and constraint naming.

  • r::LowOrderMoment{<:Any, <:Any, <:Any, <:EvenMoment}: The even-moment risk measure.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source