Skip to content
5

Turnover

PortfolioOptimisers.TurnoverEstimator Type
julia
struct TurnoverEstimator{T1, T2, T3} <: AbstractEstimator
    w::T1
    val::T2
    default::T3
end

Estimator 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 in val.

Constructor

julia
TurnoverEstimator(; w::AbstractVector{<:Real},
                  val::Union{<:AbstractDict, <:Pair{<:AbstractString, <:Real},
                             <:AbstractVector{<:Pair{<:AbstractString, <:Real}}},
                  default::Real = 0.0)

Validation

Examples

julia
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.0

Related

source
PortfolioOptimisers.Turnover Type
julia
struct Turnover{T1, T2} <: AbstractResult
    w::T1
    val::T2
end

Container 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

julia
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) and val >= 0.

Examples

julia
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.02

Related

source
PortfolioOptimisers.turnover_constraints Function
julia
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: TurnoverEstimator specifying current weights, asset-specific turnover values, and default value.

  • sets: AssetSets containing asset names or indices.

  • strict: If true, enforces strict matching between assets and turnover values (throws error on mismatch); if false, issues a warning.

Returns

  • Turnover: Object containing portfolio weights and turnover values aligned with sets.

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 strict is true.

Examples

julia
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

source
julia
turnover_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 existing Turnover object.

  • args...: Additional positional arguments (ignored).

  • kwargs...: Additional keyword arguments (ignored).

Returns

  • tn::Union{Nothing, Turnover}: The input constraint object, unchanged.

Examples

julia
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

source
julia
turnover_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