Turnover risk measure
PortfolioOptimisers.TurnoverRiskMeasure Type
struct TurnoverRiskMeasure{__T_settings, __T_w, __T_fixed} <: RiskMeasureRepresents the Turnover risk measure.
TurnoverRiskMeasure penalises portfolio rebalancing by measuring the
Mathematical definition
Let
Where:
: Portfolio turnover. : Portfolio weights vector . : Reference (previous or target) portfolio weights vector . : 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
TurnoverRiskMeasure(;
settings::RiskMeasureSettings = RiskMeasureSettings(),
w::VecNum,
fixed::Bool = false
) -> TurnoverRiskMeasureKeywords correspond to the struct's fields.
Validation
!isempty(w).
Functor
(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:
w: Sliced to the selected indices viaport_opt_view.
Examples
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: falseRelated
sourcePortfolioOptimisers.port_opt_view Method
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
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(r::TurnoverRiskMeasure) -> AnyReturn whether TurnoverRiskMeasure r requires previous portfolio weights.
Returns true if r.fixed is false (i.e., the reference weights are updated each period).
Related
sourcePortfolioOptimisers.factory Method
factory(
r::TurnoverRiskMeasure,
w::AbstractVector{<:Union{var"#s29", var"#s28"} where {var"#s29"<:Number, var"#s28"<:AbstractJuMPScalar}}
) -> TurnoverRiskMeasureCreate 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
sourcePortfolioOptimisers.factory Function
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...
) -> TurnoverRiskMeasureCreate 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