Turnover
PortfolioOptimisers.TurnoverEstimator Type
struct TurnoverEstimator{T1, T2, T3} <: AbstractEstimator
w::T1
val::T2
default::T3
endEstimator for turnover portfolio constraints.
TurnoverEstimator specifies turnover constraints for each asset in a portfolio, based on current portfolio weights w, asset-specific turnover values val, and a default value for assets not explicitly specified. Supports asset-specific turnover via dictionaries, pairs, or vectors of pairs, and validates all inputs for non-emptiness, non-negativity, and finiteness.
Fields
w: Vector of current portfolio weights.val: Asset-specific turnover values, as a dictionary, pair, or vector of pairs.default: Default turnover value for assets not specified inval.
Constructor
TurnoverEstimator(; w::AbstractVector{<:Real},
val::Union{<:AbstractDict, <:Pair{<:AbstractString, <:Real},
<:AbstractVector{<:Pair{<:AbstractString, <:Real}}},
default::Real = 0.0)Validation
!isempty(w).valis validated withassert_nonneg_finite_val.
Examples
julia> TurnoverEstimator(; w = [0.2, 0.3, 0.5], val = Dict("A" => 0.1, "B" => 0.2), default = 0.0)
TurnoverEstimator
w ┼ Vector{Float64}: [0.2, 0.3, 0.5]
val ┼ Dict{String, Float64}: Dict("B" => 0.2, "A" => 0.1)
default ┴ Float64: 0.0Related
sourcePortfolioOptimisers.Turnover Type
struct Turnover{T1, T2} <: AbstractResult
w::T1
val::T2
endContainer for turnover portfolio constraints.
Turnover stores the portfolio weights and turnover constraint values for each asset. The turnover constraint can be specified as a scalar (applied to all assets) or as a vector of per-asset values. Input validation ensures all weights and turnover values are non-empty, non-negative, and finite.
Fields
w: Vector of portfolio weights.val: Scalar or vector of turnover constraint values.
Constructor
Turnover(; w::AbstractVector{<:Real}, val::Union{<:Real, <:AbstractVector{<:Real}} = 0.0)Validation
!isempty(w).val:AbstractVector:!isempty(val),length(w) == length(val),any(isfinite, val),all(x -> x >= 0, val).Real:isfinite(val)andval >= 0.
Examples
julia> Turnover(; w = [0.2, 0.3, 0.5], val = [0.1, 0.2, 0.0])
Turnover
w ┼ Vector{Float64}: [0.2, 0.3, 0.5]
val ┴ Vector{Float64}: [0.1, 0.2, 0.0]
julia> Turnover(; w = [0.2, 0.3, 0.5], val = 0.02)
Turnover
w ┼ Vector{Float64}: [0.2, 0.3, 0.5]
val ┴ Float64: 0.02Related
sourcePortfolioOptimisers.turnover_constraints Function
turnover_constraints(tn::TurnoverEstimator, sets::AssetSets; strict::Bool = false)Generate turnover portfolio constraints from a TurnoverEstimator and asset set.
turnover_constraints constructs a Turnover object representing turnover constraints for the assets in sets, using the specifications in tn. Supports scalar, vector, dictionary, pair, or custom turnover types for flexible assignment and validation.
Arguments
tn:TurnoverEstimatorspecifying current weights, asset-specific turnover values, and default value.sets:AssetSetscontaining asset names or indices.strict: Iftrue, enforces strict matching between assets and turnover values (throws error on mismatch); iffalse, issues a warning.
Returns
Turnover: Object containing portfolio weights and turnover values aligned withsets.
Details
Turnover values are extracted and mapped to assets using
estimator_to_val.If a turnover value is missing for an asset, assigns the default value unless
strictistrue.
Examples
julia> sets = AssetSets(; dict = Dict("nx" => ["A", "B", "C"]));
julia> tn = TurnoverEstimator([0.2, 0.3, 0.5], Dict("A" => 0.1, "B" => 0.2), 0.0);
julia> turnover_constraints(tn, sets)
Turnover
w ┼ Vector{Float64}: [0.2, 0.3, 0.5]
val ┴ Vector{Float64}: [0.1, 0.2, 0.0]Related
sourceturnover_constraints(tn::Union{Nothing, <:Turnover}, args...; kwargs...)Propagate or pass through turnover portfolio constraints.
turnover_constraints returns the input Turnover object unchanged or nothing. This method is used to propagate already constructed turnover constraints, enabling composability and uniform interface handling in constraint generation workflows.
Arguments
tn: An existingTurnoverobject.args...: Additional positional arguments (ignored).kwargs...: Additional keyword arguments (ignored).
Returns
tn::Union{Nothing, Turnover}: The input constraint object, unchanged.
Examples
julia> tn = Turnover(; w = [0.2, 0.3, 0.5], val = [0.1, 0.2, 0.0]);
julia> turnover_constraints(tn)
Turnover
w ┼ Vector{Float64}: [0.2, 0.3, 0.5]
val ┴ Vector{Float64}: [0.1, 0.2, 0.0]Related
sourceturnover_constraints(tn::Union{<:AbstractVector{<:TurnoverEstimator},
<:AbstractVector{<:Turnover},
<:AbstractVector{<:Union{<:TurnoverEstimator, <:Turnover}}},
sets::AssetSets; strict::Bool = false)Broadcasts threshold_constraints over the vector.
Provides a uniform interface for processing multiple constraint estimators simultaneously.
source