Moment Risk Measures

PortfolioOptimisers.FirstLowerMoment — Type
struct FirstLowerMoment <: LowOrderMomentMeasureAlgorithm

Measures the mean shortfall of the net portfolio returns below the Moment Target.

It is the lower partial moment of order one. Equation 7.45 of [12] states the lower partial moment, and it names [191] as the source. No copy of that work was found. A number in mu is a minimum acceptable return, and mu = nothing gives the mean shortfall below the mean, the semi-deviation of order one.

Mathematical definition

\[\begin{align} R(\boldsymbol{w}) &= \mathbb{E}\left[\max(\tau - \hat{r}_t,\, 0)\right] = -\mathbb{E}\left[d_t^{-}\right]\,. \end{align}\]

Where:

  • $R(\boldsymbol{w})$: Portfolio risk.
  • $\mathbb{E}[z] = \sum_{t=1}^{T} w_t z_t / \sum_{t=1}^{T} w_t$: Observation mean of a series $z_t$, with $w_t = 1$ for every $t$ when the measure holds no observation weights.
  • $\hat{r}_t$: Net portfolio return at observation $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fees charged at $t$.
  • $\tau$: Moment Target, the value from which the measure measures the deviations. It is $\mathbb{E}[\hat{\boldsymbol{r}}]$ when mu is nothing, $\boldsymbol{\mu}^\intercal \boldsymbol{w} - \bar{F}(\boldsymbol{w})$ when mu is a vector $\boldsymbol{\mu}$, $\boldsymbol{v}^\intercal \boldsymbol{w} + s - \bar{F}(\boldsymbol{w})$ when mu is a VecScalar with fields $\boldsymbol{v}$ and $s$, and mu itself when it is a number.
  • $d_t^{-} = \min(d_t, 0)$: Lower part of the moment deviation of observation $t$.

Related

