Moment Risk Measures
PortfolioOptimisers.FirstLowerMoment Type
struct FirstLowerMoment <: UnstandardisedLowOrderMomentMeasureAlgorithm endRepresents the first lower moment risk measure algorithm in PortfolioOptimisers.jl.
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
sourcePortfolioOptimisers.MeanAbsoluteDeviation Type
struct MeanAbsoluteDeviation <: UnstandardisedLowOrderMomentMeasureAlgorithm endRepresents the mean absolute deviation risk measure algorithm in PortfolioOptimisers.jl.
Computes portfolio risk as the mean of the absolute deviations of the returns series from a target value.
Related
sourcePortfolioOptimisers.SecondMoment Type
struct SecondMoment{T1, T2, T3} <: LowOrderMomentMeasureAlgorithm
ve::T1
alg1::T2
alg2::T3
endRepresents a second moment (variance or standard deviation) risk measure algorithm in PortfolioOptimisers.jl.
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 used to compute the second moment.alg1: Moment algorithm specifying whether to use all deviations or only downside deviations.alg2: Second moment formulation specifying the optimisation formulation.
Constructors
SecondMoment(; ve::AbstractVarianceEstimator = SimpleVariance(; me = nothing),
alg1::AbstractMomentAlgorithm = Full(),
alg2::SecondMomentFormulation = SquaredSOCRiskExpr())Keyword arguments correspond to the fields above.
Examples
julia> SecondMoment()
SecondMoment
ve ┼ SimpleVariance
│ me ┼ nothing
│ w ┼ nothing
│ corrected ┴ Bool: true
alg1 ┼ Full()
alg2 ┴ SquaredSOCRiskExpr()Related
PortfolioOptimisers.LowOrderMoment Type
struct LowOrderMoment{T1, T2, T3, T4} <: RiskMeasure
settings::T1
w::T2
mu::T3
alg::T4
endRepresents a low-order moment risk measure in PortfolioOptimisers.jl.
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.
Fields
settings: Risk measure configuration.w: Optional vector of observation weights.mu: Optional target scalar, vector, orVecScalarvalue for moment calculation that overrides the priormuwhen provided. Also used to compute the moment target, viacalc_moment_target. Ifnothingit is computed from the returns series using the optional weights inw.alg: Low-order moment risk measure algorithm.
Constructors
LowOrderMoment(; settings::RiskMeasureSettings = RiskMeasureSettings(),
w::Union{Nothing, <:AbstractWeights} = nothing,
mu::Union{Nothing, <:Real, <:AbstractVector{<:Real}, <:VecScalar} = nothing,
alg::LowOrderMomentMeasureAlgorithm = FirstLowerMoment())Keyword arguments correspond to the fields above.
Validation
If
muis notnothing:::Real:isfinite(mu).::AbstractVector:!isempty(mu)andall(isfinite, mu).
If
wis notnothing,!isempty(w).
Formulations
Depending on the alg field, the risk measure is formulated using JuMP as follows:
FirstLowerMoment
The first lower moment is computed as:
Where:
: T×1vector of portfolio returns.: expected value operator, supports weighted averages. : element-wise function application.
As an optimisation problem, it can be formulated as:
Where:
: N×1asset weights vector.: T×1vector of auxiliary decision variables representing deviations below the target.: T×Nreturn matrix.: expected value operator, supports weighted averages.
MeanAbsoluteDeviation
The mean absolute deviation is computed as:
Where:
: T×1vector of portfolio returns.: expected value operator, supports weighted averages.
As an optimisation problem, it can be formulated as:
Where:
: N×1asset weights vector.: T×1vector of auxiliary decision variables representing deviations below the target.: T×Nreturn matrix.: 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.
Info
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.
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:
Where:
: T×1vector of portfolio returns.: expected value operator, supports weighted averages.
The (semi-)standard deviation formulation is:
It is computed as:
Where:
: T×1vector of portfolio returns.: expected value operator, supports weighted averages.
SquaredSOCRiskExpr
Represents the (semi-)variance using the square of a second order cone constrained variable.
The variance is formulated as.
The semi-variance is formulated as.
Where:
: N×1asset weights vector.: T×1vector of auxiliary decision variables representing deviations from the target.: standard deviation of the portfolio returns. : T×1vector of scaled deviations according to observation weights.: T×Nreturn matrix.: T×1vector of observation weights.: observation weights scaling factor, it is a function of the type of observation weights. : second order cone. : 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.
The semi-variance is formulated as.
Where:
: N×1asset weights vector.: T×1vector of auxiliary decision variables representing deviations from the target.: variance of the portfolio returns. : T×1vector of scaled deviations according to observation weights.: T×Nreturn matrix.: T×1vector of observation weights.: observation weights scaling factor, it is a function of the type of observation weights. : rotated second order cone. : element-wise (Hadamard) product.
QuadRiskExpr
Represents the (semi-)variance using the deviations vector dotted with itself.
The variance is formulated as.
The semi-variance is formulated as.
Where:
: N×1asset weights vector.: T×1vector of auxiliary decision variables representing deviations from the target.: T×1vector of scaled deviations according to observation weights.: T×Nreturn matrix.: minimum acceptable return. : T×1vector of observation weights.: observation weights scaling factor, it is a function of the type of observation weights. : element-wise (Hadamard) product.
SOCRiskExpr
Represents the (semi-)standard deviation using a second order cone constrained variable.
The standard deviation is formulated as.
The semi-standard deviation is formulated as.
Where:
: N×1asset weights vector.: T×1vector of auxiliary decision variables representing deviations from the target.: standard deviation of the portfolio returns. : T×1vector of scaled deviations according to observation weights.: T×Nreturn matrix.: minimum acceptable return. : T×1vector of observation weights.: observation weights scaling factor, it is a function of the type of observation weights. : element-wise (Hadamard) product. : second order cone.
Functor
(r::LowOrderMoment)(w::AbstractVector, X::AbstractMatrix;
fees::Union{Nothing, <:Fees} = nothing)Computes the 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
PortfolioOptimisers.ThirdLowerMoment Type
struct ThirdLowerMoment <: UnstandardisedHighOrderMomentMeasureAlgorithm endRepresents the unstandardised semi-skewness risk measure algorithm in PortfolioOptimisers.jl.
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. This algorithm is unstandardised and operates directly on the return distribution.
Related
sourcePortfolioOptimisers.FourthMoment Type
struct FourthMoment{T1} <: UnstandardisedHighOrderMomentMeasureAlgorithm
alg::T1
endRepresents the unstandardised fourth moment (kurtosis or semi-kurtosis) risk measure algorithm in PortfolioOptimisers.jl.
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 specifying whether to use all deviations or only downside deviations.
Constructors
FourthMoment(; alg::AbstractMomentAlgorithm = Full())Keyword arguments correspond to the fields above.
Examples
julia> FourthMoment()
FourthMoment
alg ┴ Full()Related
sourcePortfolioOptimisers.StandardisedHighOrderMoment Type
struct StandardisedHighOrderMoment{T1, T2} <: HighOrderMomentMeasureAlgorithm
ve::T1
alg::T2
endRepresents a standardised high-order moment risk measure algorithm in PortfolioOptimisers.jl.
Computes portfolio risk using a high-order moment algorithm (such as semi-skewness or semi-kurtosis), standardised by a variance estimator. This enables risk measures such as standardised semi-skewness or standardised semi-kurtosis, which normalise the risk by the portfolio variance.
Fields
ve: Variance estimator used for standardisation.alg: Unstandardised high-order moment algorithm used to compute the risk measure.
Constructors
StandardisedHighOrderMoment(;
ve::AbstractVarianceEstimator = SimpleVariance(; me = nothing),
alg::UnstandardisedHighOrderMomentMeasureAlgorithm = ThirdLowerMoment())Keyword arguments correspond to the fields above.
Examples
julia> StandardisedHighOrderMoment()
StandardisedHighOrderMoment
ve ┼ SimpleVariance
│ me ┼ nothing
│ w ┼ nothing
│ corrected ┴ Bool: true
alg ┴ ThirdLowerMoment()Related
PortfolioOptimisers.HighOrderMoment Type
struct HighOrderMoment{T1, T2, T3, T4} <: HierarchicalRiskMeasure
settings::T1
w::T2
mu::T3
alg::T4
endRepresents a high-order moment risk measure in PortfolioOptimisers.jl.
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.
Fields
settings: Risk measure configuration.w: Optional vector of observation weights.mu: Optional target scalar, vector, orVecScalarvalue for moment calculation that overrides the priormuwhen provided. Also used to compute the moment target, viacalc_moment_target. Ifnothingit is computed from the returns series using the optional weights inw.alg: High-order moment risk measure algorithm.
Constructors
HighOrderMoment(; settings::RiskMeasureSettings = RiskMeasureSettings(),
w::Union{Nothing, <:AbstractWeights} = nothing,
mu::Union{Nothing, <:Real, <:AbstractVector{<:Real}, <:VecScalar} = nothing,
alg::HighOrderMomentMeasureAlgorithm = ThirdLowerMoment())Keyword arguments correspond to the fields above.
Validation
If
muis notnothing:::Real:isfinite(mu).::AbstractVector:!isempty(mu)andall(isfinite, mu).
If
wis notnothing,!isempty(w).
Formulations
Depending on the alg field, the risk measure is can compute 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.
Unstandardised Moments
All unstandardised central moments have the following formula.
All unstandardised lower moments have the following formula.
Standardised Moments
All standardised central moments have the following formula.
All standardised lower moments have the following formula.
Where:
: T×1vector of portfolio returns.: expected value operator, supports weighted averages. : element-wise function application.
Functor
(r::HighOrderMoment)(w::AbstractVector, X::AbstractMatrix;
fees::Union{Nothing, <:Fees} = nothing)Computes the 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 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> HighOrderMoment()
HighOrderMoment
settings ┼ RiskMeasureSettings
│ scale ┼ Float64: 1.0
│ ub ┼ nothing
│ rke ┴ Bool: true
w ┼ nothing
mu ┼ nothing
alg ┴ ThirdLowerMoment()Related
PortfolioOptimisers.MomentMeasureAlgorithm Type
abstract type MomentMeasureAlgorithm <: AbstractAlgorithm endAbstract supertype for all moment-based risk measure algorithms in PortfolioOptimisers.jl.
Defines the interface for algorithms that compute portfolio risk using statistical moments (e.g., mean, variance, skewness, kurtosis) of the return distribution. All concrete moment risk measure algorithms should subtype MomentMeasureAlgorithm to ensure consistency and composability within the risk measure framework.
Related Types
sourcePortfolioOptimisers.LowOrderMomentMeasureAlgorithm Type
abstract type LowOrderMomentMeasureAlgorithm <: MomentMeasureAlgorithm endAbstract supertype for all low-order moment-based risk measure algorithms in PortfolioOptimisers.jl.
Defines the interface for algorithms that compute portfolio risk using low-order statistical moments (e.g., mean, variance, mean absolute deviation) of the return distribution. All concrete low-order moment risk measure algorithms should subtype LowOrderMomentMeasureAlgorithm to ensure consistency and composability within the risk measure framework.
Related Types
sourcePortfolioOptimisers.UnstandardisedLowOrderMomentMeasureAlgorithm Type
abstract type UnstandardisedLowOrderMomentMeasureAlgorithm <: LowOrderMomentMeasureAlgorithm endAbstract supertype for low-order moment risk measure algorithms that are not standardised by the variance in PortfolioOptimisers.jl.
Defines the interface for algorithms that compute portfolio risk using low-order statistical moments without normalising by the variance. All concrete unstandardised low-order moment risk measure algorithms should subtype UnstandardisedLowOrderMomentMeasureAlgorithm to ensure consistency and composability within the risk measure framework.
Related Types
sourcePortfolioOptimisers.HighOrderMomentMeasureAlgorithm Type
abstract type HighOrderMomentMeasureAlgorithm <: MomentMeasureAlgorithm endAbstract supertype for all high-order moment-based risk measure algorithms in PortfolioOptimisers.jl.
Defines the interface for algorithms that compute portfolio risk using high-order statistical moments (e.g., skewness, kurtosis) of the return distribution. All concrete high-order moment risk measure algorithms should subtype HighOrderMomentMeasureAlgorithm to ensure consistency and composability within the risk measure framework.
Related Types
sourcePortfolioOptimisers.UnstandardisedHighOrderMomentMeasureAlgorithm Type
abstract type UnstandardisedHighOrderMomentMeasureAlgorithm <: HighOrderMomentMeasureAlgorithm endAbstract supertype for high-order moment risk measure algorithms that are not standardised by the variance in PortfolioOptimisers.jl.
Defines the interface for algorithms that compute portfolio risk using high-order statistical moments (such as skewness, kurtosis) without normalising by the variance. All concrete unstandardised high-order moment risk measure algorithms should subtype UnstandardisedHighOrderMomentMeasureAlgorithm to ensure consistency and composability within the risk measure framework.
Related Types
sourcePortfolioOptimisers.calc_moment_target Method
calc_moment_target(::Union{<:LowOrderMoment{<:Any, Nothing, Nothing, <:Any},
<:HighOrderMoment{<:Any, Nothing, Nothing, <:Any}},
::Any, x::AbstractVector)Compute the target value for moment calculations when neither a target value (mu) nor observation weights are provided in the risk measure.
Arguments
r: ALowOrderMomentorHighOrderMomentrisk measure with bothwandmufields set tonothing._: Unused argument (typically asset weights, ignored in this method).x: Returns vector.
Returns
target::eltype(x): The mean of the returns vector.
Related
sourcePortfolioOptimisers.calc_moment_target Method
calc_moment_target(r::Union{<:LowOrderMoment{<:Any, <:AbstractWeights, Nothing, <:Any},
<:HighOrderMoment{<:Any, <:AbstractWeights, Nothing, <:Any}},
::Any, x::AbstractVector)Compute the target value for moment calculations when the risk measure provides an observation weights vector but no explicit target value (mu).
Arguments
r: ALowOrderMomentorHighOrderMomentrisk measure withwset to an observation weights vector andmuset tonothing._: Unused argument (typically asset weights, ignored in this method).x: Returns vector.
Returns
target::eltype(x): The weighted mean of the returns vector, using the observation weights fromr.w.
Related
sourcePortfolioOptimisers.calc_moment_target Method
calc_moment_target(r::Union{<:LowOrderMoment{<:Any, <:Any, <:AbstractVector, <:Any},
<:HighOrderMoment{<:Any, <:Any, <:AbstractVector, <:Any}},
w::AbstractVector, ::Any)Compute the target value for moment calculations when the risk measure provides an explicit expected returns vector (mu).
Arguments
r: ALowOrderMomentorHighOrderMomentrisk measure withmuset to an expected returns vector.w: Asset weights vector.::Any: Unused argument (typically the returns vector, ignored in this method).
Returns
target::eltype(w): The dot product of the asset weights and the expected returns vector.
Related
sourcePortfolioOptimisers.calc_moment_target Method
calc_moment_target(r::Union{<:LowOrderMoment{<:Any, <:Any, <:VecScalar, <:Any},
<:HighOrderMoment{<:Any, <:Any, <:VecScalar, <:Any}},
w::AbstractVector, ::Any)Compute the target value for moment calculations when the risk measure provides a VecScalar as the expected returns (mu).
Arguments
r: ALowOrderMomentorHighOrderMomentrisk measure withmuset to aVecScalar(an object with fieldsvfor the expected returns vector andsfor a scalar offset).w: Asset weights vector.::Any: Unused argument (typically the returns vector, ignored in this method).
Returns
target::promote_type(eltype(w), eltype(r.mu.v), typeof(r.mu.s)): The sum of the dot product of the asset weights and the expected returns vector plus the scalar offset,dot(w, r.mu.v) + r.mu.s.
Related
sourcePortfolioOptimisers.calc_moment_target Method
calc_moment_target(r::Union{<:LowOrderMoment{<:Any, <:Any, <:Real, <:Any},
<:HighOrderMoment{<:Any, <:Any, <:Real, <:Any}}, ::Any, ::Any)Compute the target value for moment calculations when the risk measure provides a scalar value for the expected returns (mu).
Arguments
r: ALowOrderMomentorHighOrderMomentrisk measure withmuset to a scalar value.::Any: Unused argument (typically asset weights, ignored in this method).::Any: Unused argument (typically the returns vector, ignored in this method).
Returns
target::Real: The scalar value ofr.mu.
Related
sourcePortfolioOptimisers.calc_deviations_vec Function
calc_deviations_vec(r::Union{<:LowOrderMoment, <:HighOrderMoment}, w::AbstractVector,
X::AbstractMatrix; fees::Union{Nothing, <:Fees} = nothing)Compute the vector of deviations from the target value for moment-based risk measures.
Arguments
r: ALowOrderMomentorHighOrderMomentrisk measure specifying the moment calculation algorithm and target.w: Asset weights vector.X: Return matrix.fees: Optional fees object to adjust net returns.
Returns
val::AbstractVector: The vector of deviations between net portfolio returns and the computed moment target.
Details
Computes net portfolio returns using the provided weights, return matrix, and optional fees.
Computes the target value for the moment calculation using
calc_moment_target.Returns the element-wise difference between net returns and the target value.
Related
source