Skip to content
13

XatRisk Constraints

PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::ValueatRisk{<:Any, <:Any, <:Any, <:MIPValueatRisk},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> VariableRef

Add Value-at-Risk, Value-at-Risk range, or Drawdown-at-Risk constraints to model.

The MIP overloads introduce binary variables z_var and add big-M constraints to encode the empirical quantile. The distribution overloads use closed-form z-scores computed by compute_value_at_risk_z / compute_value_at_risk_cz and add an SOC constraint. The DrawdownatRisk overload applies the MIP approach to the drawdown series.

Mathematical definition

Empirical (MIP) VaR:

zt{0,1},tztαT,VaRr^tbztt.

Where:

  • zt{0,1}: Binary indicator for tail losses.

  • α: Significance level (left tail probability), α(0,1).

  • T: Number of observations.

  • VaR: Value-at-Risk variable.

  • r^t: Portfolio return at time t.

  • b: Big-M constant.

Parametric VaR (Normal/t/Laplace):

VaRα(w)=μw+zαGw2.

Where:

  • VaRα(w): Parametric Value-at-Risk.

  • μ: Expected returns vector.

  • w: Portfolio weights vector N×1.

  • zα: Distribution quantile at level α.

  • G: Cholesky factor of the covariance matrix.

where zα is the distribution quantile at level α and G is the Cholesky factor of the covariance.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r: Risk measure instance.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::ValueatRiskRange{<:Any, <:Any, <:Any, <:Any, <:MIPValueatRisk},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> AffExpr

Add JuMP risk constraints for ValueatRiskRange using a MIP (big-M) formulation to model.

Introduces binary variables and big-M constraints to encode both the lower-tail and upper-tail empirical quantiles. The range risk expression is the difference between the two VaR expressions.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::ValueatRiskRange{<:Any, <:Any, <:Any, <:Any, <:MIPValueatRisk}: The VaR range risk measure with MIP formulation.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::ValueatRisk{<:Any, <:Any, <:Any, <:DistributionValueatRisk},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> Any

Add JuMP risk constraints for ValueatRisk using a parametric distribution formulation to model.

Uses the closed-form z-score from compute_value_at_risk_z and adds a second-order cone constraint to bound the portfolio standard deviation. The VaR expression is -mu'w + z * g_var.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::ValueatRisk{<:Any, <:Any, <:Any, <:DistributionValueatRisk}: The VaR risk measure with distribution-based formulation.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::ValueatRiskRange{<:Any, <:Any, <:Any, <:Any, <:DistributionValueatRisk},
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> Any

Add JuMP risk constraints for ValueatRiskRange using a parametric distribution formulation to model.

Uses closed-form z-scores from compute_value_at_risk_z and compute_value_at_risk_cz and adds a second-order cone constraint. The range risk expression is the difference between the lower-tail and upper-tail VaR expressions.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::ValueatRiskRange{<:Any, <:Any, <:Any, <:Any, <:DistributionValueatRisk}: The VaR range risk measure with distribution-based formulation.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! Method
julia
set_risk_constraints!(
    model::Model,
    i,
    r::DrawdownatRisk,
    opt::RiskJuMPOptimisationEstimator,
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> VariableRef

Add JuMP risk constraints for DrawdownatRisk to model.

Introduces binary variables and big-M constraints applied to the drawdown series to encode the empirical drawdown quantile at confidence level r.alpha.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.

  • i: Constraint index for unique variable and constraint naming.

  • r::DrawdownatRisk: The drawdown-at-risk risk measure.

  • opt::RiskJuMPOptimisationEstimator: Risk-based optimisation estimator.

  • pr: Prior result.

Returns

  • nothing.

Related

source
PortfolioOptimisers.compute_value_at_risk_z Function
julia
compute_value_at_risk_z(
    dist::Distributions.Normal,
    alpha::Number
) -> Any

Compute the lower-tail z-score for a parametric VaR at significance level alpha.

Returns the complementary quantile for Normal and scaled Student-t distributions, and the closed-form expression for the Laplace distribution.

Arguments

  • dist: Distribution instance (Normal, TDist, or Laplace).

  • alpha::Number: Significance level.

Returns

  • z::Number: Lower-tail z-score for the parametric VaR.

Related

source
PortfolioOptimisers.compute_value_at_risk_cz Function
julia
compute_value_at_risk_cz(
    dist::Distributions.Normal,
    alpha::Number
) -> Any

Compute the upper-tail z-score for a parametric VaR at significance level alpha.

Used for the high (upper) bound in VaR range constraints. Returns the lower quantile for Normal and scaled Student-t distributions, and the closed-form expression for Laplace.

Arguments

  • dist: Distribution instance (Normal, TDist, or Laplace).

  • alpha::Number: Significance level.

Returns

  • z::Number: Upper-tail z-score for the parametric VaR.

Related

source