References

  • [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 7.2.2.2, Equation 7.45 with $q = 1$. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
  • [191] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
source
PortfolioOptimisers.MeanAbsoluteDeviation — Type
struct MeanAbsoluteDeviation <: LowOrderMomentMeasureAlgorithm

Measures the mean absolute deviation of the net portfolio returns from the Moment Target.

Equation 7.31 of [12] states it with the mean as the target, and it names [192] as the source. No copy of that work was found. The library adds the other targets of the mu slot.

Mathematical definition

\[\begin{align} R(\boldsymbol{w}) &= \mathbb{E}\left[\left\lvert d_t \right\rvert\right] = 2\, \mathbb{E}\left[\max(\tau - \hat{r}_t,\, 0)\right] + \mathbb{E}\left[\hat{r}_t\right] - \tau\,. \end{align}\]

Where:

  • $R(\boldsymbol{w})$: Portfolio risk.
  • $\mathbb{E}[z] = \sum_{t=1}^{T} w_t z_t / \sum_{t=1}^{T} w_t$: Observation mean of a series $z_t$, with $w_t = 1$ for every $t$ when the measure holds no observation weights.
  • $d_t = \hat{r}_t - \tau$: Moment deviation of observation $t$.
  • $\hat{r}_t$: Net portfolio return at observation $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fees charged at $t$.
  • $\tau$: Moment Target, the value from which the measure measures the deviations. It is $\mathbb{E}[\hat{\boldsymbol{r}}]$ when mu is nothing, $\boldsymbol{\mu}^\intercal \boldsymbol{w} - \bar{F}(\boldsymbol{w})$ when mu is a vector $\boldsymbol{\mu}$, $\boldsymbol{v}^\intercal \boldsymbol{w} + s - \bar{F}(\boldsymbol{w})$ when mu is a VecScalar with fields $\boldsymbol{v}$ and $s$, and mu itself when it is a number.

The second form follows from $\lvert d \rvert = 2 \max(-d, 0) + d$. When $\tau$ is the observation mean of the net returns, the last two terms cancel, and the measure is twice the FirstLowerMoment of the same data. Against any other target, the measure differs from twice the first lower moment by $\mathbb{E}[\hat{r}_t] - \tau$.

Related

References

  • [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 7.2.1.3, Equation 7.31. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
  • [192] H. Konno and H. Yamazaki. Mean-absolute deviation portfolio optimization model and its applications to Tokyo stock market. Management Science 37, 519–531 (1991).
source
PortfolioOptimisers.SecondMoment — Type
struct SecondMoment{__T_ve, __T_alg1, __T_alg2} <: LowOrderMomentMeasureAlgorithm

Measures the second moment of the net portfolio returns about the Moment Target, or its square root.

alg1 selects the deviations. FullMoment reads all of them, and SemiMoment reads the deviations below the target alone. alg2 selects the units. SOCRiskExpr reports the square root, a standard deviation, and the three other formulations report the second moment itself.

With mu = nothing the measure is the variance or the semi-variance of the net portfolio returns. Against a stated target it is the second moment about that target, not a variance. ve reads the deviations at a mean of zero. So it supplies only its divisor and its observation weights, and its me has no effect. Page 81 of [32] states the variance. Pages 188 and 189 of [193] state the semi-variance about a target $b$ and about the mean $E$, with the divisor $T$.

Mathematical definition

\[\begin{align} R(\boldsymbol{w}) &= f \sum_{t=1}^{T} w_t\, d_t^{2}\,, \\ R(\boldsymbol{w}) &= f \sum_{t=1}^{T} w_t \left(d_t^{-}\right)^{2}\,. \end{align}\]

The first line is the full moment and the second line is the semi moment. SOCRiskExpr reports $\sqrt{R(\boldsymbol{w})}$.

Where:

  • $R(\boldsymbol{w})$: Portfolio risk.
  • $f$: Variance divisor of the estimator ve, StatsBase.varcorrection of $T$, or of the observation weights when the measure holds them, at ve.corrected. With no observation weights it is $1/(T-1)$ when ve.corrected is true and $1/T$ otherwise.
  • $w_{t}$: Observation weight of observation $t$. It is $1$ for every $t$ when the measure holds no observation weights.
  • $d_t = \hat{r}_t - \tau$: Moment deviation of observation $t$.
  • $d_t^{-} = \min(d_t, 0)$: Lower part of the moment deviation of observation $t$.
  • $T$: Number of observations.

The default ve sets corrected = true, so the default divisor is $1/(T-1)$. Set ve = SimpleVariance(; me = nothing, corrected = false) for the divisor $1/T$ of [193].

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(),) -> SecondMoment

Keywords correspond to the struct's fields.

Propagated parameters

factory passes its arguments on to these @fprop fields:

  • ve: Recursively updated through factory.

Examples

julia> SecondMoment()SecondMoment    ve ┼ SimpleVariance       │          me ┼ nothing       │           w ┼ nothing       │   corrected ┴ Bool: true  alg1 ┼ FullMoment()  alg2 ┴ SquaredSOCRiskExpr()

Related

References

  • [32] H. Markowitz. Portfolio selection. The Journal of Finance 7, 77–91 (1952). Page 81.
  • [193] H. M. Markowitz. Portfolio Selection: Efficient Diversification of Investments (John Wiley & Sons, New York, 1959). Chapter IX, pages 188 and 189.
source
PortfolioOptimisers.EvenMoment — Type
struct EvenMoment{__T_p, __T_ddof, __T_alg} <: LowOrderMomentMeasureAlgorithm

Measures the $p$-th root of the even moment of order $2p$ of the net portfolio returns about the Moment Target.

The order is $2p$, and p is an integer of at least $2$, so the order is always even and at least $4$. An odd order cannot be stated. alg selects all the deviations, FullMoment, or the deviations below the target alone, SemiMoment. The $p$-th root is homogeneous of degree two in the weights, the degree of a variance. Equations 3 and 4 of [194] state the full and the lower moment about the mean, with the divisor $T$, and Formulations 5 and 8 state their power cone programmes. The divisor $T_d$, the observation weights and the other targets are the library's own.

Mathematical definition

\[\begin{align} R(\boldsymbol{w}) &= \left(\frac{1}{T_d} \sum_{t=1}^{T} w_t\, d_t^{2p}\right)^{1/p}\,, \\ R(\boldsymbol{w}) &= \left(\frac{1}{T_d} \sum_{t=1}^{T} w_t \left(d_t^{-}\right)^{2p}\right)^{1/p}\,, \\ T_d &= \frac{T - \mathrm{ddof}}{T} \sum_{t=1}^{T} w_t\,. \end{align}\]

The first line is the full moment and the second line is the semi moment.

Where:

  • $R(\boldsymbol{w})$: Portfolio risk.
  • $p$: Order parameter p. The moment order is $2p$.
  • $T_d$: Effective sample size. It is $T - \mathrm{ddof}$ when the measure holds no observation weights.
  • $\mathrm{ddof}$: Degrees of freedom ddof that the divisor subtracts.
  • $w_{t}$: Observation weight of observation $t$. It is $1$ for every $t$ when the measure holds no observation weights.
  • $d_t = \hat{r}_t - \tau$: Moment deviation of observation $t$.
  • $d_t^{-} = \min(d_t, 0)$: Lower part of the moment deviation of observation $t$.
  • $T$: Number of observations.

$T_d$ is zero at $\mathrm{ddof} = T$, and the value is then Inf. A larger ddof makes $T_d$ negative, and the root raises a DomainError.

Fields

  • p: Power or order parameter.
  • ddof: Degrees-of-freedom correction, an integer that the library subtracts from the number of observations itself.
  • alg: Moment algorithm.

Constructors

EvenMoment(;    p::Integer = 2,    ddof::Integer = 0,    alg::AbstractMomentAlgorithm = FullMoment(),) -> EvenMoment

Keywords correspond to the struct's fields.

Validation

  • p >= 2, else a DomainError.
  • ddof >= 0, else a DomainError.

Examples

julia> EvenMoment()EvenMoment     p ┼ Int64: 2  ddof ┼ Int64: 0   alg ┴ FullMoment()

Related

References

  • [194] D. Cajas. Portfolio Optimization of Even Moments using Power Cone Programming. Available at SSRN 6518258 (2026). Equations 3 and 4, Formulations 5 and 8.
source
PortfolioOptimisers.LowOrderMoment — Type
struct LowOrderMoment{__T_settings, __T_w, __T_mu, __T_alg} <: RiskMeasure

Measures a low-order moment of the deviations of the net portfolio returns from the Moment Target.

alg selects the moment: FirstLowerMoment, the default, MeanAbsoluteDeviation, SecondMoment or EvenMoment. Each states its closed form. mu selects the target, and the target alone. A stated target shifts every deviation by one constant, and alg reduces the shifted deviations with the same formula. The measure is an optimisation risk measure, and set_risk_constraints! builds its model. Pages 188 and 189 of [193] measure a downside deviation from a target $b$ or from the mean $E$.

Mathematical definition

\[\begin{align} d_t &= \hat{r}_t - \tau\,,\quad t = 1, \ldots, T\,, \\ R(\boldsymbol{w}) &= \rho\left(d_1, \ldots, d_T\right)\,. \end{align}\]

Where:

  • $d_t = \hat{r}_t - \tau$: Moment deviation of observation $t$.
  • $\hat{r}_t$: Net portfolio return at observation $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fees charged at $t$.
  • $\tau$: Moment Target, the value from which the measure measures the deviations. It is $\mathbb{E}[\hat{\boldsymbol{r}}]$ when mu is nothing, $\boldsymbol{\mu}^\intercal \boldsymbol{w} - \bar{F}(\boldsymbol{w})$ when mu is a vector $\boldsymbol{\mu}$, $\boldsymbol{v}^\intercal \boldsymbol{w} + s - \bar{F}(\boldsymbol{w})$ when mu is a VecScalar with fields $\boldsymbol{v}$ and $s$, and mu itself when it is a number.
  • $\bar{F}(\boldsymbol{w})$: Mean fee per period of the portfolio, zero when fees is nothing. See moment_target_fees.
  • $\mathbb{E}[z] = \sum_{t=1}^{T} w_t z_t / \sum_{t=1}^{T} w_t$: Observation mean of a series $z_t$, with $w_t = 1$ for every $t$ when the measure holds no observation weights.
  • $T$: Number of observations.
  • $R(\boldsymbol{w})$: Portfolio risk.
  • $\rho$: The reduction that alg states.

A number in mu is a threshold on the net series, so it takes no fee. A per-asset target is net of the mean fee per period, so a fee that every period pays in full cancels from every deviation.

Fields

  • settings: Risk measure settings.
  • w: Optional observation weights vector observations × 1, or a concrete subtype of DynamicAbstractWeights. If nothing, the computation is unweighted.
  • mu: Optional centre the moment is taken about, a scalar or a vector assets × 1. Also admits a Deferred Quantity — an expected returns estimator or a prior estimator that computes the centre against the optimisation's own prior, at factory time (see MuSlot and resolve_deferred_quantities). If nothing, the prior supplies it.
  • alg: Moment algorithm.

Constructors

LowOrderMoment(;    settings::RiskMeasureSettings = RiskMeasureSettings(),    w::Option{<:ObsWeights} = nothing,    mu::Option{<:MuSlot} = nothing,    alg::LowOrderMomentMeasureAlgorithm = FirstLowerMoment(),) -> LowOrderMoment

Keywords correspond to the struct's fields. The keyword constructor passes a w that is not nothing to alg with factory, so a variance estimator inside alg reads the same weights as the measure.

Validation

Warning

A stated mu is fixed. It crosses a Cross-Validation fold or a subset view as the answer for the whole universe, so it does not follow the refit that the optimisation runs on. To make the target follow the fit, name a Deferred Quantity in mu, or leave the slot nothing and let the prior supply it.

Functor

(r::LowOrderMoment)(w::VecNum, X::MatNum, fees::Option{<:Fees} = nothing)(r::LowOrderMoment)(x::VecNum)

Computes the risk of the portfolio w on the returns X net of fees, or the risk of the net portfolio returns x. A DynamicAbstractWeights in w first resolves against the data with resolve_observation_weights. calc_deviations_vec then gives the deviations from the Moment Target, and moment_risk reduces them. The second form reads x as a net series and charges no fee. It needs a target that does not read the asset weights, which supports_precomputed_returns reports. A mu that is nothing reads the observation mean of the series. So a measure that factory did not build against a prior measures the deviations from the mean of the data, not from the expected returns of a prior.

Arguments

  • w::VecNum: Asset weights.
  • X::MatNum: Returns matrix observations × assets.
  • fees::Option{<:Fees}: Fees that the net returns pay, or nothing.
  • x::VecNum: Net portfolio returns observations × 1.

Examples

julia> LowOrderMoment()LowOrderMoment  settings ┼ RiskMeasureSettings           │   scale ┼ Float64: 1.0           │      ub ┼ nothing           │     rke ┴ Bool: true         w ┼ nothing        mu ┼ nothing       alg ┴ FirstLowerMoment()julia> x = [0.02, -0.01, 0.03, -0.04, 0.01];julia> LowOrderMoment(; alg = FirstLowerMoment())(x)0.0108julia> LowOrderMoment(; alg = MeanAbsoluteDeviation())(x)0.0216julia> LowOrderMoment(; mu = 0.0, alg = MeanAbsoluteDeviation())(x)0.022

The mean of x is 0.002. Against the mean, the mean absolute deviation is twice the first lower moment. Against the target 0.0, it is 0.0216 + 0.002 - 0.0.

Related

References

  • [193] H. M. Markowitz. Portfolio Selection: Efficient Diversification of Investments (John Wiley & Sons, New York, 1959). Chapter IX, pages 188 and 189.
source
PortfolioOptimisers.ThirdLowerMoment — Type
struct ThirdLowerMoment <: HighOrderMomentMeasureAlgorithm

Measures the negated third moment of the deviations below the Moment Target.

The cube of a deviation below the target is negative, so the measure negates the mean, and a larger value is more downside asymmetry. It is the lower partial moment of order three. Equation 7.45 of [12] states the lower partial moment, and it names [191] as the source. No copy of that work was found.

Mathematical definition

\[\begin{align} R(\boldsymbol{w}) &= -\mathbb{E}\left[\left(d_t^{-}\right)^{3}\right] = \mathbb{E}\left[\max(\tau - \hat{r}_t,\, 0)^{3}\right]\,. \end{align}\]

Where:

  • $R(\boldsymbol{w})$: Portfolio risk.
  • $\mathbb{E}[z] = \sum_{t=1}^{T} w_t z_t / \sum_{t=1}^{T} w_t$: Observation mean of a series $z_t$, with $w_t = 1$ for every $t$ when the measure holds no observation weights.
  • $d_t^{-} = \min(d_t, 0)$: Lower part of the moment deviation of observation $t$.
  • $\hat{r}_t$: Net portfolio return at observation $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fees charged at $t$.
  • $\tau$: Moment Target, the value from which the measure measures the deviations. It is $\mathbb{E}[\hat{\boldsymbol{r}}]$ when mu is nothing, $\boldsymbol{\mu}^\intercal \boldsymbol{w} - \bar{F}(\boldsymbol{w})$ when mu is a vector $\boldsymbol{\mu}$, $\boldsymbol{v}^\intercal \boldsymbol{w} + s - \bar{F}(\boldsymbol{w})$ when mu is a VecScalar with fields $\boldsymbol{v}$ and $s$, and mu itself when it is a number.

Related

References

  • [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 7.2.2.2, Equation 7.45 with $q = 3$. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
  • [191] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
source
PortfolioOptimisers.FourthMoment — Type
struct FourthMoment{__T_alg} <: HighOrderMomentMeasureAlgorithm

Measures the fourth moment of the net portfolio returns about the Moment Target.

alg selects all the deviations, FullMoment, or the deviations below the target alone, SemiMoment. The value has no root and no division by a variance, so it is in the units of a return to the fourth power. The semi moment is the lower partial moment of order four. Equation 7.45 of [12] states the lower partial moment, and it names [191] as the source. No copy of that work was found.

Mathematical definition

\[\begin{align} R(\boldsymbol{w}) &= \mathbb{E}\left[d_t^{4}\right]\,, \\ R(\boldsymbol{w}) &= \mathbb{E}\left[\left(d_t^{-}\right)^{4}\right]\,. \end{align}\]

The first line is the full moment and the second line is the semi moment.

Where:

  • $R(\boldsymbol{w})$: Portfolio risk.
  • $\mathbb{E}[z] = \sum_{t=1}^{T} w_t z_t / \sum_{t=1}^{T} w_t$: Observation mean of a series $z_t$, with $w_t = 1$ for every $t$ when the measure holds no observation weights.
  • $d_t = \hat{r}_t - \tau$: Moment deviation of observation $t$.
  • $d_t^{-} = \min(d_t, 0)$: Lower part of the moment deviation of observation $t$.

Fields

  • alg: Moment algorithm.

Constructors

FourthMoment(;    alg::AbstractMomentAlgorithm = FullMoment(),) -> FourthMoment

Keywords correspond to the struct's fields.

Examples

julia> FourthMoment()FourthMoment  alg ┴ FullMoment()

Related

References

  • [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 7.2.2.2, Equation 7.45 with $q = 4$. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
  • [191] P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
source
PortfolioOptimisers.HighOrderMoment — Type
struct HighOrderMoment{__T_settings, __T_w, __T_mu, __T_alg, __T_ve} <: HierarchicalRiskMeasure

Measures a moment of order three or four of the deviations of the net portfolio returns from the Moment Target, or that moment divided by a power of the second moment.

alg selects the moment of order $n$: ThirdLowerMoment, the default, or FourthMoment. Each states its closed form. mu selects the target, as it does for LowOrderMoment. When ve is nothing, the measure reports the moment as it is. When ve is a variance estimator, the measure divides the moment by the power $n/2$ of the second moment of the same deviations, so the value has no units. The measure is a hierarchical risk measure. The hierarchical optimisers and the value level read it, and the library builds no JuMP model for it.

A larger value is always more risk. The odd moment is the negated mean of negative cubes, and the even moments are non-negative. The second moment is positive, so the standardised value has the sign of the moment.

Mathematical definition

\[\begin{align} d_t &= \hat{r}_t - \tau\,,\quad t = 1, \ldots, T\,, \\ R_{n}(\boldsymbol{w}) &= \rho\left(d_1, \ldots, d_T\right)\,, \\ R(\boldsymbol{w}) &= \frac{R_{n}(\boldsymbol{w})}{\left(\sigma^{2}\right)^{n/2}}\,, \\ \sigma^{2} &= f \sum_{t=1}^{T} w_t\, \delta_t^{2}\,. \end{align}\]

When ve is nothing, the measure reports $R_{n}(\boldsymbol{w})$. The third and the fourth lines apply when ve is a variance estimator.

Where:

  • $d_t = \hat{r}_t - \tau$: Moment deviation of observation $t$.
  • $\hat{r}_t$: Net portfolio return at observation $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fees charged at $t$.
  • $\tau$: Moment Target, the value from which the measure measures the deviations. It is $\mathbb{E}[\hat{\boldsymbol{r}}]$ when mu is nothing, $\boldsymbol{\mu}^\intercal \boldsymbol{w} - \bar{F}(\boldsymbol{w})$ when mu is a vector $\boldsymbol{\mu}$, $\boldsymbol{v}^\intercal \boldsymbol{w} + s - \bar{F}(\boldsymbol{w})$ when mu is a VecScalar with fields $\boldsymbol{v}$ and $s$, and mu itself when it is a number.
  • $\bar{F}(\boldsymbol{w})$: Mean fee per period of the portfolio, zero when fees is nothing. See moment_target_fees.
  • $\mathbb{E}[z] = \sum_{t=1}^{T} w_t z_t / \sum_{t=1}^{T} w_t$: Observation mean of a series $z_t$, with $w_t = 1$ for every $t$ when the measure holds no observation weights.
  • $T$: Number of observations.
  • $R(\boldsymbol{w})$: Portfolio risk.
  • $R_{n}(\boldsymbol{w})$: The value of alg, the moment of order $n$.
  • $\rho$: The reduction that alg states.
  • $n$: Order of the moment, $3$ or $4$.
  • $\sigma^{2}$: Second moment of the deviations that alg reads.
  • $\delta_t$: The deviation that alg reads, $d_t^{-}$ for a lower moment and $d_t$ for a full moment.
  • $f$: Variance divisor of the estimator ve, StatsBase.varcorrection of $T$, or of the observation weights when the measure holds them, at ve.corrected. With no observation weights it is $1/(T-1)$ when ve.corrected is true and $1/T$ otherwise.
  • $w_{t}$: Observation weight of observation $t$. It is $1$ for every $t$ when the measure holds no observation weights.
  • $d_t^{-} = \min(d_t, 0)$: Lower part of the moment deviation of observation $t$.

The numerator is an observation mean, and the denominator takes the divisor of ve. SimpleVariance sets corrected = true by default, so its denominator divides by $T - 1$ and the numerator by $T$. Set ve = SimpleVariance(; me = nothing, corrected = false) for the ratio of two observation means.

Fields

  • settings: Risk measure settings.
  • w: Optional observation weights vector observations × 1, or a concrete subtype of DynamicAbstractWeights. If nothing, the computation is unweighted.
  • mu: Optional centre the moment is taken about, a scalar or a vector assets × 1. Also admits a Deferred Quantity — an expected returns estimator or a prior estimator that computes the centre against the optimisation's own prior, at factory time (see MuSlot and resolve_deferred_quantities). If nothing, the prior supplies it.
  • alg: Moment algorithm.
  • ve: Variance estimator of the second moment that divides the moment, or nothing for the moment as it is. The estimator reads the same deviations as alg: the deviations below the Moment Target for a lower moment, ThirdLowerMoment or a FourthMoment of a SemiMoment, and all the deviations for a full moment. It reads them about zero, so its own me does not enter.

Constructors

HighOrderMoment(;    settings::RiskMeasureSettings = RiskMeasureSettings(),    w::Option{<:ObsWeights} = nothing,    mu::Option{<:MuSlot} = nothing,    alg::HighOrderMomentMeasureAlgorithm = ThirdLowerMoment(),    ve::Option{<:AbstractVarianceEstimator} = nothing,) -> HighOrderMoment

Keywords correspond to the struct's fields. A w that is not nothing is passed to ve with factory, so the variance estimator reads the same weights as the measure.

Validation

Warning

A stated mu is fixed. It crosses a Cross-Validation fold or a subset view as the answer for the whole universe, so it does not follow the refit that the optimisation runs on. To make the target follow the fit, name a Deferred Quantity in mu, or leave the slot nothing and let the prior supply it.

Functor

(r::HighOrderMoment)(w::VecNum, X::MatNum, fees::Option{<:Fees} = nothing)(r::HighOrderMoment)(x::VecNum)

Computes the risk of the portfolio w on the returns X net of fees, or the risk of the net portfolio returns x, as the functor of LowOrderMoment does. A DynamicAbstractWeights in w first resolves against the data with resolve_observation_weights. calc_deviations_vec then gives the deviations from the Moment Target, and moment_risk reduces them. The second form needs a target that does not read the asset weights, which supports_precomputed_returns reports.

Arguments

  • w::VecNum: Asset weights.
  • X::MatNum: Returns matrix observations × assets.
  • fees::Option{<:Fees}: Fees that the net returns pay, or nothing.
  • x::VecNum: Net portfolio returns observations × 1.

Examples

julia> HighOrderMoment()HighOrderMoment  settings ┼ RiskMeasureSettings           │   scale ┼ Float64: 1.0           │      ub ┼ nothing           │     rke ┴ Bool: true         w ┼ nothing        mu ┼ nothing       alg ┼ ThirdLowerMoment()        ve ┴ nothingjulia> x = [0.02, -0.01, 0.03, -0.04, 0.01];julia> HighOrderMoment(; ve = SimpleVariance(; me = nothing))(x)1.4555036361053537julia> HighOrderMoment(; ve = SimpleVariance(; me = nothing, corrected = false))(x)2.034128169893555

The two values differ in the divisor of the lower second moment alone, $T - 1$ under corrected = true, the default of SimpleVariance, and $T$ with corrected = false.

Related

source
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 a LowOrderMoment whose observation weights and mu come from the measure, or from the prior result pr where the measure states none.

A measure whose mu is nothing takes pr.mu, so after this method its Moment Target is the expected portfolio return of the prior, net of the mean fee per period. Before it, the target is the mean of the data that the functor reads. The two agree when pr.mu is the observation mean of pr.X under the same weights.

Algorithm

  1. Resolve a Deferred Quantity in mu with resolve_deferred_quantities, giving r.
  2. Select w, the weights of r or else pr.w, with nothing_scalar_array_selector.
  3. Select mu, the target of r or else pr.mu, with nothing_scalar_array_selector.
  4. Pass w to r.alg with factory, giving alg.
  5. Build a new LowOrderMoment from r.settings, w, mu and alg.

Related

source
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 LowOrderMoment restricted to the assets i.

The method slices a per-asset mu to the assets i with nothing_scalar_array_view. A number and nothing pass through unchanged, and so does a Deferred Quantity, which resolves on the subset. w weighs observations, not assets, so it passes through unchanged, and so do settings and alg.

Related

source
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 a HighOrderMoment whose observation weights and mu come from the measure, or from the prior result pr where the measure states none.

A measure whose mu is nothing takes pr.mu, so after this method its Moment Target is the expected portfolio return of the prior, net of the mean fee per period.

Algorithm

  1. Resolve a Deferred Quantity in mu with resolve_deferred_quantities, giving r.
  2. Select w, the weights of r or else pr.w, with nothing_scalar_array_selector.
  3. Select mu, the target of r or else pr.mu, with nothing_scalar_array_selector.
  4. Rebuild r with w and mu, with rebuild_struct. It calls the keyword constructor, which passes w to ve with factory. r.settings, r.alg and r.ve do not change.

Related

source
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 HighOrderMoment restricted to the assets i.

The method slices a per-asset mu to the assets i with nothing_scalar_array_view. A number and nothing pass through unchanged, and so does a Deferred Quantity, which resolves on the subset. w weighs observations, not assets, so it passes through unchanged, and so do settings, alg and ve.

Related

source
PortfolioOptimisers.supports_precomputed_returns — Method
supports_precomputed_returns(
    r::Union{LowOrderMoment{T1, T2, T3, T4}, HighOrderMoment{T1, T2, T3, T4}} where {T1, T2, T3, T4}
) -> Any

Return whether the functor r(x) of a LoHiOrderMoment can evaluate the net portfolio returns x alone.

The answer is weight_independent_target of r.mu. It is true when mu is nothing or a number, because such a target does not read the asset weights. It is false for a vector, a VecScalar and an unresolved Deferred Quantity.

Related

source
PortfolioOptimisers.obs_weights_view — Method
obs_weights_view(r::LowOrderMoment, i) -> LowOrderMoment
obs_weights_view(r::HighOrderMoment, i) -> HighOrderMoment

Return the measure with its observation weights, and the weights of its children, cut to the observations i.

The two measures are not @propagatable, so they need these methods of obs_weights_view. A cut of the observations of a fit, such as the drop of a Shared Series gap, then cuts the weights of the measure too, see shared_series_estimator.

Algorithm

  1. Index r.w with obs_weights_index.
  2. Cut r.alg with obs_weights_view, and r.ve for a HighOrderMoment.
  3. Rebuild the measure with rebuild_struct, which calls its keyword constructor. settings and mu keep their values.

Arguments

  • r: The risk measure.
  • i: The observations to keep: a mask of the full sample, or their positions.

Validation

Returns

  • r: The measure at the kept observations.

Related

source

References

[12]
D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
[32]
H. Markowitz. Portfolio Selection. The Journal of Finance 7, 77–91 (1952).
[191]
P. C. Fishburn. Mean-risk analysis with risk associated with below-target returns. The American Economic Review 67, 116–126 (1977).
[192]
H. Konno and H. Yamazaki. Mean-absolute deviation portfolio optimization model and its applications to Tokyo stock market. Management Science 37, 519–531 (1991).
[193]
H. M. Markowitz. Portfolio Selection: Efficient Diversification of Investments. No. 16 of Cowles Foundation Monograph (John Wiley & Sons, New York, 1959).
[194]
D. Cajas. Portfolio Optimization of Even Moments using Power Cone Programming. Available at SSRN 6518258 (2026).