Variance Constraints
PortfolioOptimisers.variance_risk_bounds_val — Function
variance_risk_bounds_val(
bound::FrontierBoundEstimator,
ub::Frontier
) -> Frontier{_A, Int64, __T_bound} where {_A, __T_bound<:FrontierBoundEstimator}
Convert a bound into the units of the expression that it acts on.
A caller states the bound of a second moment in the units of the measure. A formulation whose bound expression is the square root takes the square root of the bound, and a formulation whose bound expression is the square takes its square.
LinearBound: The bound, unchanged.SquareRootBound: The square root of the bound, entry by entry for a vector.SquaredBound: The square of the bound, entry by entry for a vector.
A Frontier keeps its N, and takes bound as its FrontierBoundEstimator with a factor of 1. The frontier solve converts the ends of its span when it builds the sweep. nothing gives nothing.
Arguments
bound::FrontierBoundEstimator: The conversion.ub: The bound, a number, a vector, aFrontierornothing.
Returns
- The converted bound, or
nothingwhenubisnothing.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::StandardDeviation,
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::Union{Nothing, AbstractPriorResult},
args...;
prefix,
kwargs...
) -> VariableRef
Add a standard deviation to model, bound it by settings.ub, and add it to the risk that the objective reads.
The standard deviation has degree one in the weights, so its bound settings.ub is in the units of a standard deviation and acts on sd_risk_ directly.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::StandardDeviation: The measure.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr: Prior result.
Returns
sd_risk: The standard-deviation variable.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::Variance,
opt::Union{AbstractProgrammeAllocationSet, MeanRisk, NearOptimalCentering, RiskBudgeting},
pr::Union{Nothing, AbstractPriorResult},
pl::Union{Nothing, AbstractPhylogenyConstraintResult, AbstractVector{<:AbstractPhylogenyConstraintResult}},
args...;
prefix,
kwargs...
) -> Any
Add a variance to model, bound it by settings.ub, and add it to the risk that the objective reads.
The bound settings.ub is in the units of a variance. variance_risk_bounds_expr names the expression of degree one that it acts on, and variance_risk_bounds_val converts it to the units of that expression.
When the variance is a positive term of the objective's risk, the builder marks variance_flag on the namespace that owns the weights, mark_objective_variance!. A semidefinite phylogeny on the same weights then adds no p · tr(W) penalty when the objective minimises the risk. A variance that is only a bound does not mark the flag, and the penalty stays. sdp_variance_flag! selects the formulation, and the source of the covariance matrix, the measure or the prior, does not change it. A measure that holds its matrix reads no prior, so a programme Allocation Set that reads no rows passes pr = nothing.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::Variance: The measure.opt::RiskBoundOwner: The owner of the constraint.pr: The prior result, ornothingwhenrholds its covariance matrix and has no risk-contribution rows.pl: Optional phylogeny constraints.
Returns
variance_risk: The variance expression.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::Variance,
opt::FactorRiskContribution,
pr::AbstractPriorResult,
,
,
b::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
args...;
prefix,
kwargs...
) -> Any
Add a variance to the model of a FactorRiskContribution, always in the semidefinite formulation over the decision vector.
The asset weights are $\boldsymbol{w} = \mathbf{P} \boldsymbol{z}$. With flag = false the decision vector is the factor weights, $\boldsymbol{z} = \boldsymbol{w}_1$ and $\mathbf{P} = \mathbf{B}_1$, which is formulation 16 of [190]. With flag = true it holds the off-factor weights too, $\boldsymbol{z} = [\boldsymbol{w}_1; \boldsymbol{w}_2]$ and $\mathbf{P} = [\mathbf{B}_1\ \mathbf{B}_2]$. $\mathbf{P}$ is then square and invertible, so the problem is the asset formulation of Variance in the basis of the factors. The model lifts $\boldsymbol{z}$ into $\mathbf{W}_z$, and the variance is the trace of $\mathbf{P}^\intercal \mathbf{\Sigma} \mathbf{P} \mathbf{W}_z$. At rank one it is the variance of the returned weights under either value of flag.
The risk-contribution rows of r.rc read the diagonal of sigma_W_, one entry for each factor. At rank one entry $j$ is $[\boldsymbol{w}_1]_j [\mathbf{B}_1^\intercal \mathbf{\Sigma} \boldsymbol{w}]_j$, the Euler contribution of factor $j$ that factor_risk_contribution reports, and the rows state it as a share of the whole variance. The off-factor weights take no row, and their contribution is the remainder.
When sdp_objective_lift_flag is true, under MaximumRatio with SquareRootRatio, the objective term and the rows read $\mathbf{W}_c$ of set_sdp_frc_objective_lift! in place of $\mathbf{W}_z$, so the term has degree two and the model maximises the Sharpe ratio. The bound reads $\mathbf{W}_z$, and the method builds that trace only when settings.ub holds a bound.
JuMP formulation
Variables
frc_W: read, $\mathbf{W}_z$, the lifted matrix thatset_sdp_frc_constraints!builds once.lift_frc_W: read under the lift of the objective, $\mathbf{W}_c$.
Expressions
sigma_W_: $\mathbf{B}_1^\intercal \mathbf{\Sigma} \mathbf{P} \mathbf{W}_z$, the $N_f$ rows of the factors, registered without the lift of the objective.variance_risk_: $\mathrm{Tr}(\mathbf{P}^\intercal \mathbf{\Sigma} \mathbf{P} \mathbf{W}_z)$, registered without the lift of the objective, and with it whensettings.ubholds a bound.lift_sigma_W_,lift_variance_risk_: the same two expressions on $\mathbf{W}_c$, registered under the lift of the objective.
Each name carries the index i of the measure, and the namespace prefix.
Where:
- $\boldsymbol{z}$: The decision vector, $\boldsymbol{w}_1$ or $[\boldsymbol{w}_1; \boldsymbol{w}_2]$.
- $\mathbf{W}_z$: Lifted matrix of the decision vector, symmetric, with $\mathbf{W}_z \succeq \boldsymbol{z} \boldsymbol{z}^\intercal / k$.
- $\mathbf{P}$: The basis of the decision vector,
b. - $\mathbf{B}_1$: The pseudoinverse of $\mathbf{B}^\intercal$, the first $N_f$ columns of $\mathbf{P}$.
- $\mathbf{B}_2$: The basis of the off-factor directions.
- $\boldsymbol{w}_2$: The off-factor weights.
- $\mathbf{B}$: Loading matrix, of size $N \times N_{f}$.
- $\boldsymbol{w}_1$: Factor weights of
FactorRiskContribution, one entry for each of the $N_f$ factors. The asset weights are $\mathbf{B}_1 \boldsymbol{w}_1$, with $\mathbf{B}_1$ the pseudoinverse of $\mathbf{B}^\intercal$, plus an off-factor block whenflag = true. - $\mathbf{\Sigma}$: Covariance matrix of the risk measure, $N \times N$. It is the measure's own matrix when the measure states one, and the prior's otherwise.
- $k$: Variable that scales the budget in the homogenised problem.
Relaxation
The encoding is not exact: the entries below bound the quantity instead of reproducing it, and the bound is tight only under the condition stated here.
variance_risk_lies at or above $\boldsymbol{w}^\intercal \mathbf{\Sigma} \boldsymbol{w} / k$. It is tight at $\mathbf{W}_z = \boldsymbol{z} \boldsymbol{z}^\intercal / k$, andrc_variance_constraints!states the condition for its rows.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::Variance: The measure.opt::FactorRiskContribution: The optimisation estimator.pr: Prior result.b::MatNum: $\mathbf{P}$, the basis that maps the decision vector to the asset weights.
Returns
variance_risk: The variance expression.
Related
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
model::Model,
i,
r::UncertaintySetVariance,
opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
pr::AbstractPriorResult,
args...;
prefix,
rd,
kwargs...
) -> Any
Add the worst-case variance of an uncertainty set to model, bound it by settings.ub, and add it to the risk that the objective reads.
The set is the measure's own ucs, fitted with sigma_ucs when it is an estimator. The fit reads the optimisation's returns rd and its prior, because an AbstractPriorUncertaintySetEstimator fits from the prior result, and an estimator that carries its own pe drops it. The centre falls back to the measure's sigma and then to the prior's. The bound settings.ub is in the units of a variance, and ucs_variance_risk_bounds! names the expression of degree one that it acts on.
When sdp_lifted_set and sdp_objective_lift_flag are both true, the objective term of the box, the ellipsoid or the norm ball reads the lift with a constant corner of set_sdp_objective_lift!, so it has degree two under MaximumRatio. set_ucs_variance_risk! then builds the term on that lift, with its own names under the namespace lift_, and builds the worst case on the lift of set_sdp_constraints! for the bound only when settings.ub holds one.
Arguments
model::JuMP.Model: The JuMP optimisation model.i: Constraint index for unique variable and constraint naming.r::UncertaintySetVariance: The measure.opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.pr: Prior result.
Keyword arguments
prefix::Symbol: Model State namespace of the build (default: empty, i.e. the bare key).rd::ReturnsResult: The optimisation's returns, read by an estimator of the set (default: an emptyReturnsResult).kwargs...: Passed tosigma_ucs.
Returns
ucs_variance_risk: The worst-case variance expression.
Related
References
- [190]
- D. Cajas. A Semidefinite Programming Approach to Risk Parity Portfolio Optimization. Available at SSRN 5097869 (2025).