Variance Skew Kurtosis

PortfolioOptimisers.MaxRiskMeasureSettings — Type
struct MaxRiskMeasureSettings{__T_scale, __T_lb, __T_rke} <: JuMPRiskMeasureSettings

Weights a risk measure inside an aggregate, and bounds its risk expression from below.

This is the settings type of a quantity that the optimisation wants more of, so its bound is a floor and not a ceiling. It is the skewness floor $\bar{\mu}_3$ of Problem 13 of [219]. Skewness is its one holder, and a stated lb reaches the model only through VarianceSkewKurtosis, which builds the skewness term. Skewness is a NonOptimisationRiskMeasure, so no optimiser takes it alone.

Unlike the ub of RiskMeasureSettings, lb is not checked for non-negativity. A third moment can be negative, so a negative floor is valid.

Warning

The floor holds the relaxed third moment of the model, not the third moment of the returned weights. The method of set_risk_constraints! for VarianceSkewKurtosis states the gap under ## Relaxation.

Fields

  • scale: Weight of this risk measure in the aggregate risk expression formed from a vector of measures. It is a combination weight, so it is inert on a single measure: an optimiser given one measure drops it before the risk expression is built, and the value-level readers ignore it too. The upper bound in ub binds on the measure's own expression, before scale is applied.
  • lb: Lower bound(s) on the measure's own risk expression, for a quantity the optimisation maximises. A scalar bounds one model. A vector and a Frontier are sweep axes, one solve per entry. A negative value is meaningful, because the quantity it bounds may be negative.
  • rke: Whether to include the risk measure value in the JuMP risk expression.

Constructors

MaxRiskMeasureSettings(;    scale::Number = 1.0,    lb::Option{<:RkRtBounds} = nothing,    rke::Bool = true,) -> MaxRiskMeasureSettings

Keywords correspond to the struct's fields.

Validation

Examples

julia> MaxRiskMeasureSettings()MaxRiskMeasureSettings  scale ┼ Float64: 1.0     lb ┼ nothing    rke ┴ Bool: true

Related

References

  • [219] D. Cajas. Semidefinite Relaxation of Higher Portfolio Moments. Available at SSRN 5284483 (2025). Section 3, Problem 13.
source
PortfolioOptimisers.Skewness — Type
struct Skewness{__T_settings, __T_sk} <: NonOptimisationRiskMeasure

Measures the third central moment of the portfolio returns from the coskewness matrix sk.

The moment is $\boldsymbol{w}^\intercal \mathbf{M}_3 (\boldsymbol{w} \otimes \boldsymbol{w})$. It is not divided by the cube of the standard deviation, so it is not the skewness coefficient. A larger moment is better, so bigger_is_better returns true. The measure is a NonOptimisationRiskMeasure and carries a MaxRiskMeasureSettings, whose bound is the floor lb. So it answers bigger_is_better, bounds_risk_measure, no_bounds_risk_measure, no_risk_expr_risk_measure, no_bounds_no_risk_expr_risk_measure and unit_scale_risk_measure with methods of its own: the methods for a RiskMeasure build a RiskMeasureSettings, which has a ceiling ub and no floor.

No optimiser takes the measure alone. VarianceSkewKurtosis reads its sk and its settings, and builds the term $m_3(\boldsymbol{w})$ from sk. The functor reads the same matrix, so settings.lb and settings.scale act on the value of the functor, and expected_risk gives the value that the floor holds.

Info

The matrix states the moment, so the centre and the observation weights belong to the estimator that makes the matrix, such as sk = Coskewness(; w = w). ThirdCentralMoment computes the third moment from the returns, with observation weights and a Moment Target of its own. With a variance estimator in its ve, it divides the moment by the cube of the standard deviation and gives the standardised skewness. That measure reads one return series, so it is the score for an asset selection or a parameter search.

Mathematical definition

\[\begin{align} \mathrm{Skew}(\boldsymbol{w}) &= m_3(\boldsymbol{w})\,. \end{align}\]

