Moment Risk Constraints: private API

PortfolioOptimisers.calc_risk_constraint_targetFunction
calc_risk_constraint_target(
    _::Union{HighOrderMoment{var"#s7100", var"#s7099", Nothing, var"#s7098"}, LowOrderMoment{var"#s7100", var"#s7099", Nothing, var"#s7098"}} where {var"#s7100", var"#s7099", var"#s7098"},
    w::AbstractVector{<:Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<:AbstractJuMPScalar}},
    mu::AbstractVector{<:Union{var"#s136", var"#s53"} where {var"#s136"<:Number, var"#s53"<: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
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:

\[\begin{align} \mathrm{FLM}(\boldsymbol{w}) &= \frac{1}{T}\sum_{t=1}^T z_t\,, \\ z_t &\geq \boldsymbol{\mu}^\intercal \boldsymbol{w} - \hat{r}_t,\quad z_t \geq 0\,. \end{align}\]

Where:

  • $\mathrm{FLM}(\boldsymbol{w})$: First lower moment.
  • $T$: Number of observations.
  • $z_t \geq 0$: Auxiliary variables capturing deviations below the mean.
  • $\boldsymbol{\mu}$: Expected returns vector.
  • $\hat{r}_t = \boldsymbol{x}_t^\intercal \boldsymbol{w}$: Portfolio return at time $t$.

Mean absolute deviation:

\[\begin{align} \mathrm{MAD}(\boldsymbol{w}) &= \frac{1}{T}\sum_{t=1}^T z_t\,, \\ z_t &\geq |\hat{r}_t - \boldsymbol{\mu}^\intercal \boldsymbol{w}|,\quad z_t \geq 0\,. \end{align}\]

Where:

  • $\mathrm{MAD}(\boldsymbol{w})$: Mean absolute deviation.
  • $T$: Number of observations.
  • $z_t \geq 0$: Auxiliary variables capturing absolute deviations.
  • $\boldsymbol{\mu}$: Expected returns vector.
  • $\hat{r}_t = \boldsymbol{x}_t^\intercal \boldsymbol{w}$: Portfolio return at time $t$.

where $\hat{r}_t = \boldsymbol{x}_t^\intercal \boldsymbol{w}$ 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
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
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
set_second_moment_risk!(
    model::Model,
    ::QuadRiskExpr,
    i,
    factor::Number,
    second_moment,
    args...;
    prefix
) -> 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.
  • namet, namec: Bare Model State entry names for the auxiliary variable and its constraint.
  • tsecond_moment: Pre-existing SOC variable (used by SquaredSOC/SOC overloads).

Keyword arguments

  • prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).

Returns

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

Related

source
PortfolioOptimisers.second_moment_bound_valFunction
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
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):

\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{u},\,\boldsymbol{s},\,r}{\mathrm{opt}} \quad & r \\ \mathrm{s.t.} \quad & \sum_{t=1}^{T} u_t \leq r \\ \quad & \left(u_t \cdot T_d,\, r,\, s_t\right) \in \mathcal{K}_{\mathrm{pow}}\!\left(\tfrac{1}{p}\right),\quad t = 1,\ldots,T \\ \quad & \left(s_t,\, k,\, \hat{r}_t - \mu\right) \in \mathcal{K}_{\mathrm{pow}}\!\left(\tfrac{1}{2}\right),\quad t = 1,\ldots,T\,. \end{align}\]

For the semi variant, lower-deviation variables $d_t \geq 0$ with $\hat{r}_t - \mu + d_t \geq 0$ replace the centred returns in the innermost power cone.

Where:

  • $r$: Even-moment risk variable.
  • $\boldsymbol{u}$: T × 1 auxiliary variable vector.
  • $\boldsymbol{s}$: T × 1 auxiliary variable vector.
  • $T_d = T - \mathrm{ddof}$: Effective sample size.
  • $T$: Number of observations.
  • $k$: Budget-scaling / homogenisation variable.
  • $p$: Order parameter; the moment order is $2p$.
  • $\hat{r}_t = \boldsymbol{x}_t^\intercal\boldsymbol{w}$: Portfolio return at time $t$.
  • $\mu$: Target return.
  • $\mathcal{K}_{\mathrm{pow}}(\alpha)$: Power cone $\{(a, b, c) : a^{\alpha}\,b^{1-\alpha} \geq |c|,\; a, b \geq 0\}$.

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