Skip to content
13

Tracking risk measure

PortfolioOptimisers.RiskTrackingError Type
julia
struct RiskTrackingError{__T_tr, __T_r, __T_err, __T_alg} <: AbstractTracking

Represents the Risk Tracking Error configuration for benchmark weight tracking.

RiskTrackingError specifies tracking error measurement against a benchmark as a risk quantity (rather than a norm). It wraps a WeightsTracking benchmark, a risk measure r, a scalar error tolerance err, and a tracking algorithm alg.

Fields

  • tr: Benchmark tracking specification.

  • r: Risk measure instance.

  • err: Tracking error tolerance.

  • alg: Tracking formulation algorithm.

Constructors

julia
RiskTrackingError(;
    tr::WeightsTracking,
    r::AbstractBaseRiskMeasure = StandardDeviation(),
    err::Number = 0.0,
    alg::VariableTracking = IndependentVariableTracking()
) -> RiskTrackingError

Keywords correspond to the struct's fields.

Validation

Related

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(::Nothing, ::Any; kwargs...) -> nothing
port_opt_view(::Nothing, ::Any, args...; kwargs...) -> nothing

Canonical absent-value fallback for port_opt_view: an index view of a missing (nothing) estimator, algorithm, result, or constraint is itself nothing.

These methods serve every propagation family. Because many optional fields are typed Option{T} = Union{Nothing, T}, the ::Nothing-specific methods are also what disambiguate a nothing argument from the family-specific Option{T} passthroughs and from the universal leaf fallback. Both carry a fixed second positional so they dominate the universal port_opt_view(x, i, args...) method.

Examples

julia
julia> PortfolioOptimisers.port_opt_view(nothing, 1)
source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    tr::RiskTrackingError,
    i,
    X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    args...
) -> RiskTrackingError{WeightsTracking{__T_fees, __T_w, __T_fixed}, _A, <:Number, <:VariableTracking} where {__T_fees, __T_w, __T_fixed, _A}

Return a view of RiskTrackingError tr sliced to asset indices i.

Slices both the inner tracking benchmark and the risk measure for cluster-based optimisation.

Related

source
PortfolioOptimisers.factory Function
julia
factory(
    tr::RiskTrackingError,
    pr::AbstractPriorResult,
    slv,
    ucs;
    ...
) -> RiskTrackingError{WeightsTracking{__T_fees, __T_w, __T_fixed}, _A, <:Number, <:VariableTracking} where {__T_fees, __T_w, __T_fixed, _A}
factory(
    tr::RiskTrackingError,
    pr::AbstractPriorResult,
    slv,
    ucs,
    w::Union{Nothing, AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}},
    args...;
    kwargs...
) -> RiskTrackingError{WeightsTracking{__T_fees, __T_w, __T_fixed}, _A, <:Number, <:VariableTracking} where {__T_fees, __T_w, __T_fixed, _A}

Create an instance of RiskTrackingError updating the inner benchmark and risk measure from the prior result and solver context.

Related

source
PortfolioOptimisers.needs_previous_weights Method
julia
needs_previous_weights(tr::RiskTrackingError) -> Any

Return whether RiskTrackingError tr requires previous portfolio weights.

Returns true if either the inner tracking benchmark or the inner risk measure requires previous weights.

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    tr::RiskTrackingError,
    w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}
) -> RiskTrackingError{WeightsTracking{__T_fees, __T_w, __T_fixed}, _A, <:Number, <:VariableTracking} where {__T_fees, __T_w, __T_fixed, _A}

Create an instance of RiskTrackingError updating the inner benchmark and risk measure from new portfolio weights w.

Related

source
PortfolioOptimisers.TrackingRiskMeasure Type
julia
struct TrackingRiskMeasure{__T_settings, __T_tr, __T_alg} <: RiskMeasure

Represents the Tracking Error risk measure.

TrackingRiskMeasure penalises portfolio deviation from a benchmark by computing a norm of the difference between portfolio returns and a benchmark return series or benchmark weights. The tracking error is defined using returns-based or weights-based benchmarks, and the norm is configurable.

Mathematical definition

Let x be the portfolio returns series, b the benchmark returns, and NT the number of observations. The L2 tracking error is:

TE(w)=1NTxb22.