Where:

  • $m_3(\boldsymbol{w}) = \boldsymbol{w}^\intercal \mathbf{M}_3 (\boldsymbol{w} \otimes \boldsymbol{w})$: Third central moment of the portfolio returns, with $\otimes$ the Kronecker product.
  • $\mathbf{M}_3$: Coskewness matrix of the risk measure, $N \times N^2$. It is the measure's own sk when the measure states one, and the prior's otherwise.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.

$m_3$ is the observation mean of the cube of the centred portfolio returns when $\mathbf{M}_3$ is the sample coskewness about the per-asset centres. That is Equation 1 of [219].

Fields

  • settings: Risk measure settings.
  • sk: Optional coskewness matrix assets × assets^2. Also admits a Deferred Quantity — a coskewness estimator or a prior estimator that computes the matrix against the optimisation's own prior, at factory time (see SkSlot and resolve_deferred_quantities). A coskewness estimator supplies mu as well, from its own me, so that the tensor and the centre it was taken about come out of one object. If nothing, the prior supplies it.

Constructors

Skewness(;    settings::MaxRiskMeasureSettings = MaxRiskMeasureSettings(),    sk::Option{<:SkSlot} = nothing) -> Skewness

Keywords correspond to the struct's fields.

Validation

  • If sk is a matrix: !isempty(sk) and size(sk, 1)^2 == size(sk, 2).
Info

sk also admits a CoskewnessEstimator or an AbstractPriorEstimator, which resolve_deferred_quantities resolves against the prior of the optimisation. The measure carries one deferrable slot, so it takes no pe.

Functor

(r::Skewness)(w::VecNum)

Computes $m_3(\boldsymbol{w})$ from the matrix r.sk, with portfolio_third_moment. The functor reads sk as it stands, so a measure whose sk is nothing or a Deferred Quantity needs factory with a HighOrderPrior result first.

Arguments

  • w: Portfolio weights vector assets × 1.

Examples

julia> Skewness()Skewness  settings ┼ MaxRiskMeasureSettings           │   scale ┼ Float64: 1.0           │      lb ┼ nothing           │     rke ┴ Bool: true        sk ┴ nothingjulia> X = [0.02 -0.01; -0.01 0.03; 0.03 -0.02; -0.04 0.01; 0.01 0.02];julia> w = [0.6, 0.4];julia> Skewness(; sk = first(coskewness(Coskewness(), X)))(w)-2.331648000000001e-6julia> ThirdCentralMoment()(w, X)-2.3316480000000003e-6

The sample coskewness about the mean of each asset gives the third moment of the portfolio returns about their mean, so the two values agree.

Related

References

  • [219] D. Cajas. Semidefinite Relaxation of Higher Portfolio Moments. Available at SSRN 5284483 (2025). Section 2, Equation 1.
source
PortfolioOptimisers.VarianceSkewKurtosis — Type
struct VarianceSkewKurtosis{__T_settings, __T_vr, __T_sk, __T_kt, __T_pe} <: RiskMeasure

Measures a weighted sum of the variance, the third central moment and the fourth central moment of the portfolio returns.

The third moment enters with a negative sign, because a larger skewness is better. Each term takes the scale of its child as its weight, and the bound of its child as its bound. The skewness bound is the floor sk.settings.lb, and the other two are ceilings. The terms are the raw moments: the third moment is not standardised, and the fourth moment is not square-rooted under any alg of kt. The model and the functor read the matrices of the children. To weight a term, name a Deferred Quantity that carries the weights, such as kt = Kurtosis(; kt = Cokurtosis(; w = w)).

set_risk_constraints! states the model. It is the semidefinite relaxation of Problems 12 to 14 of [219], and that work states that the relaxation is tight over a range of skewness values only. The ## Relaxation of the method states the gap of each term.

Warning

A skewness scale $s_{\mathrm{sk}}$ that is large against $s_{\sigma^2}$ and $s_{\kappa}$ loosens the relaxation. The optimum moves to relaxation blocks far from any product of the weights, and the value of the model stops tracking the value of the functor, without bound. A first-order solver can then stop at a point that breaks the weight bounds and the budget, and the solution check accepts that point as solved when check_sol = (; allow_almost = true). Raise $s_{\mathrm{sk}}$ in small steps, and compare the value of the model with the value of the functor at the returned weights. The default check_sol rejects an approximate solution, so a solver that stops short fails and returns no such point.

