OWA risk measures (a): private API
PortfolioOptimisers.AbstractOrderedWeightsArrayEstimator — Type
abstract type AbstractOrderedWeightsArrayEstimator <: AbstractEstimatorAbstract supertype for the estimators of the risk aversion coefficients of an L-moment OWA weight vector.
owa_l_moment_crm dispatches on the subtype. NormalisedConstantRelativeRiskAversion states the coefficients in closed form, and OWAJuMP solves a programme for them.
Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.AbstractOrderedWeightsArrayAlgorithm — Type
abstract type AbstractOrderedWeightsArrayAlgorithm <: AbstractAlgorithmAbstract supertype for the objectives of the programme that OWAJuMP solves for an L-moment OWA weight vector.
Every subtype solves over the same feasible set, which owa_l_moment_crm states. The subtype selects the objective alone.
Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.SquaredOrderedWeightsArrayAlgorithm — Type
abstract type SquaredOrderedWeightsArrayAlgorithm{T} <: AbstractOrderedWeightsArrayAlgorithmAbstract supertype for the quadratic objectives of the L-moment programme of OWAJuMP.
Each subtype minimises a sum of squares of the OWA weights. The parameter T is the type of the conic encoding of that sum, a second-order cone risk expression. owa_l_moment_crm_sumsq_obj dispatches on it.
Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.UnionAllSOCRiskExpr — Type
const UnionAllSOCRiskExpr = Union{SquaredSOCRiskExpr, RSOCRiskExpr, SOCRiskExpr}The three conic encodings of the objective of a SquaredOrderedWeightsArrayAlgorithm.
MinimumSquaredDistance and MinimumSumSquares accept each of them in alg. The three encodings give one minimiser, so the choice changes the model and not the OWA weights.
Related
PortfolioOptimisers.UnionSOCRiskExpr — Type
const UnionSOCRiskExpr = Union{SquaredSOCRiskExpr, SOCRiskExpr}The encodings that bound the objective norm with one second-order cone.
The methods of owa_l_moment_crm for these encodings write the row t ≥ ‖v‖₂. RSOCRiskExpr is not a member, because it writes a rotated cone.
Related
PortfolioOptimisers.UnionRSOCSOCRiskExpr — Type
const UnionRSOCSOCRiskExpr = Union{RSOCRiskExpr, SOCRiskExpr}The encodings whose objective is linear in the cone variable t.
owa_l_moment_crm_sumsq_obj minimises so * t for these encodings. SquaredSOCRiskExpr is not a member, because it minimises so * t^2.
Related
PortfolioOptimisers.EntropyFormulation — Type
abstract type EntropyFormulation <: AbstractAlgorithmAbstract supertype for the conic encodings of the entropy objective of MaximumEntropy.
The encoding changes the cones of the model, not the problem. owa_l_moment_crm_entropy states the rows of each encoding.
Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.OWA_Func_VecNum — Type
const OWA_Func_VecNum = Union{Func_VecNum, AbstractOrderedWeightsArrayFunction}The values that a weight slot of OrderedWeightsArray or OrderedWeightsArrayRange accepts.
A weight vector fixes the sample size. A function or an AbstractOrderedWeightsArrayFunction is called at the sample size, so one measure serves a sample of any length. Only a builder can hold a Calibration Rule.
Related
PortfolioOptimisers.OrderedWeightsArrayFormulation — Type
abstract type OrderedWeightsArrayFormulation <: AbstractAlgorithmAbstract supertype for the JuMP encodings of an OWA risk measure.
The OWA risk sorts the returns, and a convex programme cannot sort its variables. ExactOrderedWeightsArray and SortingNetworkOrderedWeightsArray encode the sort exactly, at two different costs. ApproxOrderedWeightsArray drops the sort and gives an upper bound. The functor of the measure sorts the returns itself and does not read the formulation.
Related
ExactOrderedWeightsArraySortingNetworkOrderedWeightsArrayApproxOrderedWeightsArrayOrderedWeightsArrayOrderedWeightsArrayRange
References
- [209] W. Ogryczak and T. Śliwiński. On solving linear programs with the ordered weighted averaging objective. European Journal of Operational Research 148, 80–91 (2003).
- [199] D. Cajas. OWA portfolio optimization: A disciplined convex programming framework. Available at SSRN 3988927 (2021).
- [207] D. Cajas. Efficient Gini Mean Difference and Tail Gini Portfolio Optimization based on P-Norms. Available at SSRN 4711326 (2024).
- [12] D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025). Section 7.1.5.
PortfolioOptimisers.assert_owa_formulation_weights — Method
assert_owa_formulation_weights(
_::OrderedWeightsArrayFormulation,
_::AbstractVector{<:Union{Number, AbstractJuMPScalar}}
)
Refuse an OWA weight vector w that the formulation alg cannot optimise.
The exact and the approximate formulations accept every weight vector, so this method returns nothing. A formulation that needs a property of the vector adds a method that checks it.
Arguments
alg: OWA formulation of the risk measure.w: OWA weight vector, after the range measure reverses its second vector.
Returns
nothing.
Related
PortfolioOptimisers.OWA_RevFunc — Type
const OWA_RevFunc = ComposedFunction{typeof(reverse),
<:AbstractOrderedWeightsArrayFunction}The reversal of an ordered-weights builder, which is what OrderedWeightsArrayRange stores in w2 under the approximate formulation.
It is a Function and it computes no quantity, so it is the one occupant of a weight slot that a reader of the calibration channel must part from a Calibration Rule. The name is written once here, because the type is long and three sites read it.
Related
PortfolioOptimisers.OWA_CalOccupant — Type
const OWA_CalOccupant = Union{AbstractOrderedWeightsArrayFunction, OWA_RevFunc}The occupants of an OrderedWeightsArray weight slot that carry a calibration slot of their own: a weight builder, and the reversal of one that the Range container builds.
The slot also takes a weight vector and a caller's own plain function, and neither carries a slot, so calibration_slots names neither. Everywhere else in the library, a plain function in a calibration slot is a Calibration Rule. The rule is what resolve_calibration_slot calls and what assert_calibrated_slots refuses, so a weight builder written as a plain function must not reach either.
Related
PortfolioOptimisers.owa_constraint_scale — Function
owa_constraint_scale(sc::Option{<:Number}, alg::AbstractOrderedWeightsArrayAlgorithm)Return the constraint scale of the L-moment programme of OWAJuMP.
A stated sc wins. When sc is nothing, the objective alg gives the scale, so each objective can set the value that its programme solves at. Every objective gives 1.0 now.
Arguments
sc: Thescfield ofOWAJuMP.alg: The objective of the programme.
Returns
sc::Number: The constraint scale.
Examples
julia> PortfolioOptimisers.owa_constraint_scale(nothing, MaximumEntropy())1.0julia> PortfolioOptimisers.owa_constraint_scale(2.0, MaximumEntropy())2.0Related
PortfolioOptimisers.owa_objective_scale — Function
owa_objective_scale(so::Option{<:Number}, alg::AbstractOrderedWeightsArrayAlgorithm)Return the objective scale of the L-moment programme of OWAJuMP.
A stated so wins. When so is nothing, the objective alg gives the scale, so each objective can set the value that its programme solves at. MaximumEntropy gives 1e-3, and its docstring states why. The other objectives give 1.0.
Arguments
so: Thesofield ofOWAJuMP.alg: The objective of the programme.
Returns
so::Number: The objective scale.
Examples
julia> PortfolioOptimisers.owa_objective_scale(nothing, MaximumEntropy())0.001julia> PortfolioOptimisers.owa_objective_scale(nothing, MinimumSumSquares())1.0julia> PortfolioOptimisers.owa_objective_scale(2.0, MaximumEntropy())2.0Related
PortfolioOptimisers.owa_l_moment_crm_sumsq_obj — Function
owa_l_moment_crm_sumsq_obj(method::OWAJuMP{<:Any, <:Any, <:Any, <:Any,
<:SquaredOrderedWeightsArrayAlgorithm},
model::JuMP.Model)Set the objective of a SquaredOrderedWeightsArrayAlgorithm programme on model.
owa_l_moment_crm adds the cone row that bounds the variable t. This method sets the objective alone, and it dispatches on the SecondMomentFormulation that parameterises method.alg. It does not solve the model. The three encodings give one minimiser, so they return the same OWA weights to solver tolerance.
JuMP formulation
Variables
t: Read, the scalar that the cone row of the caller bounds.
Objective
- Under
SOCRiskExprorRSOCRiskExpr:Minof $s_o t$. - Under
SquaredSOCRiskExpr:Minof $s_o t^{2}$, because the cone row of the caller bounds $t$ by a norm, not by its square.
Where:
- $s_o$: Objective scale. It multiplies the objective, so a positive value leaves the argument of the optimum unchanged.
owa_objective_scalegives it from thesofield ofmethod.
Arguments
method: Programme of the coefficients, whosealgis aMinimumSquaredDistanceor aMinimumSumSquares.model::JuMP.Model: Model ofowa_l_moment_crm, which holds the variabletand its cone row.
Returns
- The objective function that the method sets on
model. The function changesmodelin place.
Related
MinimumSquaredDistanceMinimumSumSquaresSquaredOrderedWeightsArrayAlgorithmowa_model_setupowa_l_moment_crmowa_l_moment_crm_entropy
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.ncrra_weights — Function
ncrra_weights(weights::MatNum, g::Number = 0.5)Compute the OWA weight vector of the normalised constant relative risk aversion coefficients of g.
Column j of weights takes the coefficient of the L-moment of order j + 1, so the columns of the signed L-moment weight matrix give the vector that NormalisedConstantRelativeRiskAversion states. The coefficients sum to one, and the returned weights do not. The returned vector is the running maximum of a combination of the columns, so its sum is at least the same combination of the column sums.
Mathematical definition
\[\begin{align} \tilde{\phi}_{j} &= \dfrac{1}{(j + 1)!} \prod\limits_{i=0}^{j-1} \left(\gamma + i\right) \quad \forall j = 1,\, \ldots,\, M\\ \phi_{j} &= \dfrac{\tilde{\phi}_{j}}{\sum_{i=1}^{M} \tilde{\phi}_{i}}\\ \boldsymbol{\vartheta} &= \mathbf{V} \boldsymbol{\phi}\\ \eta_{t} &= \max\limits_{s \leq t} \vartheta_{s} \quad \forall t = 1,\, \ldots,\, T\,. \end{align}\]
Where:
- $\gamma$: Relative risk aversion
gof the normalised constant relative risk aversion coefficients, $\gamma \in (0, 1)$. - $\mathbf{V}$: The matrix
weights, $T \times M$. - $\tilde{\phi}_{j}$, $\phi_{j}$: Coefficient of column $j$ before and after the normalisation.
- $\boldsymbol{\vartheta}$: Combination of the columns of $\mathbf{V}$, $T \times 1$.
- $\boldsymbol{\eta}$: OWA weight vector $T \times 1$. Its $t$-th entry $\eta_{t}$ multiplies the $t$-th smallest return.
Algorithm
- Set the running product
e = 1. For each columniofweights, multiplyebyg + i - 1, and setphis[i] = e / factorial(i + 1). - Divide
phisby its sum. - Compute the combination
a = weights * phis. - Set
w[i]to the largest entry ofa[1:i], for eachi.
Arguments
weights: Matrix $T \times M$ of signed L-moment weights, one column for each order from two up.g: Relative risk aversion.
Returns
w::VecNum: Nondecreasing vector of OWA weights of lengthsize(weights, 1).
Examples
julia> w = [1.0 0.5; 0.5 1.0]2×2 Matrix{Float64}: 1.0 0.5 0.5 1.0julia> PortfolioOptimisers.ncrra_weights(w, 0.5)2-element Vector{Float64}: 0.8333333333333333 0.8333333333333333Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023). Section 3.2, Equation 12.
PortfolioOptimisers.owa_model_setup — Function
owa_model_setup(method::OWAJuMP, weights::MatNum)Build the feasible set of the L-moment programme of OWAJuMP in a new JuMP model.
The model holds the risk aversion coefficients phi and the OWA weights theta, and the rows that every objective of AbstractOrderedWeightsArrayAlgorithm shares. It has no objective and no optimiser. owa_l_moment_crm adds the objective, and owa_model_solve solves the model.
JuMP formulation
Variables
theta: Created, the OWA weights $\boldsymbol{\theta}$, $T \times 1$.phi: Created, the risk aversion coefficients $\boldsymbol{\phi}$, $(K - 1) \times 1$.
Constraints
Every row is registered under no name.
- $s_c \boldsymbol{\phi} \geq 0$.
- $s_c (\boldsymbol{\phi} - \phi_{\max}) \leq 0$.
- $s_c \left(\sum_{k=2}^{K} \phi_{k} - 1\right) = 0$.
- $s_c (\boldsymbol{\theta} - \mathbf{W} \boldsymbol{\phi}) = 0$.
- $s_c (\phi_{k+1} - \phi_{k}) \leq 0$ for $k = 2, \ldots, K - 1$.
- $s_c (\theta_{t+1} - \theta_{t}) \geq 0$ for $t = 1, \ldots, T - 1$.
Where:
- $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
owa_constraint_scalegives it from thescfield ofmethod. - $\boldsymbol{\theta}$: Solved OWA weight vector $T \times 1$, the model variable
theta. - $\phi_{k}$: Risk aversion coefficient of the $k$-th L-moment, for $k = 2, \ldots, K$.
- $\phi_{\max}$: Ceiling on each risk aversion coefficient, the
max_phifield ofOWAJuMP. - $\mathbf{W}$: Signed L-moment weight matrix $T \times (K - 1)$. Its column $k - 1$ is $(-1)^{k} \boldsymbol{\omega}^{k}$ for $k = 2, \ldots, K$. It is the matrix
weights. - $\omega_{i}^{k}$: L-moment weight of the $i$-th smallest observation in the $k$-th sample L-moment, the $i$-th entry of
owa_l_moment(T, k). - $K$: Highest L-moment order, the
kofowa_l_moment_crm. - $T$: Number of observations.
Arguments
method: Programme of the coefficients. The function readsmax_phi,scandalg.weights: Signed L-moment weight matrix $T \times (K - 1)$.
Returns
model::JuMP.Model: The model of the feasible set.
Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023). Section 3.2, Equations 13 to 15.
PortfolioOptimisers.owa_model_solve — Function
owa_model_solve(model::JuMP.Model, method::OWAJuMP, weights::MatNum)Solve the L-moment programme in model, and return its OWA weights.
The returned weights are the value of the variable theta, which owa_model_setup holds equal to weights * phi. The model holds the coefficients phi to a sum of one, not theta.
The programme is infeasible for some combinations of the sample size, the highest order and max_phi, and the function then returns the fallback. These are the cases with the default max_phi = 0.5, measured with a linear programme that maximises the smallest step of the OWA weights:
- At the highest order
2it is always infeasible, because the one coefficient must equal one, andmax_phi < 1. - At the highest order
3the rows leave the one choice $\boldsymbol{\phi} = (0.5, 0.5)$, and its OWA weights decrease near the largest return. It is infeasible at every sample size measured: 3 to 300, 1000 and 5000 observations. - At the highest order
4it is infeasible up to 21 observations, and feasible at every sample size measured from 22 to 80, 100 and 1000 observations. - At each highest order
kfrom5to8it is feasible at every sample size measured, fromkto 80 observations.
Algorithm
- Optimise
modelwith the solvers ofmethod.slv, throughoptimise_JuMP_model!. - If the solve succeeds, return
w, the value ofmodel[:theta]. - Otherwise, warn, and return
w = ncrra_weights(weights, 0.5).
Arguments
model: Model of the programme, with its objective set.method: Programme of the coefficients. The function readsslv.weights: Signed L-moment weight matrix $T \times (K - 1)$, for the fallback.
Returns
w::VecNum: Vector of OWA weights of lengthsize(weights, 1).
Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
PortfolioOptimisers.owa_l_moment_crm_entropy — Function
owa_l_moment_crm_entropy(method::OWAJuMP{<:Any, <:Any, <:Any, <:Any, <:MaximumEntropy},
model::JuMP.Model)Add the entropy objective of the MaximumEntropy programme to model.
The method dispatches on the EntropyFormulation in method.alg.alg. It reads the risk aversion coefficients phi, adds the variable and the cone rows that bound their entropy, and sets the objective. It does not solve the model.
The two encodings state one problem. Under ExponentialConeEntropy the objective is the entropy less $\log s_c$, because the cones hold $s_c \phi_{k}$ and the coefficients sum to one. So the objective values differ when $s_c \neq 1$, and the maximiser does not. MaximumEntropy states why the programme needs a small $s_o$.
JuMP formulation
Variables
phi: Read, the risk aversion coefficients $\boldsymbol{\phi}$ thatowa_model_setupcreates.t: Created. UnderRelativeEntropyit is a scalar, and underExponentialConeEntropyit is a vector $(K - 1) \times 1$.
Constraints
Every row is registered under no name.
- Under
RelativeEntropy: $(s_c t,\, s_c \boldsymbol{1},\, s_c \boldsymbol{\phi}) \in \mathcal{K}_{\mathrm{rel}}$, which states $t \geq \sum_{k=2}^{K} \phi_{k} \log \phi_{k}$. - Under
ExponentialConeEntropy: $(s_c t_{k},\, s_c \phi_{k},\, 1) \in \mathcal{K}_{\exp}$ for each $k$, which states $t_{k} \leq -\phi_{k} \log(s_c \phi_{k})$.
Objective
- Under
RelativeEntropy:Maxof $-s_o t$. - Under
ExponentialConeEntropy:Maxof $s_o \sum_{k=2}^{K} t_{k}$.
Where:
- $\phi_{k}$: Risk aversion coefficient of the $k$-th L-moment, for $k = 2, \ldots, K$.
- $\boldsymbol{\theta}$: Solved OWA weight vector $T \times 1$, the model variable
theta. - $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
owa_constraint_scalegives it from thescfield ofmethod. - $s_o$: Objective scale. It multiplies the objective, so a positive value leaves the argument of the optimum unchanged.
owa_objective_scalegives it from thesofield ofmethod. - $\mathcal{K}_{\mathrm{rel}} = \{(u, \boldsymbol{v}, \boldsymbol{z}) : u \geq \sum_{i} z_{i} \log(z_{i} / v_{i}),\, \boldsymbol{v}, \boldsymbol{z} \geq 0\}$: Relative entropy cone.
- $\mathcal{K}_{\exp} = \mathrm{cl}\,\{(a,b,c) : b\, e^{a/b} \leq c,\, b > 0\}$: Exponential cone.
- $K$: Highest L-moment order, the
kofowa_l_moment_crm. - $T$: Number of observations.
Arguments
method: Programme of the coefficients, whosealgis aMaximumEntropy.model::JuMP.Model: Model ofowa_l_moment_crm, which holds the variablephi.
Returns
nothing. The function changesmodelin place.
Related
References
- [208] D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
References
- [12]
- D. Cajas. Advanced Portfolio Optimization: A Cutting-edge Quantitative Approach (Springer Nature Switzerland, 2025).
- [199]
- D. Cajas. OWA portfolio optimization: A disciplined convex programming framework. Available at SSRN 3988927 (2021).
- [207]
- D. Cajas. Efficient Gini Mean Difference and Tail Gini Portfolio Optimization based on P-Norms. Available at SSRN 4711326 (2024).
- [208]
- D. Cajas. Higher order moment portfolio optimization with L-moments. Available at SSRN 4393155 (2023).
- [209]
- W. Ogryczak and T. Śliwiński. On solving linear programs with the ordered weighted averaging objective. European Journal of Operational Research 148, 80–91 (2003).