Skip to content
13

X at Risk

PortfolioOptimisers.ValueatRiskFormulation Type
julia
abstract type ValueatRiskFormulation <: AbstractAlgorithm

Abstract supertype for all Value-at-Risk formulation algorithms in PortfolioOptimisers.jl.

All concrete and/or abstract types representing the formulation for computing Value-at-Risk (e.g., mixed-integer programming, distribution-based) should be subtypes of ValueatRiskFormulation.

Related

source
PortfolioOptimisers.MIPValueatRisk Type
julia
struct MIPValueatRisk{__T_b, __T_s} <: ValueatRiskFormulation

Mixed-integer programming (MIP) formulation for Value-at-Risk.

MIPValueatRisk specifies bounds used in the binary variable formulation of Value-at-Risk within a JuMP optimisation model.

Fields

  • b: Optional big-M upper bound for the binary variable formulation. Must be positive and strictly greater than s if both are provided.

  • s: Optional small-M lower bound for the binary variable formulation. Must be positive and strictly less than b if both are provided.

Constructors

julia
MIPValueatRisk(;
    b::Option{<:Number} = nothing,
    s::Option{<:Number} = nothing
) -> MIPValueatRisk

Keywords correspond to the struct's fields.

Validation

  • If b is not nothing: b > 0.

  • If s is not nothing: s > 0.

  • If both are not nothing: b > s.

Examples

julia
julia> MIPValueatRisk()
MIPValueatRisk
  b ┼ nothing
  s ┴ nothing

Related

source
PortfolioOptimisers.DistributionValueatRisk Type
julia
struct DistributionValueatRisk{__T_mu, __T_sigma, __T_chol, __T_dist} <: ValueatRiskFormulation

Distribution-based formulation for Value-at-Risk.

DistributionValueatRisk specifies a parametric distribution for computing Value-at-Risk analytically. The distribution parameters can be overridden by prior results during optimisation.

Fields

  • mu: Optional expected returns vector. If nothing, uses prior result.

  • sigma: Optional covariance matrix. If nothing, uses prior result.

  • chol: Optional Cholesky factorisation of the covariance matrix. If nothing, uses prior result.

  • dist: Probability distribution to use for Value-at-Risk computation.

Constructors

julia
DistributionValueatRisk(;
    mu::Option{<:VecNum} = nothing,
    sigma::Option{<:MatNum} = nothing,
    chol::Option{<:MatNum} = nothing,
    dist::Distributions.Distribution = Distributions.Normal()
) -> DistributionValueatRisk

Keywords correspond to the struct's fields.

Validation

  • If mu is not nothing: !isempty(mu).

  • If sigma is not nothing: !isempty(sigma) and size(sigma, 1) == size(sigma, 2).

  • If chol is not nothing: !isempty(chol).

Examples

julia
julia> DistributionValueatRisk()
DistributionValueatRisk
     mu ┼ nothing
  sigma ┼ nothing
   chol ┼ nothing
   dist ┴ Distributions.Normal{Float64}: Distributions.Normal{Float64}=0.0, σ=1.0)

Related

source
PortfolioOptimisers.ValueatRisk Type
julia
struct ValueatRisk{__T_settings, __T_alpha, __T_w, __T_alg} <: RiskMeasure

Represents the Value-at-Risk (VaR) risk measure.

ValueatRisk quantifies the maximum expected loss at a given confidence level alpha over a specified time horizon. It can be computed using empirical quantiles (weighted or unweighted) or via a parametric distribution.

Mathematical Definition

Let x=(x1,,xT) be the portfolio returns vector and x(k) the k-th order statistic (k-th smallest value). The empirical VaR at significance level α is:

VaRα(x)=x(αT).

For observation-weighted samples with weight vector w summing to Sw, VaR is the αSw-quantile of the weighted empirical distribution.

