Tracking
PortfolioOptimisers.SOCTracking Type
struct SOCTracking{T1} <: NormTracking
ddof::T1
endSecond-order cone (SOC) norm-based tracking formulation.
SOCTracking implements a norm-based tracking error formulation using the Euclidean (L2) norm, scaled by the square root of the number of assets minus the degrees of freedom (ddof). This is commonly used for tracking error constraints and objectives in portfolio optimisation.
Fields
ddof: Degrees of freedom adjustment (integer, must be > 0).
Constructor
SOCTracking(; ddof::Integer = 1)Validation
ddof > 0.
Examples
julia> SOCTracking()
SOCTracking
ddof ┴ Int64: 1Related
sourcePortfolioOptimisers.NOCTracking Type
struct NOCTracking <: NormTracking endNorm-one (NOC) tracking formulation.
NOCTracking implements a norm-based tracking error formulation using the L1 (norm-one) distance between portfolio and benchmark weights. This is commonly used for tracking error constraints and objectives in portfolio optimisation where sparsity or absolute deviations are preferred.
Examples
julia> NOCTracking()
NOCTracking()Related
sourcePortfolioOptimisers.IndependentVariableTracking Type
struct IndependentVariableTracking <: VariableTracking endIndependent variable-based tracking formulation.
IndependentVariableTracking tracks the independent variables of a measurement.
Related
sourcePortfolioOptimisers.DependentVariableTracking Type
struct DependentVariableTracking <: VariableTracking endDependent variable-based tracking formulation.
DependentVariableTracking tracks the measurement.
Related
sourcePortfolioOptimisers.WeightsTracking Type
struct WeightsTracking{T1, T2} <: AbstractTrackingAlgorithm
fees::T1
w::T2
endAsset weights-based tracking algorithm.
WeightsTracking represents a tracking algorithm that operates directly on portfolio weights, optionally incorporating transaction fees. This is used for tracking error measurement and constraint generation where the comparison is made between portfolio weights and benchmark weights, with optional adjustment for fees.
Fields
fees: Optional fees estimator or result to apply to the weights tracking.w: Portfolio weights (vector of real numbers).
Constructor
WeightsTracking(; fees::Union{Nothing, <:Fees} = nothing, w::AbstractVector{<:Real})Validation
!isempty(w).
Examples
julia> WeightsTracking(; w = [0.5, 0.5])
WeightsTracking
fees ┼ nothing
w ┴ Vector{Float64}: [0.5, 0.5]Related
sourcePortfolioOptimisers.ReturnsTracking Type
struct ReturnsTracking{T1} <: AbstractTrackingAlgorithm
w::T1
endReturns-based tracking algorithm.
ReturnsTracking represents a tracking algorithm that operates directly on portfolio returns, rather than asset weights. This is used for tracking error measurement and constraint generation where the comparison is made between portfolio returns and benchmark returns.
Fields
w: Benchmark portfolio returns (vector of real numbers).
Constructor
ReturnsTracking(; w::AbstractVector{<:Real})Validation
!isempty(w).
Examples
julia> ReturnsTracking(; w = [0.01, 0.02, 0.03])
ReturnsTracking
w ┴ Vector{Float64}: [0.01, 0.02, 0.03]Related
sourcePortfolioOptimisers.TrackingError Type
struct TrackingError{T1, T2, T3} <: AbstractTracking
tracking::T1
err::T2
alg::T3
endTracking error result type.
TrackingError represents the result of a tracking error computation, including the tracking algorithm used, the computed error value, and the tracking formulation algorithm. This type is used to store and propagate tracking error results in portfolio analytics and optimisation workflows.
Fields
tracking: Tracking algorithm object.err: Tracking error value.alg: Tracking formulation algorithm.
Constructor
TrackingError(; tracking::AbstractTrackingAlgorithm, err::Real = 0.0,
alg::NormTracking = SOCTracking())Validation
isfinite(err)anderr >= 0.
Examples
julia> tracking = WeightsTracking(; w = [0.5, 0.5]);
julia> TrackingError(; tracking = tracking, err = 0.01)
TrackingError
tracking ┼ WeightsTracking
│ fees ┼ nothing
│ w ┴ Vector{Float64}: [0.5, 0.5]
err ┼ Float64: 0.01
alg ┼ SOCTracking
│ ddof ┴ Int64: 1Related
sourcePortfolioOptimisers.AbstractTracking Type
abstract type AbstractTracking <: AbstractResult endAbstract supertype for all tracking result types in PortfolioOptimisers.jl.
All concrete types representing tracking error or tracking constraint results should subtype AbstractTracking. This enables a consistent, composable interface for tracking error measurement, tracking constraint generation, and related portfolio analytics.
Related
sourcePortfolioOptimisers.AbstractTrackingAlgorithm Type
abstract type AbstractTrackingAlgorithm <: AbstractAlgorithm endAbstract supertype for all tracking algorithm types in PortfolioOptimisers.jl.
All concrete types representing tracking algorithms (such as weights or returns tracking) should subtype AbstractTrackingAlgorithm. This enables a consistent, composable interface for tracking error computation, tracking constraint generation, and related portfolio analytics.
Related
sourcePortfolioOptimisers.TrackingFormulation Type
abstract type TrackingFormulation <: AbstractAlgorithm endAbstract supertype for all tracking formulation algorithm types in PortfolioOptimisers.jl.
All concrete types representing tracking formulation algorithms (such as norm-based or variable-based tracking) should subtype TrackingFormulation. This enables a consistent, composable interface for tracking error computation, constraint generation, and related portfolio analytics.
Related
sourcePortfolioOptimisers.NormTracking Type
abstract type NormTracking <: TrackingFormulation endAbstract supertype for all norm-based tracking formulation algorithms in PortfolioOptimisers.jl.
All concrete types representing norm-based tracking algorithms (such as second-order cone or norm-one tracking) should subtype NormTracking. This enables a consistent, composable interface for tracking error computation and constraint generation using norm-based formulations.
Related
sourcePortfolioOptimisers.VariableTracking Type
abstract type VariableTracking <: TrackingFormulation endAbstract supertype for all variable-based tracking formulation algorithms in PortfolioOptimisers.jl.
All concrete types representing variable-based tracking algorithms (such as independent or dependent variable tracking) should subtype VariableTracking. This enables a consistent, composable interface for tracking error computation and constraint generation using variable-based formulations.
Related
sourcePortfolioOptimisers.norm_tracking Function
norm_tracking(f::SOCTracking, a, b; N::Union{Nothing, <:Real} = nothing)
norm_tracking(::NOCTracking, a, b; N::Union{Nothing, <:Real} = nothing)Compute the norm-based tracking error between portfolio and benchmark weights.
norm_tracking calculates the tracking error using either the Euclidean (L2) norm for SOCTracking or the L1 (norm-one) distance for NOCTracking. The error is optionally scaled by the number of assets and degrees of freedom for SOC, or by the number of assets for NOC.
Arguments
f: Tracking formulation algorithm.a: Portfolio weights.b: Benchmark weights.N: Optional number of assets.
Returns
err::Real: Norm-based tracking error.
Details
For
SOCTracking, computesnorm(a - b, 2) / sqrt(N - f.ddof)ifNis provided, else unscaled.For
NOCTracking, computesnorm(a - b, 1) / NifNis provided, else unscaled.
Examples
julia> PortfolioOptimisers.norm_tracking(SOCTracking(), [0.5, 0.5], [0.6, 0.4], 2)
0.14142135623730948
julia> PortfolioOptimisers.norm_tracking(NOCTracking(), [0.5, 0.5], [0.6, 0.4], 2)
0.09999999999999998Related
sourcePortfolioOptimisers.tracking_benchmark Function
tracking_benchmark(tracking::WeightsTracking, X::AbstractMatrix{<:Real})Compute the benchmark portfolio returns for a weights-based tracking algorithm.
tracking_benchmark calculates the net portfolio returns for the benchmark weights stored in a WeightsTracking object, optionally adjusting for transaction fees if specified. The asset return matrix X is multiplied by the benchmark weights, and fees are deducted if present.
Arguments
tracking:WeightsTrackingtracking algorithm containing benchmark weights and optional fees.X: Asset return matrix (assets × periods).
Returns
Vector{<:Real}: Net benchmark portfolio returns.
Details
If
tracking.feesis provided, net returns are computed usingcalc_net_returns.Otherwise, returns are computed as
X * tracking.w.
Examples
julia> tracking = WeightsTracking(; w = [0.5, 0.5]);
julia> X = [0.01 0.02; 0.03 0.04];
julia> PortfolioOptimisers.tracking_benchmark(tracking, X)
2-element Vector{Float64}:
0.015
0.035Related
sourcetracking_benchmark(tracking::ReturnsTracking, args...)Return the benchmark portfolio returns for a returns-based tracking algorithm.
tracking_benchmark extracts the benchmark portfolio returns stored in a ReturnsTracking object. This is used for tracking error measurement and constraint generation where the comparison is made directly between portfolio returns and benchmark returns.
Arguments
tracking:ReturnsTrackingtracking algorithm containing benchmark returns.args...: For interface compatibility (ignored).
Returns
Vector{<:Real}: Benchmark portfolio returns.
Examples
julia> tracking = ReturnsTracking(; w = [0.01, 0.02, 0.03]);
julia> PortfolioOptimisers.tracking_benchmark(tracking)
3-element Vector{Float64}:
0.01
0.02
0.03Related
source