Where:

  • TE(w): L2 tracking error of the portfolio.

  • w: Portfolio weights vector N×1.

  • x: Portfolio returns series NT×1.

  • b: Benchmark returns series NT×1.

  • NT: Number of observations.

Other norms can be selected via the alg field.

Fields

  • settings: Risk measure settings.

  • tr: Benchmark tracking specification.

  • alg: Tracking formulation algorithm.

Constructors

julia
TrackingRiskMeasure(;
    settings::RiskMeasureSettings = RiskMeasureSettings(),
    tr::AbstractTrackingAlgorithm,
    alg::NormTracking = L2Tracking()
) -> TrackingRiskMeasure

Keywords correspond to the struct's fields.

Functor

julia
(r::TrackingRiskMeasure)(w::VecNum, X::MatNum, fees = nothing)

Computes the Tracking Error of a portfolio weight vector w.

Arguments

  • w::VecNum: Portfolio weights vector.

  • X::MatNum: Asset returns matrix (T×N).

  • fees: Optional fee structure.

Examples

julia
julia> TrackingRiskMeasure(; tr = ReturnsTracking(; w = [0.1, -0.2, 0.3]))
TrackingRiskMeasure
  settings ┼ RiskMeasureSettings
           │   scale ┼ Float64: 1.0
           │      ub ┼ nothing
           │     rke ┴ Bool: true
        tr ┼ ReturnsTracking
           │   w ┴ Vector{Float64}: [0.1, -0.2, 0.3]
       alg ┼ L2Tracking
           │   ddof ┴ Int64: 1

Related

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    r::TrackingRiskMeasure,
    i,
    args...
) -> TrackingRiskMeasure{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, <:AbstractTrackingAlgorithm, <:NormTracking} where {__T_scale, __T_ub, __T_rke}

Return a view of TrackingRiskMeasure r sliced to asset indices i.

Slices the inner tracking specification for cluster-based optimisation.

Related

source
PortfolioOptimisers.needs_previous_weights Method
julia
needs_previous_weights(r::TrackingRiskMeasure) -> Any

Return whether TrackingRiskMeasure r requires previous portfolio weights.

Delegates to the inner tracking specification.

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    r::TrackingRiskMeasure,
    w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}
) -> TrackingRiskMeasure{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, <:AbstractTrackingAlgorithm, <:NormTracking} where {__T_scale, __T_ub, __T_rke}

Create an instance of TrackingRiskMeasure updating the inner tracking specification with new weights w.

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    r::TrackingRiskMeasure,
    ,
    ,
    ,
    w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    args...;
    kwargs...
) -> TrackingRiskMeasure{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, <:AbstractTrackingAlgorithm, <:NormTracking} where {__T_scale, __T_ub, __T_rke}

Create an instance of TrackingRiskMeasure from a full optimisation context, forwarding w to factory(r, w).

Ignores prior result, solver, and uncertainty set arguments.

Related

source
PortfolioOptimisers.RiskTrackingRiskMeasure Type
julia
struct RiskTrackingRiskMeasure{__T_settings, __T_tr, __T_r, __T_alg} <: RiskMeasure

Represents the Risk Tracking risk measure.

RiskTrackingRiskMeasure computes the deviation of portfolio risk from a benchmark portfolio risk, using any base risk measure. Two modes are supported:

  • Independent (IndependentVariableTracking): computes the risk of the weight difference wwb.

  • Dependent (DependentVariableTracking): computes the absolute difference between the portfolio risk and the benchmark risk.

Mathematical definition

Independent mode:

RkTrackindep(w)=ρ(wwb).

Where:

  • RkTrackindep(w): Risk of the weight difference between portfolio and benchmark.

  • w: Portfolio weights vector N×1.

  • wb: Benchmark portfolio weights vector N×1.

  • ρ: Chosen base risk measure.

Dependent mode:

RkTrackdep(w)=|ρ(w)ρ(wb)|.

Where:

  • RkTrackdep(w): Absolute difference between portfolio risk and benchmark risk.

  • w: Portfolio weights vector N×1.

  • wb: Benchmark portfolio weights vector N×1.

  • ρ: Chosen base risk measure.

Fields

  • settings: Risk measure settings.

  • tr: Benchmark tracking specification.

  • r: Risk measure instance.

  • alg: Tracking formulation algorithm.

Constructors

