Moment Risk Measures
PortfolioOptimisers.FirstLowerMoment — Type
struct FirstLowerMoment <: UnstandardisedLowOrderMomentMeasureAlgorithmRepresents the first lower moment risk measure algorithm.
Computes portfolio risk using the first lower moment, which is the negative mean of the deviations of the returns series below a target value.
Related
References
- [98] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
PortfolioOptimisers.MeanAbsoluteDeviation — Type
struct MeanAbsoluteDeviation <: UnstandardisedLowOrderMomentMeasureAlgorithmRepresents the mean absolute deviation risk measure algorithm.
Computes portfolio risk as the mean of the absolute deviations of the returns series from a target value.
Related
References
- [99] H. Konno and H. Yamazaki. Mean-absolute deviation portfolio optimization model and its applications to Tokyo stock market. Management Science 37, 519–531 (1991).
PortfolioOptimisers.SecondMoment — Type
struct SecondMoment{__T_ve, __T_alg1, __T_alg2} <: LowOrderMomentMeasureAlgorithmRepresents a second moment (variance or standard deviation) risk measure algorithm.
Computes portfolio risk using the second central (full) or lower (semi) moment of the return distribution, supporting both full and semi (downside) formulations. The specific formulation is determined by the alg1 and alg2 fields, enabling flexible representation of variance, semi-variance, standard deviation, or semi-standard deviation.
Fields
ve: Variance estimator.
alg1: First algorithm variant.
alg2: Second algorithm variant.
Constructors
SecondMoment(; ve::AbstractVarianceEstimator = SimpleVariance(; me = nothing), alg1::AbstractMomentAlgorithm = FullMoment(), alg2::SecondMomentFormulation = SquaredSOCRiskExpr(),) -> SecondMomentKeywords correspond to the struct's fields.
Propagated parameters
When factory is called on this type, the following @fprop-tagged fields are automatically propagated:
ve: Recursively updated viafactory.
Examples
julia> SecondMoment()SecondMoment ve ┼ SimpleVariance │ me ┼ nothing │ w ┼ nothing │ corrected ┴ Bool: true alg1 ┼ FullMoment() alg2 ┴ SquaredSOCRiskExpr()Related
LowOrderMomentMeasureAlgorithmAbstractVarianceEstimatorAbstractMomentAlgorithmSecondMomentFormulationfactory
References
- [11] H. Markowitz. Modern portfolio theory. Journal of Finance 7, 77–91 (1952).
PortfolioOptimisers.EvenMoment — Type
struct EvenMoment{__T_p, __T_ddof, __T_alg} <: UnstandardisedLowOrderMomentMeasureAlgorithmRepresents an even-order moment risk measure algorithm.
Computes portfolio risk using the $p$-th root of the $2p$-th central (full) or lower (semi) even moment of the return distribution. Despite the potentially high moment order, even moments admit an exact power cone reformulation, keeping the optimisation formulation affine.
Fields
p: Power or order parameter.
ddof: Degrees-of-freedom correction.
alg: Moment algorithm.
Constructors
EvenMoment(; p::Integer = 2, ddof::Integer = 0, alg::AbstractMomentAlgorithm = FullMoment(),) -> EvenMomentKeywords correspond to the struct's fields.
Validation
p >= 2.ddof >= 0andisfinite(ddof).
Examples
julia> EvenMoment()EvenMoment p ┼ Int64: 2 ddof ┼ Int64: 0 alg ┴ FullMoment()Related
References
- [100] D. Cajas. Portfolio Optimization of Even Moments using Power Cone Programming. Available at SSRN 6518258 (2026).
PortfolioOptimisers.LowOrderMoment — Type
struct LowOrderMoment{__T_settings, __T_w, __T_mu, __T_alg} <: RiskMeasureRepresents a low-order moment risk measure.
Computes portfolio risk using a low-order moment algorithm (such as first lower moment, mean absolute deviation, or second moment), optionally with custom weights and target values. This type is used for risk measures based on mean, variance, or related statistics.
Mathematical definition
Depending on the alg field, the risk measure computes one of the following quantities.
FirstLowerMoment
The first lower moment is computed as:
\[\begin{align} \mathrm{FirstLowerMoment}(\boldsymbol{X}) &= \mathbb{E}\left[\max \circ \left(\mathbb{E}\left[\boldsymbol{X}\right] - \boldsymbol{X},\, 0\right)\right]\,. \end{align}\]
Where:
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
- $\circ$: Element-wise function application.
MeanAbsoluteDeviation
The mean absolute deviation is computed as:
\[\begin{align} \mathrm{MeanAbsoluteDeviation}(\boldsymbol{X}) &= \mathbb{E}\left[\left\lvert \boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right] \right\rvert\right]\,. \end{align}\]
Where:
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
SecondMoment
Depending on the alg1 field the risk measure can either compute the second central moment or second lower moment.
Both central and lower moments can be formulated as quadratic moments (variance or semi-variance) or their square roots (standard deviation or semi-standard deviation). Regardless of whether they are central or lower moments, they can be formulated in a variety of ways.
Depending on the alg2 field, it can represent the variance (using different formulations in JuMP) or standard deviation.
The (semi-)variance formulations are:
It is computed as:
\[\begin{align} \mathrm{Variance}(\boldsymbol{X}) &= \mathbb{E}\left[\left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right]\right)^2\right] \,, \\ \mathrm{SemiMoment\text{-}Variance}(\boldsymbol{X}) &= \mathbb{E}\left[\min \circ \left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right],\,0\right)^2\right] \,. \end{align}\]
Where:
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
The (semi-)standard deviation formulation is:
It is computed as:
\[\begin{align} \mathrm{StandardDeviation}(\boldsymbol{X}) &= \sqrt{\mathbb{E}\left[\left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right]\right)^2\right]} \,, \\ \mathrm{SemiMoment\text{-}StandardDeviation}(\boldsymbol{X}) &= \sqrt{\mathbb{E}\left[\min \circ \left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right],\,0\right)^2\right]} \,. \end{align}\]
Where:
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
EvenMoment
EvenMoment computes the $2p$-th central (full) or lower (semi) moment of the return distribution. Although the moment order $2p \geq 4$ can be arbitrarily high, EvenMoment is not a low-order moment in the classical sense. However, because the exponent is always even, the moment can be expressed as an iterated power of squared deviations, admitting an exact reformulation using power cone constraints. This makes the optimisation problem affine and solvable by standard conic solvers.
The full (central) even moment is computed as:
\[\begin{align} \mathrm{EvenMoment}_{p}(\boldsymbol{X}) &= \left(\frac{1}{T_d}\sum_{t=1}^{T}\left(\boldsymbol{X}_t - \mathbb{E}\left[\boldsymbol{X}\right]\right)^{2p}\right)^{1/p}\,. \end{align}\]
The semi (lower) even moment is computed as:
\[\begin{align} \mathrm{SemiMoment\text{-}EvenMoment}_{p}(\boldsymbol{X}) &= \left(\frac{1}{T_d}\sum_{t=1}^{T}\min \circ \left(\boldsymbol{X}_t - \mathbb{E}\left[\boldsymbol{X}\right],\, 0\right)^{2p}\right)^{1/p}\,. \end{align}\]
Where:
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
- $T_d = T - \mathrm{ddof}$: Effective sample size after degrees-of-freedom correction.
- $p \geq 2$: Order parameter; the moment order is $2p$.
- $\circ$: Element-wise function application.
Fields
settings: Risk measure settings.
w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.
mu: Optional centre the moment is taken about, a scalar or a vectorassets × 1. Also admits a Deferred Quantity — an expected returns estimator or a prior estimator that computes the centre against the optimisation's own prior, atfactorytime (seeMuSlotandresolve_deferred_quantities). Ifnothing, the prior supplies it.
alg: Moment algorithm.
Constructors
LowOrderMoment(; settings::RiskMeasureSettings = RiskMeasureSettings(), w::Option{<:ObsWeights} = nothing, mu::Option{<:MuSlot} = nothing, alg::LowOrderMomentMeasureAlgorithm = FirstLowerMoment(),) -> LowOrderMomentKeywords correspond to the struct's fields.
Validation
If
muis notnothing:::Number:isfinite(mu).::AbstractVector:!isempty(mu)andall(isfinite, mu).
If
wis notnothing,!isempty(w).
A stated mu is pinned: it crosses a Cross-Validation fold or a subset view as the whole universe's answer, so it does not follow the refit the optimisation runs on. A caller who wants it to follow the fit names a Deferred Quantity in mu, or leaves the slot nothing and lets the prior supply it.
JuMP Formulations
Depending on the alg field, the risk measure is formulated in JuMP as follows. Every formulation measures the deviations against the target returned by calc_risk_constraint_target, which is mu when the slot holds a value and the prior's expected returns otherwise.
FirstLowerMoment
As an optimisation problem, it can be formulated as:
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & \mathbb{E}\left[\boldsymbol{d}\right] \\ \mathrm{s.t.} \quad & \boldsymbol{d} \geq \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] - \mathrm{X} \boldsymbol{w}\\ \quad & \boldsymbol{d} \geq 0 \,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations below the target. - $\mathrm{X}$:
T × Nreturn matrix. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
MeanAbsoluteDeviation
As an optimisation problem, it can be formulated as:
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & 2 \mathbb{E}\left[\boldsymbol{d}\right]\\ \mathrm{s.t.} \quad & \boldsymbol{d} \geq \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] - \mathrm{X} \boldsymbol{w}\\ \quad & \boldsymbol{d} \geq 0 \,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations below the target. - $\mathrm{X}$:
T × Nreturn matrix. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
SecondMoment
Regardless of the formulation used, an auxiliary variable representing the square root of the central/lower moment is needed in order to constrain the risk or maximise the risk-adjusted return ratio. This is because quadratic constraints are not strictly convex, and the transformation needed to maximise the risk-adjusted return ratio requires affine variables in the numerator and denominator.
SquaredSOCRiskExpr
Represents the (semi-)variance using the square of a second order cone constrained variable.
The variance is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & f \cdot \sigma^2\\ \mathrm{s.t.} \quad & \boldsymbol{d} = \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d} \\ \quad & \left(\sigma,\, \boldsymbol{d}_s\right) \in K_{soc}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $\sigma$: Standard deviation of the portfolio returns.
- $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $K_{soc}$: Second order cone.
- $\odot$: Element-wise (Hadamard) product.
The semi-variance is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & f \cdot \sigma^2\\ \mathrm{s.t.} \quad & \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \geq -\boldsymbol{d} \\ \quad & \boldsymbol{d} \geq 0 \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d} \\ \quad & \left(\sigma,\, \boldsymbol{d}_s\right) \in K_{soc}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $\sigma$: Standard deviation of the portfolio returns.
- $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $K_{soc}$: Second order cone.
- $\odot$: Element-wise (Hadamard) product.
RSOCRiskExpr
Represents the (semi-)variance using a sum of squares formulation via a rotated second order cone.
The variance is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & f \cdot t\\ \mathrm{s.t.} \quad & \boldsymbol{d} = \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d} \\ \quad & \left(t,\, 0.5,\,\boldsymbol{d}_s\right) \in K_{rsoc}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $t$: Variance of the portfolio returns.
- $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $K_{rsoc}$: Rotated second order cone.
- $\odot$: Element-wise (Hadamard) product.
The semi-variance is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & f \cdot t\\ \mathrm{s.t.} \quad & \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \geq -\boldsymbol{d} \\ \quad & \boldsymbol{d} \geq 0 \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d} \\ \quad & \left(t,\, 0.5,\,\boldsymbol{d}_s\right) \in K_{rsoc}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $t$: Variance of the portfolio returns.
- $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $K_{rsoc}$: Rotated second order cone.
- $\odot$: Element-wise (Hadamard) product.
QuadRiskExpr
Represents the (semi-)variance using the deviations vector dotted with itself.
The variance is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & f \cdot \boldsymbol{d}_s \cdot \boldsymbol{d}_s\\ \mathrm{s.t.} \quad & \boldsymbol{d} = \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $\odot$: Element-wise (Hadamard) product.
The semi-variance is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & f \cdot \boldsymbol{d}_s \cdot \boldsymbol{d}_s\\ \mathrm{s.t.} \quad & \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \geq -\boldsymbol{d} \\ \quad & \boldsymbol{d} \geq 0 \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\mu$: Minimum acceptable return.
- $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $\odot$: Element-wise (Hadamard) product.
SOCRiskExpr
Represents the (semi-)standard deviation using a second order cone constrained variable.
The standard deviation is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & \sqrt{f} \cdot \sigma\\ \mathrm{s.t.} \quad & \boldsymbol{d} = \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d} \\ \quad & \left(\sigma,\, \boldsymbol{d}_s\right) \in K_{soc}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $\sigma$: Standard deviation of the portfolio returns.
- $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $K_{soc}$: Second order cone.
- $\odot$: Element-wise (Hadamard) product.
The semi-standard deviation is formulated as.
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{d}}{\mathrm{opt}} \quad & \sqrt{f} \cdot \sigma\\ \mathrm{s.t.} \quad & \mathrm{X} \boldsymbol{w} - \mathbb{E}\left[\mathrm{X} \boldsymbol{w}\right] \geq -\boldsymbol{d} \\ \quad & \boldsymbol{d} \geq 0 \\ \quad & \boldsymbol{d}_s = \sqrt{\boldsymbol{\lambda}} \odot \boldsymbol{d} \\ \quad & \left(\sigma,\, \boldsymbol{d}_s\right) \in K_{soc}\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $\boldsymbol{d}$:
T × 1vector of auxiliary decision variables representing deviations from the target. - $\sigma$: Standard deviation of the portfolio returns.
- $\boldsymbol{d}_s$:
T × 1vector of scaled deviations according to observation weights. - $\mathrm{X}$:
T × Nreturn matrix. - $\mu$: Minimum acceptable return.
- $\boldsymbol{\lambda}$:
T × 1vector of observation weights. - $f$: Variance correction factor from
StatsBase.varcorrection. It corrects for the sample size without observation weights, and for $\boldsymbol{\lambda}$ with them.ve.correctedselects the divisor. - $\odot$: Element-wise (Hadamard) product.
- $K_{soc}$: Second order cone.
EvenMoment
As an optimisation problem, the full even moment is formulated using a chain of power cone constraints:
\[\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}\]
The semi even moment is formulated as:
\[\begin{align} \underset{\boldsymbol{w},\,\boldsymbol{u},\,\boldsymbol{s},\,\boldsymbol{d},\,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,\, d_t\right) \in \mathcal{K}_{\mathrm{pow}}\!\left(\tfrac{1}{2}\right),\quad t = 1,\ldots,T \\ \quad & \hat{r}_t - \mu + d_t \geq 0,\quad t = 1,\ldots,T \\ \quad & d_t \geq 0,\quad t = 1,\ldots,T\,. \end{align}\]
Where:
- $\boldsymbol{w}$:
N × 1asset weights vector. - $r$: Even-moment risk variable.
- $\boldsymbol{u}$:
T × 1auxiliary variable vector. - $\boldsymbol{s}$:
T × 1auxiliary variable vector. - $\boldsymbol{d}$:
T × 1lower-deviation auxiliary variables, capturing returns below the target. - $T_d$: Effective sample size.
- $k$: Budget-scaling / homogenisation variable.
- $p$: Order parameter; the moment order is $2p$.
- $\mathrm{X}$:
T × Nreturn matrix. - $\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\}$.
Functor
(r::LowOrderMoment)(w::VecNum, X::MatNum; fees::Option{<:Fees} = nothing)Computes the low-order moment risk measure as defined in r using portfolio weights w, return matrix X, and optional fees fees.
Details
r.algdefines what low-order moment to compute.- The values of
r.muandr.ware optionally used to compute the moment target viacalc_moment_target, which is used incalc_deviations_vecto compute the deviation vector.
Examples
julia> LowOrderMoment()LowOrderMoment settings ┼ RiskMeasureSettings │ scale ┼ Float64: 1.0 │ ub ┼ nothing │ rke ┴ Bool: true w ┼ nothing mu ┼ nothing alg ┴ FirstLowerMoment()Related
RiskMeasureSettingsLowOrderMomentMeasureAlgorithmFirstLowerMomentMeanAbsoluteDeviationSecondMomentSquaredSOCRiskExprRSOCRiskExprQuadRiskExprSOCRiskExprEvenMoment
References
- [100] D. Cajas. Portfolio Optimization of Even Moments using Power Cone Programming. Available at SSRN 6518258 (2026).
- [98] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
- [99] H. Konno and H. Yamazaki. Mean-absolute deviation portfolio optimization model and its applications to Tokyo stock market. Management Science 37, 519–531 (1991).
- [11] H. Markowitz. Modern portfolio theory. Journal of Finance 7, 77–91 (1952).
PortfolioOptimisers.ThirdLowerMoment — Type
struct ThirdLowerMoment <: UnstandardisedHighOrderMomentMeasureAlgorithmRepresents the unstandardised semi-skewness risk measure algorithm.
Computes portfolio risk using the third lower moment (unstandardised semi-skewness), which quantifies downside asymmetry by considering only the cubed deviations below a target value. The measure negates the mean cubed lower deviation, so a larger value is more downside asymmetry. This algorithm is unstandardised and operates directly on the return distribution.
Related
References
- [98] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
PortfolioOptimisers.FourthMoment — Type
struct FourthMoment{__T_alg} <: UnstandardisedHighOrderMomentMeasureAlgorithmRepresents the unstandardised fourth moment (kurtosis or semi-kurtosis) risk measure algorithm.
Computes portfolio risk using the fourth central (full) or lower (semi) moment of the return distribution, depending on the provided moment algorithm. This algorithm quantifies the "tailedness" of the return distribution without normalising by the variance.
Fields
alg: Moment algorithm.
Constructors
FourthMoment(; alg::AbstractMomentAlgorithm = FullMoment(),) -> FourthMomentKeywords correspond to the struct's fields.
Examples
julia> FourthMoment()FourthMoment alg ┴ FullMoment()Related
References
- [98] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
PortfolioOptimisers.StandardisedHighOrderMoment — Type
struct StandardisedHighOrderMoment{__T_ve, __T_alg} <: HighOrderMomentMeasureAlgorithmRepresents a standardised high-order moment risk measure algorithm.
Computes portfolio risk using a high-order moment algorithm (such as semi-skewness or semi-kurtosis), divided by ve's variance raised to half the moment order. ve runs on the same deviations as alg, so a lower-moment alg is standardised by a semi-variance.
Fields
ve: Variance estimator.
alg: Moment algorithm.
Constructors
StandardisedHighOrderMoment(; ve::AbstractVarianceEstimator = SimpleVariance(; me = nothing), alg::UnstandardisedHighOrderMomentMeasureAlgorithm = ThirdLowerMoment(),) -> StandardisedHighOrderMomentKeywords correspond to the struct's fields.
Examples
julia> StandardisedHighOrderMoment()StandardisedHighOrderMoment ve ┼ SimpleVariance │ me ┼ nothing │ w ┼ nothing │ corrected ┴ Bool: true alg ┴ ThirdLowerMoment()Related
PortfolioOptimisers.HighOrderMoment — Type
struct HighOrderMoment{__T_settings, __T_w, __T_mu, __T_alg} <: HierarchicalRiskMeasureRepresents a high-order moment risk measure.
Computes portfolio risk using a high-order moment algorithm (such as semi-skewness, semi-kurtosis, or kurtosis), optionally with custom weights and target values. This type is used for risk measures based on third or fourth moments of the return distribution.
Mathematical definition
Depending on the alg field, the risk measure computes the third lower moment, fourth lower (semi) moment, or fourth central (full) moment. Each can be standardised or unstandardised.
The unstandardised formulations are:
The standardised formulations are:
StandardisedHighOrderMoment, which uses a variance estimator and an unstandardised high-order moment algorithm.
An odd moment order makes a lower moment negative, so the risk measure returns $(-1)^n \mu_n$. A larger value is therefore always more risk. The third lower moment is negated; the fourth moment is already non-negative and is returned unchanged.
Unstandardised Moments
All unstandardised central moments have the following formula.
\[\begin{align} \mu_n &= \mathbb{E}\left[\left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right]\right)^n\right]\,. \end{align}\]
Where:
- $\mu_n$: $n$-th central moment.
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
- $n$: Moment order.
All unstandardised lower moments have the following formula.
\[\begin{align} \mu_n &= \mathbb{E}\left[\min \circ \left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right],\, 0\right)^n\right]\,. \end{align}\]
Where:
- $\mu_n$: $n$-th lower moment.
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
- $\circ$: Element-wise function application.
- $n$: Moment order.
Standardised Moments
All standardised central moments have the following formula.
\[\begin{align} \mu_n &= \dfrac{\mathbb{E}\left[\left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right]\right)^n\right]}{\mathbb{E}\left[\left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right]\right)^2\right]^{n/2}}\,. \end{align}\]
Where:
- $\mu_n$: $n$-th standardised central moment.
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
- $n$: Moment order.
All standardised lower moments have the following formula.
\[\begin{align} \mu_n &= \dfrac{\mathbb{E}\left[\min \circ \left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right],\, 0\right)^n\right]}{\mathbb{E}\left[\min \circ \left(\boldsymbol{X} - \mathbb{E}\left[\boldsymbol{X}\right],\, 0\right)^2\right]^{n/2}}\,. \end{align}\]
Where:
- $\mu_n$: $n$-th standardised lower moment.
- $\boldsymbol{X}$:
T × 1vector of portfolio returns. - $\mathbb{E}[\cdot]$: Expected value operator, supports weighted averages.
- $\circ$: Element-wise function application.
- $n$: Moment order.
Fields
settings: Risk measure settings.
w: Optional observation weights vectorobservations × 1, or a concrete subtype ofDynamicAbstractWeights. Ifnothing, the computation is unweighted.
mu: Optional centre the moment is taken about, a scalar or a vectorassets × 1. Also admits a Deferred Quantity — an expected returns estimator or a prior estimator that computes the centre against the optimisation's own prior, atfactorytime (seeMuSlotandresolve_deferred_quantities). Ifnothing, the prior supplies it.
alg: Moment algorithm.
Constructors
HighOrderMoment(; settings::RiskMeasureSettings = RiskMeasureSettings(), w::Option{<:ObsWeights} = nothing, mu::Option{<:MuSlot} = nothing, alg::HighOrderMomentMeasureAlgorithm = ThirdLowerMoment(),) -> HighOrderMomentKeywords correspond to the struct's fields.
Validation
If
muis notnothing:::Number:isfinite(mu).::AbstractVector:!isempty(mu)andall(isfinite, mu).
If
wis notnothing,!isempty(w).
A stated mu is pinned: it crosses a Cross-Validation fold or a subset view as the whole universe's answer, so it does not follow the refit the optimisation runs on. A caller who wants it to follow the fit names a Deferred Quantity in mu, or leaves the slot nothing and lets the prior supply it.
Functor
(r::HighOrderMoment)(w::VecNum, X::MatNum; fees::Option{<:Fees} = nothing)Computes the high-order moment risk measure as defined in r using portfolio weights w, return matrix X, and optional fees fees.
Details
r.algdefines what high-order moment to compute.- The values of
r.muandr.ware optionally used to compute the moment target viacalc_moment_target, which is used incalc_deviations_vecto compute the deviation vector.
Examples
julia> HighOrderMoment()HighOrderMoment settings ┼ RiskMeasureSettings │ scale ┼ Float64: 1.0 │ ub ┼ nothing │ rke ┴ Bool: true w ┼ nothing mu ┼ nothing alg ┴ ThirdLowerMoment()Related
RiskMeasureSettingsHighOrderMomentMeasureAlgorithmThirdLowerMomentFourthMomentStandardisedHighOrderMoment
References
- [98] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
PortfolioOptimisers.factory — Method
factory(
alg::StandardisedHighOrderMoment,
w::Union{DynamicAbstractWeights, AbstractWeights}
) -> StandardisedHighOrderMoment{<:AbstractVarianceEstimator, <:UnstandardisedHighOrderMomentMeasureAlgorithm}
Return a new StandardisedHighOrderMoment with observation weights w applied to the underlying variance estimator.
Related
PortfolioOptimisers.factory — Method
factory(
alg::MomentMeasureAlgorithm,
args...;
kwargs...
) -> SecondMoment{<:AbstractVarianceEstimator, <:AbstractMomentAlgorithm, <:SecondMomentFormulation}
Return the moment measure algorithm alg unchanged.
Identity pass-through used when a moment measure algorithm is provided in a context that calls factory.
Related
PortfolioOptimisers.factory — Method
factory(
r::LowOrderMoment,
pr::AbstractPriorResult,
args...;
kwargs...
) -> LowOrderMoment{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, _A, _B, <:LowOrderMomentMeasureAlgorithm} where {__T_scale, __T_ub, __T_rke, _A, _B}
Create an instance of LowOrderMoment by selecting observation weights, expected returns, and algorithm from the risk-measure instance or falling back to the prior result.
Related
PortfolioOptimisers.port_opt_view — Method
port_opt_view(
r::LowOrderMoment,
i,
args...
) -> LowOrderMoment{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, _A, _B, <:LowOrderMomentMeasureAlgorithm} where {__T_scale, __T_ub, __T_rke, _A, _B}
Return a view of LowOrderMoment r sliced to asset indices i.
Slices the expected returns mu for cluster-based optimisation.
Related
PortfolioOptimisers.factory — Method
factory(
r::HighOrderMoment,
pr::AbstractPriorResult,
args...;
kwargs...
) -> HighOrderMoment{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, _A, _B, <:HighOrderMomentMeasureAlgorithm} where {__T_scale, __T_ub, __T_rke, _A, _B}
Create an instance of HighOrderMoment by selecting observation weights, expected returns, and algorithm from the risk-measure instance or falling back to the prior result.
Related
PortfolioOptimisers.port_opt_view — Method
port_opt_view(
r::HighOrderMoment,
i,
args...
) -> HighOrderMoment{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, _A, _B, <:HighOrderMomentMeasureAlgorithm} where {__T_scale, __T_ub, __T_rke, _A, _B}
Return a view of HighOrderMoment r sliced to asset indices i.
Slices the expected returns mu for cluster-based optimisation.
Related
References
- [11]
- H. Markowitz. Modern portfolio theory. Journal of Finance 7, 77–91 (1952).
- [98]
- P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
- [99]
- H. Konno and H. Yamazaki. Mean-absolute deviation portfolio optimization model and its applications to Tokyo stock market. Management Science 37, 519–531 (1991).
- [100]
- D. Cajas. Portfolio Optimization of Even Moments using Power Cone Programming. Available at SSRN 6518258 (2026).