Risk Measure Tools: private API

PortfolioOptimisers.MomentRiskMeasuresType
const MomentRiskMeasures{T} = Union{<:LowOrderMoment{<:Any, T}, <:HighOrderMoment{<:Any, T}, <:Kurtosis{<:Any, T}, <:Skewness{<:Any, <:Any, <:Any, T}, <:ThirdCentralMoment{<:Any, T}}

Parameterised union of the five central-moment risk measures sharing the same observation-weight (T) type parameter.

The members are LowOrderMoment, HighOrderMoment, Kurtosis, Skewness and ThirdCentralMoment. Each evaluates the same way — deviations from the centring target, then moment_risk — and each resolves a DynamicAbstractWeights the same way, so the four functor methods are written once here rather than four times per measure.

T selects the arm:

  • Option{<:StatsBase.AbstractWeights}: the weights are resolved, so the measure computes.
  • <:DynamicAbstractWeights: the weights are not resolved, so the measure resolves them against the data it was handed and re-calls itself.

The rebuild replaces w and copies every other field, so it names no field list and cannot drop a field. The ten hand-written rebuilds it replaces did: Skewness reset its settings, and Kurtosis bound its rebuild to SemiMoment, which left a default Kurtosis carrying dynamic weights matching no method at all.

Related

source
PortfolioOptimisers.measure_labelFunction
measure_label(r::AbstractBaseRiskMeasure) -> String
measure_label(rs::VecBaseRM) -> String

Name a risk measure for an axis label, a title, or a legend entry.

One measure answers its own type name. A vector answers its elements' names joined by " + ".

The vector arm is the reason the helper exists. string(nameof(typeof(rs))) on a vector evaluates to "Vector" — a wrong label, silently, with no error — and seven plot sites spelled that expression inline. Writing the rule once means a future measure-taking plot inherits it.

Related

source