Moment risk measure constraints
The methods below are public. The other names of this topic are private, and the private page documents them.
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::LowOrderMoment{<:Any, <:Any, <:Any, <:FirstLowerMoment},
opt::Union{AbstractProgrammeAllocationSet, 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} - \bar{F}(\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.
- $\bar{F}(\boldsymbol{w})$: Mean fee per period, subtracted by
calc_risk_constraint_targetso that the target is the net mean. Zero without a fee. - $\hat{r}_t$: Net portfolio return at time $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fee of the period.
Mean absolute deviation:
\[\begin{align} \mathrm{MAD}(\boldsymbol{w}) &= \frac{2}{T}\sum_{t=1}^T z_t + \frac{1}{T}\sum_{t=1}^T \hat{r}_t - \boldsymbol{\mu}^\intercal \boldsymbol{w} + \bar{F}(\boldsymbol{w})\,, \\ z_t &\geq \boldsymbol{\mu}^\intercal \boldsymbol{w} - \bar{F}(\boldsymbol{w}) - \hat{r}_t,\quad z_t \geq 0\,. \end{align}\]
The row is one-sided, and the identity $\lvert d \rvert = 2 \max(-d, 0) + d$ gives the absolute deviation from it. The mean of the second term is the gap between the mean net return and the target, so the expression is exact for every target, not only for the mean.
Where:
- $\mathrm{MAD}(\boldsymbol{w})$: Mean absolute deviation.
- $T$: Number of observations.
- $z_t \geq 0$: Auxiliary variables capturing the deviations below the target.
- $\boldsymbol{\mu}$: Expected returns vector.
- $\bar{F}(\boldsymbol{w})$: Mean fee per period, subtracted by
calc_risk_constraint_targetso that the target is the net mean. Zero without a fee. - $\hat{r}_t$: Net portfolio return at time $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fee of the period.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::LowOrderMoment: Risk measure instance.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr::AbstractPriorResult: Prior result containingX(returns matrix) andmu.
Returns
- The risk expression:
flm_risk_underFirstLowerMoment,mad_risk_underMeanAbsoluteDeviation, andsecond_moment_risk_underSecondMoment.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::LowOrderMoment{<:Any, <:Any, <:Any, <:MeanAbsoluteDeviation},
opt::Union{AbstractProgrammeAllocationSet, 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::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr: Prior result.
Returns
mad_risk: The risk expression.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::LowOrderMoment{<:Any, <:Any, <:Any, <:SecondMoment},
opt::Union{AbstractProgrammeAllocationSet, 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::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr: Prior result.
Returns
second_moment_risk: The risk expression ofset_second_moment_risk!.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::LowOrderMoment{<:Any, <:Any, <:Any, <:EvenMoment},
opt::Union{AbstractProgrammeAllocationSet, 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 \in \mathcal{I}} 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 \in \mathcal{I} \\ \quad & \left(s_t,\, k,\, \hat{r}_t - \mu\right) \in \mathcal{K}_{\mathrm{pow}}\!\left(\tfrac{1}{2}\right),\quad t \in \mathcal{I}\,. \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. With observation weights $q_t$, the budget row reads $\sum_{t \in \mathcal{I}} q_t u_t$.
The variables and the rows cover the observations of positive weight only. An observation of weight zero does not change the moment, but the power cone row of a large loss can stop the solver far from the optimum.
Where:
- $r$: Even-moment risk variable.
- $\boldsymbol{u}$:
N × 1auxiliary variable vector, with one entry for each observation in $\mathcal{I}$. - $\boldsymbol{s}$:
N × 1auxiliary variable vector, with one entry for each observation in $\mathcal{I}$. - $\mathcal{I}$: Set of the observations of positive weight. Without observation weights, it holds all $T$ observations.
- $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::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr: Prior result.
Returns
even_moment_risk: The epigraph variable of the even moment, the risk expression.
Related