Tracking risk measure
PortfolioOptimisers.RiskTrackingError Type
struct RiskTrackingError{__T_tr, __T_r, __T_err, __T_alg} <: AbstractTrackingRepresents 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
RiskTrackingError(;
tr::WeightsTracking,
r::AbstractBaseRiskMeasure = StandardDeviation(),
err::Number = 0.0,
alg::VariableTracking = IndependentVariableTracking()
) -> RiskTrackingErrorKeywords correspond to the struct's fields.
Validation
erris validated withassert_nonempty_nonneg_finite_val.
Related
PortfolioOptimisers.port_opt_view Method
port_opt_view(::Nothing, ::Any; kwargs...) -> nothing
port_opt_view(::Nothing, ::Any, args...; kwargs...) -> nothingCanonical 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> PortfolioOptimisers.port_opt_view(nothing, 1)PortfolioOptimisers.port_opt_view Method
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
sourcePortfolioOptimisers.factory Function
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
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(tr::RiskTrackingError) -> AnyReturn whether RiskTrackingError tr requires previous portfolio weights.
Returns true if either the inner tracking benchmark or the inner risk measure requires previous weights.
Related
sourcePortfolioOptimisers.factory Method
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
sourcePortfolioOptimisers.TrackingRiskMeasure Type
struct TrackingRiskMeasure{__T_settings, __T_tr, __T_alg} <: RiskMeasureRepresents 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
Where:
: tracking error of the portfolio. : Portfolio weights vector . : Portfolio returns series . : Benchmark returns series . : 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
TrackingRiskMeasure(;
settings::RiskMeasureSettings = RiskMeasureSettings(),
tr::AbstractTrackingAlgorithm,
alg::NormTracking = L2Tracking()
) -> TrackingRiskMeasureKeywords correspond to the struct's fields.
Functor
(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 (). fees: Optional fee structure.
Examples
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: 1Related
PortfolioOptimisers.port_opt_view Method
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
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(r::TrackingRiskMeasure) -> AnyReturn whether TrackingRiskMeasure r requires previous portfolio weights.
Delegates to the inner tracking specification.
Related
sourcePortfolioOptimisers.factory Method
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
sourcePortfolioOptimisers.factory Method
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
sourcePortfolioOptimisers.RiskTrackingRiskMeasure Type
struct RiskTrackingRiskMeasure{__T_settings, __T_tr, __T_r, __T_alg} <: RiskMeasureRepresents 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. Dependent (
DependentVariableTracking): computes the absolute difference between the portfolio risk and the benchmark risk.
Mathematical definition
Independent mode:
Where:
: Risk of the weight difference between portfolio and benchmark. : Portfolio weights vector . : Benchmark portfolio weights vector . : Chosen base risk measure.
Dependent mode:
Where:
: Absolute difference between portfolio risk and benchmark risk. : Portfolio weights vector . : Benchmark portfolio weights vector . : Chosen base risk measure.
Fields
settings: Risk measure settings.tr: Benchmark tracking specification.r: Risk measure instance.alg: Tracking formulation algorithm.
Constructors
RiskTrackingRiskMeasure(;
settings::RiskMeasureSettings = RiskMeasureSettings(),
tr::WeightsTracking,
r::AbstractBaseRiskMeasure = Variance(),
alg::VariableTracking = IndependentVariableTracking()
) -> RiskTrackingRiskMeasureKeywords correspond to the struct's fields.
Functor
(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 (). fees: Optional fee structure.
Examples
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
PortfolioOptimisers.port_opt_view Method
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
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(r::RiskTrackingRiskMeasure) -> AnyReturn whether RiskTrackingRiskMeasure r requires previous portfolio weights.
Returns true if either the inner tracking benchmark or the inner risk measure requires previous weights.
Related
sourcePortfolioOptimisers.factory Method
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
sourcePortfolioOptimisers.factory Method
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
sourcePortfolioOptimisers.TrRM Type
const TrRM = Union{<:TrackingRiskMeasure, <:RiskTrackingRiskMeasure}Union of tracking risk measures used for dispatch on factory methods and expected risk computations.
Related
sourcePortfolioOptimisers.supports_precomputed_returns Method
supports_precomputed_returns(
_::TrackingRiskMeasure{<:WeightsTracking}
) -> BoolReturn false: a WeightsTracking measure compares against a benchmark weight vector and always requires explicit portfolio weights.
Related
sourcePortfolioOptimisers.supports_precomputed_returns Method
supports_precomputed_returns(
_::TrackingRiskMeasure{<:ReturnsTracking}
) -> BoolReturn true: a ReturnsTracking measure compares against a benchmark return series and its risk is a function of the net-return series alone.
Related
source