julia
RiskTrackingRiskMeasure(;
    settings::RiskMeasureSettings = RiskMeasureSettings(),
    tr::WeightsTracking,
    r::AbstractBaseRiskMeasure = Variance(),
    alg::VariableTracking = IndependentVariableTracking()
) -> RiskTrackingRiskMeasure

Keywords correspond to the struct's fields.

Functor

julia
(r::RiskTrackingRiskMeasure)(w::VecNum, X::MatNum, fees = nothing)

Computes the Risk Tracking deviation of a portfolio weight vector w.

Arguments

  • w::VecNum: Portfolio weights vector.

  • X::MatNum: Asset returns matrix (T×N).

  • fees: Optional fee structure.

Examples

julia
julia> RiskTrackingRiskMeasure(; tr = WeightsTracking(; w = [0.5, 0.5]))
RiskTrackingRiskMeasure
  settings ┼ RiskMeasureSettings
           │   scale ┼ Float64: 1.0
           │      ub ┼ nothing
           │     rke ┴ Bool: true
        tr ┼ WeightsTracking
           │    fees ┼ nothing
           │       w ┼ Vector{Float64}: [0.5, 0.5]
           │   fixed ┴ Bool: false
         r ┼ Variance
           │   settings ┼ RiskMeasureSettings
           │            │   scale ┼ Int64: 1
           │            │      ub ┼ nothing
           │            │     rke ┴ Bool: false
           │      sigma ┼ nothing
           │       chol ┼ nothing
           │         rc ┼ nothing
           │        alg ┴ SquaredSOCRiskExpr()
       alg ┴ IndependentVariableTracking()

Related

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    r::RiskTrackingRiskMeasure,
    i,
    X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    args...
) -> RiskTrackingRiskMeasure{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, WeightsTracking{__T_fees, __T_w, __T_fixed}, _A, <:VariableTracking} where {__T_scale, __T_ub, __T_rke, __T_fees, __T_w, __T_fixed, _A}

Return a view of RiskTrackingRiskMeasure r sliced to asset indices i.

Slices both the inner tracking benchmark and the risk measure for cluster-based optimisation.

Related

source
PortfolioOptimisers.needs_previous_weights Method
julia
needs_previous_weights(r::RiskTrackingRiskMeasure) -> Any

Return whether RiskTrackingRiskMeasure r requires previous portfolio weights.

Returns true if either the inner tracking benchmark or the inner risk measure requires previous weights.

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    r::RiskTrackingRiskMeasure,
    w::AbstractVector{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}}
) -> RiskTrackingRiskMeasure{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, WeightsTracking{__T_fees, __T_w, __T_fixed}, _A, <:VariableTracking} where {__T_scale, __T_ub, __T_rke, __T_fees, __T_w, __T_fixed, _A}

Create an instance of RiskTrackingRiskMeasure updating the inner benchmark and risk measure from new portfolio weights w.

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    r::RiskTrackingRiskMeasure,
    pr::AbstractPriorResult,
    args...;
    kwargs...
) -> RiskTrackingRiskMeasure{RiskMeasureSettings{__T_scale, __T_ub, __T_rke}, WeightsTracking{__T_fees, __T_w, __T_fixed}, _A, <:VariableTracking} where {__T_scale, __T_ub, __T_rke, __T_fees, __T_w, __T_fixed, _A}

Create an instance of RiskTrackingRiskMeasure updating the inner risk measure from the prior result.

The inner tracking benchmark is preserved; the risk measure is updated via factory.

Related

source
PortfolioOptimisers.TrRM Type
julia
const TrRM = Union{<:TrackingRiskMeasure, <:RiskTrackingRiskMeasure}

Union of tracking risk measures used for dispatch on factory methods and expected risk computations.

Related

source
PortfolioOptimisers.supports_precomputed_returns Method
julia
supports_precomputed_returns(
    _::TrackingRiskMeasure{<:WeightsTracking}
) -> Bool

Return false: a WeightsTracking measure compares against a benchmark weight vector and always requires explicit portfolio weights.

Related

source
PortfolioOptimisers.supports_precomputed_returns Method
julia
supports_precomputed_returns(
    _::TrackingRiskMeasure{<:ReturnsTracking}
) -> Bool

Return true: a ReturnsTracking measure compares against a benchmark return series and its risk is a function of the net-return series alone.

Related

source