Ratio Risk Measure

PortfolioOptimisers.RiskRatioType
struct RiskRatio{__T_r1, __T_r2} <: HierarchicalRiskMeasure

Represents a risk ratio risk measure for hierarchical portfolio optimisation.

RiskRatio computes the ratio of two risk measures, enabling the construction of risk-adjusted performance metrics for use in hierarchical optimisation routines.

Mathematical definition

\[\begin{align} \mathrm{RiskRatio}(\boldsymbol{x}) &= \frac{r_1(\boldsymbol{x})}{r_2(\boldsymbol{x})}\,. \end{align}\]

Where:

  • $\mathrm{RiskRatio}(\boldsymbol{x})$: Risk ratio of the portfolio.
  • $\boldsymbol{x}$: Portfolio returns vector $T \times 1$.
  • $r_1$: First (numerator) optimisation risk measure.
  • $r_2$: Second (denominator) optimisation risk measure.

Fields

  • r1: First risk measure.
  • r2: Second risk measure.

Constructors

RiskRatio(;    r1::OptimisationRiskMeasure = Variance(),    r2::OptimisationRiskMeasure = ConditionalValueatRisk()) -> RiskRatio

Keywords correspond to the struct's fields.

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

  • r1: Recursively updated via factory.
  • r2: Recursively updated via factory.

Examples

julia> RiskRatio()RiskRatio  r1 ┼ Variance     │   settings ┼ RiskMeasureSettings     │            │   scale ┼ Float64: 1.0     │            │      ub ┼ nothing     │            │     rke ┴ Bool: true     │      sigma ┼ nothing     │       chol ┼ nothing     │         rc ┼ nothing     │        alg ┴ SquaredSOCRiskExpr()  r2 ┼ ConditionalValueatRisk     │   settings ┼ RiskMeasureSettings     │            │   scale ┼ Float64: 1.0     │            │      ub ┼ nothing     │            │     rke ┴ Bool: true     │      alpha ┼ Float64: 0.05     │          w ┴ nothing

Related

source
PortfolioOptimisers.factoryMethod
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                 <:AbstractResult}, args...; kwargs...) -> a
factory(a::AbstractVector{<:Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                                  <:AbstractResult}}, args...; kwargs...) -> Vector

No-op factory function for constructing objects with a uniform interface.

Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.

factory and port_opt_view are the two propagation mechanisms in this library. They are duals: factory threads runtime values (prior moments, observation weights, previous portfolio weights) down through a composed struct tree; port_opt_view threads an index selection (a subset of assets or observations) down through the same tree.

The vector method is the one forwarding contract for every vector-valued propagation field: it applies factory to each element and forwards args... and kwargs... unchanged, so a family that admits a vector of estimators, algorithms, or results needs no method of its own. A family that needs more than the forward, such as a concrete element type (concrete_typed_array_if_abstract), defines its own more specific method.

Algorithm

The scalar method:

  1. Return a unchanged, and drop args... and kwargs.... This method is the leaf of the recursion, and it is what makes an untagged type safe to call the verb on.

The vector method:

  1. For each element ai of a, call factory on ai, and forward args... and kwargs... unchanged.
  2. Collect the results into a new vector, in the order of a, and return it.

A @propagatable struct with at least one @fprop- or @wprop-tagged field carries a generated method that dominates the scalar method. That method rebuilds the struct with its keyword constructor, sending each @fprop field through factory_child and each @wprop field through _wprop.

Arguments

  • a: Indicates no object should be constructed, or a vector whose elements are rebuilt one by one.
  • args...: Arbitrary positional arguments (ignored by the scalar method, forwarded by the vector method).
  • kwargs...: Arbitrary keyword arguments (ignored by the scalar method, forwarded by the vector method).

Returns

  • a: The input unchanged.
  • v::Vector: The element-wise rebuilds, for the vector method.

Examples

julia> factory(nothing, 1, 2; x = 3)julia> factory(MeanValue())MeanValue  w ┴ nothing

Related

source
factory(
    rs::AbstractBaseRiskMeasure,
    args...;
    kwargs...
) -> GenericValueatRiskRange{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}} where {__T_scale, __T_ub, __T_rke}