Mathematical definition

\[\begin{align} \mathcal{R}(\boldsymbol{w}) &= s_{\sigma^2}\, \boldsymbol{w}^\intercal \mathbf{\Sigma} \boldsymbol{w} - s_{\mathrm{sk}}\, m_3(\boldsymbol{w}) + s_{\kappa}\, m_4(\boldsymbol{w})\,. \end{align}\]

Where:

  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $\mathbf{\Sigma}$: Covariance matrix of the risk measure, $N \times N$. It is the measure's own matrix when the measure states one, and the prior's otherwise.
  • $m_3(\boldsymbol{w}) = \boldsymbol{w}^\intercal \mathbf{M}_3 (\boldsymbol{w} \otimes \boldsymbol{w})$: Third central moment of the portfolio returns, with $\otimes$ the Kronecker product.
  • $\mathbf{M}_3$: Coskewness matrix of the risk measure, $N \times N^2$. It is the measure's own sk when the measure states one, and the prior's otherwise.
  • $m_4(\boldsymbol{w}) = (\boldsymbol{w} \otimes \boldsymbol{w})^\intercal \mathbf{K} (\boldsymbol{w} \otimes \boldsymbol{w})$: Fourth central moment of the portfolio returns, with $\otimes$ the Kronecker product.
  • $\mathbf{K}$: Cokurtosis matrix of the risk measure, $N^2 \times N^2$. It is the measure's own kt when the measure states one, and the prior's otherwise.
  • $s_{\sigma^2}$, $s_{\mathrm{sk}}$, $s_{\kappa}$: The settings.scale of vr, sk and kt.

The three matrices are the moments of the returns, so $\mathcal{R}$ is Equation 2 of [219] for orders two and four and Equation 1 for order three. With the default prior, the covariance has the divisor $T - 1$ and the two higher moments have the divisor $T$.

Fields

  • settings: Risk measure settings.
  • vr: Variance risk measure component.
  • sk: Skewness risk measure component.
  • kt: Kurtosis risk measure component.
  • pe: Optional prior estimator that fills every prior-derived slot the measure leaves unstated, from a single fit. A stated slot wins. See resolve_deferred_quantities. It fits on the returns of the Prior Result that the measure receives, so it states no source of its own, and the constructor refuses a pe whose x_src is not nothing, see assert_returns_source.

Constructors

VarianceSkewKurtosis(;    settings::RiskMeasureSettings = RiskMeasureSettings(),    vr::Variance = Variance(),    sk::Skewness = Skewness(),    kt::Kurtosis = Kurtosis(),    pe::Option{<:AbstractPriorEstimator} = nothing) -> VarianceSkewKurtosis

Keywords correspond to the struct's fields.

Warning

The three children each state their quantities independently, so nothing makes sigma, sk and kt agree with each other. A caller who wants one consistent set names pe on the container alone and lets it fill all three from a single fit. A child that names its own quantity keeps it, and the pe fills only what is left.

Info

The constructor passes vr, sk and kt through no_risk_expr_risk_measure, so a child never registers a risk expression of its own. This is why the children show rke ┴ Bool: false below.

Propagated parameters

factory passes its arguments on to these @fprop fields:

  • vr: Recursively updated through factory.
  • sk: Recursively updated through factory.
  • kt: Recursively updated through factory.

View parameters

port_opt_view takes the view of these @vprop fields at the selected indices:

Functor

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

Computes $\mathcal{R}(\boldsymbol{w})$ from vr.sigma, sk.sk and kt.kt, so a measure needs factory with a HighOrderPrior result first, unless its children state the three matrices. X and fees take part in no term. The matrices fix the moments, and a central moment does not move when fees shifts every observation by the same constant.

Arguments

  • w: Portfolio weights vector assets × 1.
  • X::MatNum: Asset returns matrix ($T \times N$).
  • fees: Fees estimator or result.

