Skip to content
18

Turnover risk measure

PortfolioOptimisers.TurnoverRiskMeasure Type
julia
struct TurnoverRiskMeasure{__T_settings, __T_w, __T_fixed} <: RiskMeasure

Represents the Turnover risk measure.

TurnoverRiskMeasure penalises portfolio rebalancing by measuring the L1 distance between the new portfolio weights and a reference weight vector. It controls trading costs and limits portfolio drift.

Mathematical definition

Let w be the new portfolio weights and w0 the reference (previous or target) weights:

Turnover(w)=w0w1=i=1N|w0,iwi|.

Where:

  • Turnover(w): Portfolio turnover.

  • w: Portfolio weights vector N×1.

  • w0: Reference (previous or target) portfolio weights vector N×1.

  • N: Number of assets.

Fields

  • settings: Risk measure settings.

  • w: Reference portfolio weights vector.

  • fixed: Whether the estimator is fixed and does not update with new weights.

Constructors

julia
TurnoverRiskMeasure(;
    settings::RiskMeasureSettings = RiskMeasureSettings(),
    w::VecNum,
    fixed::Bool = false
) -> TurnoverRiskMeasure

Keywords correspond to the struct's fields.

Validation

  • !isempty(w).

Functor

julia
(r::TurnoverRiskMeasure)(w::VecNum)

Computes the Turnover risk of a portfolio weight vector w.

Arguments

  • w::VecNum: New portfolio weights vector.

View parameters

When port_opt_view is called on this type, the following @vprop-tagged fields are automatically subset to the selected indices:

Examples

julia
julia> TurnoverRiskMeasure(; w = [0.5, 0.5])
TurnoverRiskMeasure
  settings ┼ RiskMeasureSettings
           │   scale ┼ Float64: 1.0
           │      ub ┼ nothing
           │     rke ┴ Bool: true
         w ┼ Vector{Float64}: [0.5, 0.5]
     fixed ┴ Bool: false

Related

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(x, i, args...; kwargs...) -> nothing_scalar_array_view(x, i)

Sub-select an estimator, result, or algorithm to the asset/observation index i.

port_opt_view is the index-selection counterpart of factory: where factory threads runtime values down a composed struct tree, port_opt_view threads an index selection — restricting every data-bearing field and composed child to the subset i. It is the mechanism that makes meta-optimisers (NestedClustered, SubsetResampling) and cross-validation variants operate on subproblems with identical struct shapes.

Callers do not normally call port_opt_view directly; it is driven by meta-optimisers and cross-validation internals. It is public (not exported) because extension authors who implement a new composed estimator may need to define a method. Use @vprop on data-bearing fields to have the method generated automatically.

This universal fallback handles leaf values: arrays are sliced via nothing_scalar_array_view; scalars, nothing, estimators without data fields, and algorithms pass through unchanged. Composed structs that recurse into children define their own (more specific) method — emitted by @vprop or hand-written.

The threaded tail args... (typically the returns matrix X for the JuMP families) and any kwargs are accepted and dropped here, so a macro-threaded port_opt_view(child, i, X) never MethodErrors on a leaf field.

Related

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

Return whether TurnoverRiskMeasure r requires previous portfolio weights.

Returns true if r.fixed is false (i.e., the reference weights are updated each period).

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    r::TurnoverRiskMeasure,
    w::AbstractVector{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}}
) -> TurnoverRiskMeasure

Create an instance of TurnoverRiskMeasure updating the reference weights to w.

If r.fixed is true, returns r unchanged. Otherwise, constructs a new instance with w as the reference weight vector.

Related

source
PortfolioOptimisers.factory Function
julia
factory(
    r::TurnoverRiskMeasure,
    ,
    ,
    ;
    ...
) -> TurnoverRiskMeasure
factory(
    r::TurnoverRiskMeasure,
    ,
    ,
    ,
    w::Union{Nothing, AbstractVector{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}}},
    args...;
    kwargs...
) -> TurnoverRiskMeasure

Create an instance of TurnoverRiskMeasure from a full optimisation context, forwarding the optional weight argument w to factory(r, w).

Ignores prior result, solver, and uncertainty set arguments — only w is used.

Related

source