Variance Skew Kurtosis
PortfolioOptimisers.MaxRiskMeasureSettings — Type
struct MaxRiskMeasureSettings{__T_scale, __T_lb, __T_rke} <: JuMPRiskMeasureSettingsWeights 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.
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 inubbinds on the measure's own expression, beforescaleis 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 aFrontierare 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 theJuMPrisk expression.
Constructors
MaxRiskMeasureSettings(; scale::Number = 1.0, lb::Option{<:RkRtBounds} = nothing, rke::Bool = true,) -> MaxRiskMeasureSettingsKeywords correspond to the struct's fields.
Validation
isfinite(scale).lbis validated withassert_nonempty_finite_val.
Examples
julia> MaxRiskMeasureSettings()MaxRiskMeasureSettings scale ┼ Float64: 1.0 lb ┼ nothing rke ┴ Bool: trueRelated
JuMPRiskMeasureSettingsRiskMeasureSettingsSkewnessVarianceSkewKurtosisFrontierset_variance_risk_bounds_and_expression!
References
- [219] D. Cajas. Semidefinite Relaxation of Higher Portfolio Moments. Available at SSRN 5284483 (2025). Section 3, Problem 13.
PortfolioOptimisers.Skewness — Type
struct Skewness{__T_settings, __T_sk} <: NonOptimisationRiskMeasureMeasures 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.
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
skwhen 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 matrixassets × assets^2. Also admits a Deferred Quantity — a coskewness estimator or a prior estimator that computes the matrix against the optimisation's own prior, atfactorytime (seeSkSlotandresolve_deferred_quantities). A coskewness estimator suppliesmuas well, from its ownme, so that the tensor and the centre it was taken about come out of one object. Ifnothing, the prior supplies it.
Constructors
Skewness(; settings::MaxRiskMeasureSettings = MaxRiskMeasureSettings(), sk::Option{<:SkSlot} = nothing) -> SkewnessKeywords correspond to the struct's fields.
Validation
- If
skis a matrix:!isempty(sk)andsize(sk, 1)^2 == size(sk, 2).
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 vectorassets × 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-6The 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
NonOptimisationRiskMeasureMaxRiskMeasureSettingsThirdCentralMoment: the third moment of the returns, standardised or not.bigger_is_betterresolve_deferred_quantitiesportfolio_third_momentVarianceSkewKurtosisNegativeSkewness: a convex part of the third moment that an optimiser can minimise alone.
References
- [219] D. Cajas. Semidefinite Relaxation of Higher Portfolio Moments. Available at SSRN 5284483 (2025). Section 2, Equation 1.
PortfolioOptimisers.VarianceSkewKurtosis — Type
struct VarianceSkewKurtosis{__T_settings, __T_vr, __T_sk, __T_kt, __T_pe} <: RiskMeasureMeasures 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.
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
skwhen 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
ktwhen the measure states one, and the prior's otherwise. - $s_{\sigma^2}$, $s_{\mathrm{sk}}$, $s_{\kappa}$: The
settings.scaleofvr,skandkt.
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. Seeresolve_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 apewhosex_srcis notnothing, seeassert_returns_source.
Constructors
VarianceSkewKurtosis(; settings::RiskMeasureSettings = RiskMeasureSettings(), vr::Variance = Variance(), sk::Skewness = Skewness(), kt::Kurtosis = Kurtosis(), pe::Option{<:AbstractPriorEstimator} = nothing) -> VarianceSkewKurtosisKeywords correspond to the struct's fields.
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.
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 throughfactory.sk: Recursively updated throughfactory.kt: Recursively updated throughfactory.
View parameters
port_opt_view takes the view of these @vprop fields at the selected indices:
vr: Recursively viewed throughport_opt_view.sk: Recursively viewed throughport_opt_view.kt: Recursively viewed throughport_opt_view.
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 vectorassets × 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 ┴ nothingRelated
RiskMeasureRiskMeasureSettingsVarianceSkewnessKurtosisfactoryport_opt_viewset_risk_constraints!: states the model and its relaxation.no_bounds_risk_measure: removes the bounds of the container and of the three children.
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.
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
- Resolve a Deferred Quantity in
skwithresolve_deferred_quantities, givingr. - Select
skwithnothing_scalar_array_selector. A measure that states a matrix keeps it, and a measure whoseskisnothingtakespr.sk. - Build a new
Skewnessfromskand thesettingsofr.
Related
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
PortfolioOptimisers.port_opt_view — Method
port_opt_view(r::Skewness, i, args...) -> Skewness
Return Skewness r unchanged, because its sk holds no matrix to slice.
sk is nothing, or it holds a Deferred Quantity, which crosses the view unresolved and then fits on the subset.
Related
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
- Compute
idx, the columns ofskthat belong to the pairs of assets ini, withfourth_moment_index_generator. - Take the view of
skat the rowsiand the columnsidxwithnothing_scalar_array_view_odd_order. - Build a new
Skewnessfrom the view and thesettingsofr.
Related
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
PortfolioOptimisers.no_bounds_no_risk_expr_risk_measure — Method
no_bounds_no_risk_expr_risk_measure(r::Skewness) -> Skewness
Return a copy of Skewness r with rke = false, lb = nothing and a unit scale.
This is the copy that a measure takes when it only measures a distance, as the method for a RiskMeasure does. The method exists because that method builds a RiskMeasureSettings, which has no lb.
Related
PortfolioOptimisers.bounds_risk_measure — Method
bounds_risk_measure(r::Skewness, ub::Number) -> Skewness
Return a copy of Skewness r with the floor lb set to ub.
bounds_risk_measure passes the bound of every measure as ub. The bound of a MaxRiskMeasureSettings is a floor, so this method writes it to lb, and keeps rke and scale.
Related
PortfolioOptimisers.no_bounds_risk_measure — Method
no_bounds_risk_measure(r::Skewness) -> Skewness
Return a copy of Skewness r with lb = nothing, and keep rke and scale.
no_bounds_risk_measure of a VarianceSkewKurtosis calls this method on its sk, so that the floor of the skewness term leaves the model with the other bounds. The method exists because the method for a RiskMeasure builds a RiskMeasureSettings, which has no lb.
Related
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
- Resolve the container with
resolve_deferred_quantities, givingr. - Thread
printo each child with its own method offactory, givingvr,skandkt. - Build a new
VarianceSkewKurtosisfrom the three children and thesettingsofr, withpe = nothing.
Related
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
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
PortfolioOptimisers.bigger_is_better — Method
bigger_is_better(_::Skewness) -> Bool
Return true, because a larger third moment is better.
The generic method for an AbstractBaseRiskMeasure returns false. The asset selection, the parameter search and the ranking of cross-validation results read this trait to choose the direction of the score.
Related
PortfolioOptimisers.supports_precomputed_returns — Method
supports_precomputed_returns(
_::VarianceSkewKurtosis
) -> Bool
Return false: the functor of VarianceSkewKurtosis reads the weights in all three terms, through the comoment matrices, and has no form that reads a series alone.
Related
References
- [219]
- D. Cajas. Semidefinite Relaxation of Higher Portfolio Moments. Available at SSRN 5284483 (2025).