Examples

julia> r = VarianceSkewKurtosis()VarianceSkewKurtosis  settings ┼ RiskMeasureSettings           │   scale ┼ Float64: 1.0           │      ub ┼ nothing           │     rke ┴ Bool: true        vr ┼ Variance           │    settings ┼ RiskMeasureSettings           │             │   scale ┼ Float64: 1.0           │             │      ub ┼ nothing           │             │     rke ┴ Bool: false           │       sigma ┼ nothing           │        chol ┼ nothing           │          rc ┼ nothing           │         alg ┼ SquaredSOCRiskExpr()           │    mtx_sqrt ┼ EigenFallbackSquareRoot()           │   ratio_alg ┼ SquareRootRatio()           │      corner ┴ nothing        sk ┼ Skewness           │   settings ┼ MaxRiskMeasureSettings           │            │   scale ┼ Float64: 1.0           │            │      lb ┼ nothing           │            │     rke ┴ Bool: false           │         sk ┴ nothing        kt ┼ Kurtosis           │   settings ┼ RiskMeasureSettings           │            │   scale ┼ Float64: 1.0           │            │      ub ┼ nothing           │            │     rke ┴ Bool: false           │         kt ┼ nothing           │          N ┼ nothing           │        alg ┼ SOCRiskExpr()           │   mtx_sqrt ┴ EigenFallbackSquareRoot()        pe ┴ nothing

Related

References

  • [219] D. Cajas. Semidefinite Relaxation of Higher Portfolio Moments. Available at SSRN 5284483 (2025). Section 2, Equations 1 and 2, and Section 3, Problems 12 to 14.
source
PortfolioOptimisers.factory — Method
factory(
    r::Skewness,
    pr::HighOrderPrior,
    args...;
    kwargs...
) -> Union{Skewness{MaxRiskMeasureSettings{__T_scale, __T_lb, __T_rke}, Nothing} where {__T_scale, __T_lb, __T_rke}, Skewness{MaxRiskMeasureSettings{__T_scale, __T_lb, __T_rke}, <:AbstractMatrix{var"#s166"}} where {__T_scale, __T_lb, __T_rke, var"#s166"<:Union{Number, AbstractJuMPScalar}}}

Create an instance of Skewness that holds its coskewness matrix, from the measure or from the HighOrderPrior result pr.

Algorithm

  1. Resolve a Deferred Quantity in sk with resolve_deferred_quantities, giving r.
  2. Select sk with nothing_scalar_array_selector. A measure that states a matrix keeps it, and a measure whose sk is nothing takes pr.sk.
  3. Build a new Skewness from sk and the settings of r.

Related

source
PortfolioOptimisers.factory — Method
factory(
    r::Skewness,
    pr::LowOrderPrior,
    args...;
    kwargs...
) -> Skewness

Resolve a Deferred Quantity in the sk slot of Skewness r against a LowOrderPrior result, and otherwise return r unchanged.

A LowOrderPrior holds no coskewness matrix, so the method has no matrix to take from pr. A coskewness estimator in sk needs only the returns of the result, so it resolves here too. The functor and the model need a matrix. A value-level entry point refuses a measure whose sk is nothing, and so does set_risk_constraints!.

Related

source
PortfolioOptimisers.port_opt_view — Method
port_opt_view(
    r::Skewness{<:Any, <:AbstractMatrix{<:Union{Number, AbstractJuMPScalar}}},
    i,
    args...
) -> Skewness

Return a view of Skewness r sliced to asset indices i, with a view of its coskewness matrix sk.

The view agrees with the coskewness that a refit on the assets i gives.

Algorithm

  1. Compute idx, the columns of sk that belong to the pairs of assets in i, with fourth_moment_index_generator.
  2. Take the view of sk at the rows i and the columns idx with nothing_scalar_array_view_odd_order.
  3. Build a new Skewness from the view and the settings of r.

Related

source
PortfolioOptimisers.no_risk_expr_risk_measure — Method
no_risk_expr_risk_measure(r::Skewness) -> Skewness