Return the risk measure rs unchanged.

Identity pass-through used when a risk measure is provided in a context that calls factory.

Related

source
PortfolioOptimisers.factoryMethod
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                 <:AbstractResult}, args...; kwargs...) -> a
factory(a::AbstractVector{<:Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                                  <:AbstractResult}}, args...; kwargs...) -> Vector

No-op factory function for constructing objects with a uniform interface.

Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.

factory and port_opt_view are the two propagation mechanisms in this library. They are duals: factory threads runtime values (prior moments, observation weights, previous portfolio weights) down through a composed struct tree; port_opt_view threads an index selection (a subset of assets or observations) down through the same tree.

The vector method is the one forwarding contract for every vector-valued propagation field: it applies factory to each element and forwards args... and kwargs... unchanged, so a family that admits a vector of estimators, algorithms, or results needs no method of its own. A family that needs more than the forward, such as a concrete element type (concrete_typed_array_if_abstract), defines its own more specific method.

Algorithm

The scalar method:

  1. Return a unchanged, and drop args... and kwargs.... This method is the leaf of the recursion, and it is what makes an untagged type safe to call the verb on.

The vector method:

  1. For each element ai of a, call factory on ai, and forward args... and kwargs... unchanged.
  2. Collect the results into a new vector, in the order of a, and return it.

A @propagatable struct with at least one @fprop- or @wprop-tagged field carries a generated method that dominates the scalar method. That method rebuilds the struct with its keyword constructor, sending each @fprop field through factory_child and each @wprop field through _wprop.

Arguments

  • a: Indicates no object should be constructed, or a vector whose elements are rebuilt one by one.
  • args...: Arbitrary positional arguments (ignored by the scalar method, forwarded by the vector method).
  • kwargs...: Arbitrary keyword arguments (ignored by the scalar method, forwarded by the vector method).

Returns

  • a: The input unchanged.
  • v::Vector: The element-wise rebuilds, for the vector method.

Examples

julia> factory(nothing, 1, 2; x = 3)julia> factory(MeanValue())MeanValue  w ┴ nothing

Related

source
factory(
    rs::AbstractBaseRiskMeasure,
    args...;
    kwargs...
) -> GenericValueatRiskRange{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}} where {__T_scale, __T_ub, __T_rke}

Return the risk measure rs unchanged.

Identity pass-through used when a risk measure is provided in a context that calls factory.

Related

source
PortfolioOptimisers.NonOptimisationRiskRatioType
struct NonOptimisationRiskRatio{__T_settings, __T_r1, __T_sca1, __T_r2, __T_sca2} <: NonOptimisationRiskMeasure

Represents a non-optimisation risk ratio measure.

NonOptimisationRiskRatio computes the ratio of two risk measures for analysis or reporting purposes. Unlike RiskRatio, it is not intended for use as an objective or constraint in optimisation routines.

Mathematical definition

\[\begin{align} \mathrm{RiskRatio}(\boldsymbol{x}) &= \frac{r_1(\boldsymbol{x})}{r_2(\boldsymbol{x})}\,. \end{align}\]

Where:

  • $\mathrm{RiskRatio}(\boldsymbol{x})$: Risk ratio of the portfolio.
  • $\boldsymbol{x}$: Portfolio returns vector $T \times 1$.
  • $r_1$: First (numerator) base risk measure.
  • $r_2$: Second (denominator) base risk measure.

Fields

  • settings: Risk measure settings.
  • r1: First risk measure, or a vector of them scalarised by sca1.
  • sca1: Scalariser combining the risk measures in r1 into one number. Inert when r1 holds a single measure.
  • r2: Second risk measure, or a vector of them scalarised by sca2.
  • sca2: Scalariser combining the risk measures in r2 into one number. Inert when r2 holds a single measure.

Constructors

NonOptimisationRiskRatio(;    settings::HierarchicalRiskMeasureSettings = HierarchicalRiskMeasureSettings(),    r1::BaseRM_VecBaseRM = Variance(),    sca1::Scalariser = SumScalariser(),    r2::BaseRM_VecBaseRM = ConditionalValueatRisk(),    sca2::Scalariser = SumScalariser()) -> NonOptimisationRiskRatio