Fields

  • settings: Risk measure configuration.

  • alpha: Significance level for the lower tail (e.g., 0.05 for 95% VaR).

  • w: Optional observation weights.

  • alg: Formulation algorithm for computing VaR.

Constructors

julia
ValueatRisk(;
    settings::RiskMeasureSettings = RiskMeasureSettings(),
    alpha::Number = 0.05,
    w::Option{<:ObsWeights} = nothing,
    alg::ValueatRiskFormulation = MIPValueatRisk()
) -> ValueatRisk

Keywords correspond to the struct's fields.

Validation

  • 0 < alpha < 1.

  • If w is not nothing: !isempty(w).

Functor

julia
(r::ValueatRisk)(x::VecNum)

Computes the Value-at-Risk of a portfolio returns vector x.

Arguments

  • x::VecNum: Portfolio returns vector.

Examples

julia
julia> ValueatRisk()
ValueatRisk
  settings ┼ RiskMeasureSettings
           │   scale ┼ Float64: 1.0
           │      ub ┼ nothing
           │     rke ┴ Bool: true
     alpha ┼ Float64: 0.05
         w ┼ nothing
       alg ┼ MIPValueatRisk
           │   b ┼ nothing
           │   s ┴ nothing

Related

source
PortfolioOptimisers.ValueatRiskRange Type
julia
struct ValueatRiskRange{__T_settings, __T_alpha, __T_beta, __T_w, __T_alg} <: RiskMeasure

Represents the Value-at-Risk Range risk measure.

ValueatRiskRange computes the difference between the lower-tail Value-at-Risk (at level alpha) and the upper-tail Value-at-Risk (at level beta), measuring the spread between downside and upside tail risks.

Mathematical Definition

VaRRangeα,β(x)=VaRα(x)VaRβ(x),

where VaRα(x) captures the lower-tail loss quantile and VaRβ(x) captures the upper-tail gain quantile.

Fields

  • settings: Risk measure configuration.

  • alpha: Significance level for the lower tail.

  • beta: Significance level for the upper tail.

  • w: Optional observation weights.

  • alg: Formulation algorithm for computing VaR.

Constructors

julia
ValueatRiskRange(;
    settings::RiskMeasureSettings = RiskMeasureSettings(),
    alpha::Number = 0.05,
    beta::Number = 0.05,
    w::Option{<:ObsWeights} = nothing,
    alg::ValueatRiskFormulation = MIPValueatRisk()
) -> ValueatRiskRange

Keywords correspond to the struct's fields.

Validation

  • 0 < alpha < 1.

  • 0 < beta < 1.

  • If w is not nothing: !isempty(w).

Functor

julia
(r::ValueatRiskRange)(x::VecNum)

Computes the VaR Range of a portfolio returns vector x.

Arguments

  • x::VecNum: Portfolio returns vector.

Examples

julia
julia> ValueatRiskRange()
ValueatRiskRange
  settings ┼ RiskMeasureSettings
           │   scale ┼ Float64: 1.0
           │      ub ┼ nothing
           │     rke ┴ Bool: true
     alpha ┼ Float64: 0.05
      beta ┼ Float64: 0.05
         w ┼ nothing
       alg ┼ MIPValueatRisk
           │   b ┼ nothing
           │   s ┴ nothing

Related

source
PortfolioOptimisers.DrawdownatRisk Type
julia
struct DrawdownatRisk{__T_settings, __T_alpha, __T_w, __T_b, __T_s} <: RiskMeasure

Represents the Drawdown-at-Risk (DaR) risk measure.

DrawdownatRisk quantifies the maximum drawdown not exceeded at a given confidence level alpha. It operates on absolute drawdowns computed from the portfolio returns series.

Mathematical Definition

Define the cumulative wealth process and absolute drawdown at time t:

ct=s=1txs,dt=ctmax0stcs0.

The Drawdown-at-Risk at level α is the αT-th smallest (most extreme) drawdown:

DaRα(x)=d(αT).