Return a copy of Skewness r with rke = false, so that the measure adds nothing to the risk of the objective.

The copy keeps lb and scale. The constructor of VarianceSkewKurtosis calls this method on its sk, so the composite registers the skewness term once, inside its own risk expression. The method exists because the method for a RiskMeasure builds a RiskMeasureSettings, which has no lb.

Related

source
PortfolioOptimisers.factory — Method
factory(
    r::VarianceSkewKurtosis,
    pr::AbstractPriorResult,
    args...;
    kwargs...
) -> VarianceSkewKurtosis{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, Variance{__T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner}, Skewness{__T_settings1, __T_sk}, Kurtosis{__T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}, Nothing} where {__T_scale, __T_ub, __T_rke, __T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner, __T_settings1, __T_sk, __T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}

Create an instance of VarianceSkewKurtosis by fanning pe out over its three children, then threading pr into each of them.

The container holds no quantity of its own, so @fprop alone would reach the children and leave pe in place, and the measure would then hold a pe that it never applied. This method resolves first, which is the same order that set_risk_constraints! uses.

Algorithm

  1. Resolve the container with resolve_deferred_quantities, giving r.
  2. Thread pr into each child with its own method of factory, giving vr, sk and kt.
  3. Build a new VarianceSkewKurtosis from the three children and the settings of r, with pe = nothing.

Related

source
PortfolioOptimisers.no_bounds_risk_measure — Method
no_bounds_risk_measure(
    r::VarianceSkewKurtosis
) -> Union{VarianceSkewKurtosis{RiskMeasureSettings{var"#s185", Nothing, Bool}, Variance{__T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner}, Skewness{__T_settings1, __T_sk}, Kurtosis{__T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}, Nothing} where {var"#s185"<:Number, __T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner, __T_settings1, __T_sk, __T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}, VarianceSkewKurtosis{RiskMeasureSettings{var"#s185", Nothing, Bool}, Variance{__T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner}, Skewness{__T_settings1, __T_sk}, Kurtosis{__T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}, <:AbstractPriorEstimator} where {var"#s185"<:Number, __T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner, __T_settings1, __T_sk, __T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}}

Return a copy of VarianceSkewKurtosis r without its bounds, the bound of the container and the bounds of its three children.

A child holds the bound of its own term, so the method for a RiskMeasure, which rebuilds only settings, would leave vr.settings.ub, sk.settings.lb and kt.settings.ub in the model. NearOptimalCentering solves its corner portfolios with this copy, so a child bound would constrain a corner that must be free. Every child and the container keep rke and scale, because the scale of a child weights its term.

Related

source
PortfolioOptimisers.no_bounds_no_risk_expr_risk_measure — Method
no_bounds_no_risk_expr_risk_measure(
    r::VarianceSkewKurtosis
) -> Union{VarianceSkewKurtosis{RiskMeasureSettings{var"#s185", Nothing, Bool}, Variance{__T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner}, Skewness{__T_settings1, __T_sk}, Kurtosis{__T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}, Nothing} where {var"#s185"<:Number, __T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner, __T_settings1, __T_sk, __T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}, VarianceSkewKurtosis{RiskMeasureSettings{var"#s185", Nothing, Bool}, Variance{__T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner}, Skewness{__T_settings1, __T_sk}, Kurtosis{__T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}, <:AbstractPriorEstimator} where {var"#s185"<:Number, __T_settings, __T_sigma, __T_chol, __T_rc, __T_alg, __T_mtx_sqrt, __T_ratio_alg, __T_corner, __T_settings1, __T_sk, __T_settings2, __T_kt, __T_N, __T_alg1, __T_mtx_sqrt1}}

Return a copy of VarianceSkewKurtosis r without its bounds and outside the risk of the objective.

The container takes rke = false and a unit scale, as the method for a RiskMeasure does. The children lose their bounds through no_bounds_risk_measure and keep their scales, because the scale of a child weights its term in the composite.

Related

source

References

[219]
D. Cajas. Semidefinite Relaxation of Higher Portfolio Moments. Available at SSRN 5284483 (2025).