Tracking Error Constraints: private API
PortfolioOptimisers.set_tracking_error_constraints! — Function
set_tracking_error_constraints!(model::JuMP.Model, pr::Option{<:AbstractPriorResult}, ::Nothing, args...; kwargs...)
set_tracking_error_constraints!(model::JuMP.Model, pr::AbstractPriorResult, tres::Tr_VecTr, args...; kwargs...)
set_tracking_error_constraints!(model::JuMP.Model, i::Integer, pr::AbstractPriorResult, tr, args...; prefix::Symbol = Symbol(""), kwargs...)Add tracking error constraints to the JuMP optimisation model.
The method on tres = nothing adds no row. A tracking error whose type or norm has no method is a MethodError. The methods on one tracking error dispatch on the tracking algorithm type:
L1Norm: Enforces‖net_X - wb * k‖₁ ≤ err * (T - ddof)via NormOneCone.L2Norm: Enforces a scaled L2 norm via SecondOrderCone.SquaredL2Norm: The same cone, with the bound square-rooted, becauseerrbounds the squared error thatnorm_errorreports.LpNorm: Enforces a scaled Lp norm via power cone.LInfNorm: Enforces‖net_X - wb * k‖_∞ ≤ errvia NormInfinityCone.IndependentVariableTracking: Substitutesw - wbforwand applies the chosen risk constraint.DependentVariableTracking: Constrains the difference between portfolio risk and benchmark risk. The inner build reads the lifted matrix of the head's weights,weights_prefix. The bound holds from above only, $R(\boldsymbol{w}) \leq R(\boldsymbol{w}_b) + \mathrm{err}$, for every inner measure whose model is an upper bound on the risk, asDependentVariableTrackingstates. A portfolio whose risk is below the benchmark risk by more thanerralso satisfies it.
The collection method iterates over all tracking errors in tres.
Mathematical definition
\[\begin{align} t_{tr} &\geq \lVert \mathbf{X}\boldsymbol{w} - \boldsymbol{b} k \rVert_p \cdot c_p^{-1}\,, \\ t_{tr} &\leq \mathrm{err} \cdot k\,. \end{align}\]
Where:
- $t_{tr}$: Auxiliary tracking error scalar variable.
- $\mathbf{X}$: Asset returns matrix ($T \times N$).
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
- $\boldsymbol{b}$: Benchmark return vector.
- $k$: Variable that scales the budget in the homogenised problem.
- $p$: Norm order.
- $c_p$: Norm-specific scaling factor,
norm_factorof the norm ($T - d$, $\sqrt{T - d}$, $1$, etc.). - $\mathrm{err}$: Tracking error tolerance.
Arguments
model::JuMP.Model: The JuMP optimisation model.i::Integer: Constraint index for generating unique variable and constraint names.pr::AbstractPriorResult: Prior result providing the return matrixX.tr: Tracking error specification.tres: One tracking error, a vector of them, ornothing.opt: TheRiskConstraintOwnerwhose programme the constraint joins, read by the risk-based variants for the solver a Deferred Quantity is resolved against (risk_constraint_solver).pl: Optional phylogeny constraints.fees: Optional fees structure.prefix::Symbol: The Model State namespace the entries are registered under,Symbol("")for a head's own, so a programme Allocation Set's tracking error joins a leader's model beside the head's own under the namespace of its block,blk_2_. The net returnsX ware formed under the same prefix, over the rows ofprand their count.
Returns
nothing.
Related
PortfolioOptimisers.tracking_error_soc_factor — Function
tracking_error_soc_factor(
f::L2Norm,
err::Number,
T::Integer
) -> Any
Convert a TrackingError tolerance into the bound on the second-order cone variable.
Both norms share one cone, which bounds $\lVert \mathbf{X}\boldsymbol{w} - \boldsymbol{b}k \rVert_2$. They do not share the quantity that err bounds. norm_error divides that norm by $\sqrt{T - d}$ for an L2Norm and squares it before dividing by $T - d$ for a SquaredL2Norm, so the second bound is square-rooted here to keep the model, the functor and set_risk_constraints! in agreement.
Arguments
f: TheNormErrorthe tracking error carries.err::Number: Tracking error tolerance.T::Integer: Number of observations.
Returns
f::Number: Upper bound on the cone variable, before the budget scaling by $k$.
Related
PortfolioOptimisers.tracking_benchmark_expression — Function
tracking_benchmark_expression(model::JuMP.Model, b::VecNum, prefix::Symbol)
tracking_benchmark_expression(model::JuMP.Model, B::MatNum, prefix::Symbol)Return the benchmark return series that a tracking constraint subtracts from the net portfolio returns.
The model states the weights scaled by the budget variable $k$, so both forms carry that scale and stay linear in the weights.
- A series is fixed, so it scales with the budget variable: $\boldsymbol{b}k$.
- A matrix holds one benchmark per asset, the bound benchmark of a
DataBenchmarkTracking, so the series is $\mathbf{B}\boldsymbol{w}$ on the weights of the model underprefix. These are the weights of the net portfolio returns under the sameprefix, and they carry the scale already.
Arguments
model::JuMP.Model: The JuMP optimisation model.b,B: The benchmark thattracking_benchmarkreturns.prefix::Symbol: The Model State namespace of the weights.
Returns
- The benchmark return series, a vector of affine expressions with one entry per row.
Related
set_tracking_error_constraints!DataBenchmarkTrackingcollapse_benchmark: The same rule on a numeric weight vector.