Turnover risk measure

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

Measures the turnover of a portfolio, the $L^1$ distance of its weights from a vector of reference weights.

The measure reads no returns. It reads the portfolio weights and the reference weights w, and nothing else. As a risk term it penalises the trades of a rebalance, and with settings.ub it bounds their sum. Turnover bounds the change of each asset, and this measure bounds or penalises the sum of the changes.

The measure is the full sum of the absolute changes, the two-way turnover. A purchase and the sale that pays for it both count. So a move of a weight of 0.25 from one asset to another has a turnover of 0.5. The one-way convention halves this sum, and the measure does not.

fixed sets the source of the reference weights. With fixed = false, factory replaces w with the weights that it receives, so in a sequence of rebalances w holds the weights of the last rebalance. needs_previous_weights then returns true. With fixed = true, w is a fixed target, and factory keeps it. The constructor has no default for w, so a measure always holds reference weights. A factory call that receives no weights keeps them.

In an optimisation the model is exact. The risk that the model reports, divided by the budget variable $k$ of a ratio problem, is equal to the functor at the optimal weights.

Mathematical definition

\[\begin{align} \mathrm{Turnover}(\boldsymbol{w}) &= \lVert \boldsymbol{w} - \boldsymbol{w}_{0} \rVert_1 = \sum_{i=1}^{N} \lvert w_i - w_{0,i} \rvert\,. \end{align}\]

Where:

  • $\mathrm{Turnover}(\boldsymbol{w})$: Turnover of the portfolio, the sum over the assets of the absolute change of weight from the reference weights.
  • $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
  • $\boldsymbol{w}_{0}$: Reference portfolio weights vector $N \times 1$, the weights from which the turnover is measured.
  • $w_i$: Weight of asset $i$.
  • $w_{0,i}$: Reference weight of asset $i$.
  • $N$: Number of assets.

Equation 9.10 of [12] bounds the absolute change of each asset, $\lvert \boldsymbol{w} - \boldsymbol{w}_{0} \rvert$. This measure is the sum of that vector.

Fields

  • settings: Risk measure settings.
  • w: Reference portfolio weights vector.
  • fixed: If true, factory keeps the reference weights w and ignores the new weights. If false, factory replaces w with the new weights.

Constructors

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

Keywords correspond to the struct's fields.

Validation

  • w, through assert_nonempty_finite_val: !isempty(w) and all(isfinite, w). Every entry must be finite, so the constructor refuses [0.5, NaN].

Functor

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

Computes the turnover of the portfolio weights w from the reference weights r.w.

Arguments

  • w::VecNum: Portfolio weights vector. It has the length of r.w. A vector of a different length raises a DimensionMismatch.

The measure holds no Fees, so fee amortisation cannot reach it. Each fold evaluates it against the reference weights that factory gives.

View parameters

port_opt_view takes the view of these @vprop fields at the selected indices:

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: falsejulia> TurnoverRiskMeasure(; w = [0.5, 0.25, 0.25])([0.25, 0.5, 0.25])0.5

Related

References

  • [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 9.1, Equation 9.10. The original source of this formulation was not found. The formulation follows this work and is not checked against the original.
source
PortfolioOptimisers.port_opt_view — Method
port_opt_view(x, i, args...; kwargs...) -> nothing_scalar_array_view(x, i)

Select the assets i of an estimator, a result or an algorithm.

port_opt_view is the index-selection counterpart of factory. factory passes runtime values down a tree of composed structs, and port_opt_view passes an index selection down the same tree. It restricts every field that holds data, and every composed child, to the subset i. The meta-optimisers, such as NestedClustered and SubsetResampling, and the cross-validation variants use it to solve sub-problems with structs of the same shape.

A caller does not usually call port_opt_view. The meta-optimisers and the cross-validation internals call it. It is public and not exported, because the author of a new composed estimator can need to define a method. Tag each field that holds data with @vprop, and @propagatable makes the method.

This universal fallback handles leaf values. It views an array through nothing_scalar_array_view. It returns a scalar, nothing, an estimator with no data fields and an algorithm with no change. A composed struct that recurses into its children has its own, more specific method, which @propagatable makes from the @vprop tags or which the author writes by hand.

This method accepts and drops the threaded tail args... and all kwargs. The tail is usually the returns matrix X of the JuMP families. With this method, a call port_opt_view(child, i, X) that a macro makes never raises a MethodError on a leaf field.

Algorithm

  1. Drop args... and kwargs.... This method is the leaf of the recursion, so it passes nothing further.
  2. Return nothing_scalar_array_view of x at i. The algorithm of that function gives the rule for each leaf type.

Related

source
PortfolioOptimisers.factory — Method
factory(
    r::TurnoverRiskMeasure,
    w::AbstractVector{<:Union{Number, AbstractJuMPScalar}}
) -> TurnoverRiskMeasure

Return a TurnoverRiskMeasure whose reference weights are w.

When r.fixed is true, the function returns r and does not read w. Otherwise it rebuilds r with w as the reference weights, with rebuild_struct, and r.settings and r.fixed pass through unchanged.

Validation

Related

source
PortfolioOptimisers.factory — Method
factory(
    r::TurnoverRiskMeasure,
    ,
    ,
    ,
    w::AbstractVector{<:Union{Number, AbstractJuMPScalar}},
    args...;
    kwargs...
) -> TurnoverRiskMeasure

Return the TurnoverRiskMeasure whose reference weights are w, as factory(r, w) does.

The measure reads no moment, so the prior result, the solver and the uncertainty set in the second to fourth positions are not read. When w is nothing, the method on ::Nothing returns r unchanged. The method on a vector holds the rule of factory(r, w), and the two give one measure.

Related

source

References

[12]
D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).