Fields

  • settings: Risk measure configuration.

  • alpha: Significance level for the lower tail.

  • w: Optional observation weights.

  • b: Optional big-M upper bound for the binary variable formulation in JuMP models.

  • s: Optional small-M lower bound for the binary variable formulation in JuMP models.

Constructors

julia
DrawdownatRisk(;
    settings::RiskMeasureSettings = RiskMeasureSettings(),
    alpha::Number = 0.05,
    w::Option{<:ObsWeights} = nothing,
    b::Option{<:Number} = nothing,
    s::Option{<:Number} = nothing
) -> DrawdownatRisk

Keywords correspond to the struct's fields.

Validation

  • 0 < alpha < 1.

  • If w is not nothing: !isempty(w).

  • If b is not nothing: b > 0.

  • If s is not nothing: s > 0.

  • If both b and s are not nothing: b > s.

Functor

julia
(r::DrawdownatRisk)(x::VecNum)

Computes the Drawdown-at-Risk of a portfolio returns vector x.

Arguments

  • x::VecNum: Portfolio returns vector.

Examples

julia
julia> DrawdownatRisk()
DrawdownatRisk
  settings ┼ RiskMeasureSettings
           │   scale ┼ Float64: 1.0
           │      ub ┼ nothing
           │     rke ┴ Bool: true
     alpha ┼ Float64: 0.05
         w ┼ nothing
         b ┼ nothing
         s ┴ nothing

Related

source
PortfolioOptimisers.RelativeDrawdownatRisk Type
julia
struct RelativeDrawdownatRisk{__T_settings, __T_alpha, __T_w} <: HierarchicalRiskMeasure

Represents the Relative Drawdown-at-Risk risk measure for hierarchical optimisation.

RelativeDrawdownatRisk quantifies the maximum relative (compounded) drawdown not exceeded at a given confidence level alpha. It operates on relative drawdowns computed from the portfolio returns series.

Mathematical Definition

Define the compounded wealth process and relative drawdown at time t:

Ct=s=1t(1+xs),rdt=Ctmax0stCs10.

The Relative Drawdown-at-Risk at level α is:

RDaRα(x)=rd(αT),

where rd(k) is the k-th smallest relative drawdown.

Fields

  • settings: Hierarchical risk measure configuration.

  • alpha: Significance level for the lower tail.

  • w: Optional observation weights.

Constructors

julia
RelativeDrawdownatRisk(;
    settings::HierarchicalRiskMeasureSettings = HierarchicalRiskMeasureSettings(),
    alpha::Number = 0.05,
    w::Option{<:ObsWeights} = nothing
) -> RelativeDrawdownatRisk

Keywords correspond to the struct's fields.

Validation

  • 0 < alpha < 1.

  • If w is not nothing: !isempty(w).

Functor

julia
(r::RelativeDrawdownatRisk)(x::VecNum)

Computes the Relative Drawdown-at-Risk of a portfolio returns vector x.

Arguments

  • x::VecNum: Portfolio returns vector.

Examples

julia
julia> RelativeDrawdownatRisk()
RelativeDrawdownatRisk
  settings ┼ HierarchicalRiskMeasureSettings
           │   scale ┴ Float64: 1.0
     alpha ┼ Float64: 0.05
         w ┴ nothing

Related

source
PortfolioOptimisers.CholRM Type
julia
const CholRM = Union{<:Variance, <:StandardDeviation, <:DistributionValueatRisk}

Union of risk measures that support Cholesky-factor-based computation.

Related

source
PortfolioOptimisers.absolute_drawdown_vec Function
julia
absolute_drawdown_vec(x::VecNum) -> Vector

Compute the absolute drawdown series for a single-asset return vector.

Each element of the result is the difference between the current cumulative return and its running maximum (always ≤ 0).

Arguments

  • x::VecNum: Return series vector (modified in place temporarily, then restored).

Returns

  • Vector: Drawdown vector of the same length as x.

Related

source