Keywords correspond to the struct's fields.

Multiplicity

Each axis takes one risk measure or a vector of them, and each carries its own scalariser. This is the only type in the family with two independent risk vectors, so sca1 governs r1 and sca2 governs r2. A scalariser sits immediately after the field it governs.

Both fields beat a caller's sca keyword. A sca passed at the call site flows no further than this type, so a figure reported from a NonOptimisationRiskRatio is always the pair the type names. The two axes are independent: sca1 and sca2 need not agree.

Validation

  • If r1 is a vector: !isempty(r1).
  • If r2 is a vector: !isempty(r2).

Propagated parameters

When factory is called on this type, the following @fprop-tagged fields are automatically propagated:

  • r1: Recursively updated via factory.
  • r2: Recursively updated via factory.

Examples

julia> NonOptimisationRiskRatio()NonOptimisationRiskRatio  settings ┼ HierarchicalRiskMeasureSettings           │   scale ┴ Float64: 1.0        r1 ┼ Variance           │   settings ┼ RiskMeasureSettings           │            │   scale ┼ Float64: 1.0           │            │      ub ┼ nothing           │            │     rke ┴ Bool: true           │      sigma ┼ nothing           │       chol ┼ nothing           │         rc ┼ nothing           │        alg ┴ SquaredSOCRiskExpr()      sca1 ┼ SumScalariser()        r2 ┼ ConditionalValueatRisk           │   settings ┼ RiskMeasureSettings           │            │   scale ┼ Float64: 1.0           │            │      ub ┼ nothing           │            │     rke ┴ Bool: true           │      alpha ┼ Float64: 0.05           │          w ┴ nothing      sca2 ┴ SumScalariser()

Related

source
PortfolioOptimisers.factoryMethod
factory(a::Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                 <:AbstractResult}, args...; kwargs...) -> a
factory(a::AbstractVector{<:Union{Nothing, <:AbstractEstimator, <:AbstractAlgorithm,
                                  <:AbstractResult}}, args...; kwargs...) -> Vector

No-op factory function for constructing objects with a uniform interface.

Defining methods which dispatch on the first argument allows for a consistent factory interface across different types.

factory and port_opt_view are the two propagation mechanisms in this library. They are duals: factory threads runtime values (prior moments, observation weights, previous portfolio weights) down through a composed struct tree; port_opt_view threads an index selection (a subset of assets or observations) down through the same tree.

The vector method is the one forwarding contract for every vector-valued propagation field: it applies factory to each element and forwards args... and kwargs... unchanged, so a family that admits a vector of estimators, algorithms, or results needs no method of its own. A family that needs more than the forward, such as a concrete element type (concrete_typed_array_if_abstract), defines its own more specific method.

Algorithm

The scalar method:

  1. Return a unchanged, and drop args... and kwargs.... This method is the leaf of the recursion, and it is what makes an untagged type safe to call the verb on.

The vector method:

  1. For each element ai of a, call factory on ai, and forward args... and kwargs... unchanged.
  2. Collect the results into a new vector, in the order of a, and return it.

A @propagatable struct with at least one @fprop- or @wprop-tagged field carries a generated method that dominates the scalar method. That method rebuilds the struct with its keyword constructor, sending each @fprop field through factory_child and each @wprop field through _wprop.

Arguments

  • a: Indicates no object should be constructed, or a vector whose elements are rebuilt one by one.
  • args...: Arbitrary positional arguments (ignored by the scalar method, forwarded by the vector method).
  • kwargs...: Arbitrary keyword arguments (ignored by the scalar method, forwarded by the vector method).

Returns

  • a: The input unchanged.
  • v::Vector: The element-wise rebuilds, for the vector method.

Examples

julia> factory(nothing, 1, 2; x = 3)julia> factory(MeanValue())MeanValue  w ┴ nothing

Related

source
factory(
    rs::AbstractBaseRiskMeasure,
    args...;
    kwargs...
) -> GenericValueatRiskRange{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}} where {__T_scale, __T_ub, __T_rke}

Return the risk measure rs unchanged.

Identity pass-through used when a risk measure is provided in a context that calls factory.

Related

source