Risk Measure Tools

PortfolioOptimisers.unit_scale_risk_measureFunction
unit_scale_risk_measure(r)

Return a copy of risk measure r with its scale set to one(scale), preserving its upper bound and its rke flag. A measure that already carries a unit scale is returned unchanged, so the common path allocates nothing.

scale is a combination weight: it says how much this measure contributes to an aggregate built from several measures. One measure is not an aggregate, so the weight has nothing to weigh and the model drops it before it can reach the risk expression. Hierarchical risk measures are returned unchanged.

Arguments

  • r: Risk measure.

Returns

  • Risk measure carrying a unit scale.

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
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