X at Risk
PortfolioOptimisers.ValueatRiskFormulation Type
abstract type ValueatRiskFormulation <: AbstractAlgorithmAbstract 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
sourcePortfolioOptimisers.MIPValueatRisk Type
struct MIPValueatRisk{__T_b, __T_s} <: ValueatRiskFormulationMixed-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 thansif both are provided.s: Optional small-M lower bound for the binary variable formulation. Must be positive and strictly less thanbif both are provided.
Constructors
MIPValueatRisk(;
b::Option{<:Number} = nothing,
s::Option{<:Number} = nothing
) -> MIPValueatRiskKeywords correspond to the struct's fields.
Validation
If
bis notnothing:b > 0.If
sis notnothing:s > 0.If both are not
nothing:b > s.
Examples
julia> MIPValueatRisk()
MIPValueatRisk
b ┼ nothing
s ┴ nothingRelated
sourcePortfolioOptimisers.DistributionValueatRisk Type
struct DistributionValueatRisk{__T_mu, __T_sigma, __T_chol, __T_dist} <: ValueatRiskFormulationDistribution-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. Ifnothing, uses prior result.sigma: Optional covariance matrix. Ifnothing, uses prior result.chol: Optional Cholesky factorisation of the covariance matrix. Ifnothing, uses prior result.dist: Probability distribution to use for Value-at-Risk computation.
Constructors
DistributionValueatRisk(;
mu::Option{<:VecNum} = nothing,
sigma::Option{<:MatNum} = nothing,
chol::Option{<:MatNum} = nothing,
dist::Distributions.Distribution = Distributions.Normal()
) -> DistributionValueatRiskKeywords correspond to the struct's fields.
Validation
If
muis notnothing:!isempty(mu).If
sigmais notnothing:!isempty(sigma)andsize(sigma, 1) == size(sigma, 2).If
cholis notnothing:!isempty(chol).
Examples
julia> DistributionValueatRisk()
DistributionValueatRisk
mu ┼ nothing
sigma ┼ nothing
chol ┼ nothing
dist ┴ Distributions.Normal{Float64}: Distributions.Normal{Float64}(μ=0.0, σ=1.0)Related
sourcePortfolioOptimisers.ValueatRisk Type
struct ValueatRisk{__T_settings, __T_alpha, __T_w, __T_alg} <: RiskMeasureRepresents 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
For observation-weighted samples with weight vector
Fields
settings: Risk measure configuration.alpha: Significance level for the lower tail (e.g.,0.05for 95% VaR).w: Optional observation weights.alg: Formulation algorithm for computing VaR.
Constructors
ValueatRisk(;
settings::RiskMeasureSettings = RiskMeasureSettings(),
alpha::Number = 0.05,
w::Option{<:ObsWeights} = nothing,
alg::ValueatRiskFormulation = MIPValueatRisk()
) -> ValueatRiskKeywords correspond to the struct's fields.
Validation
0 < alpha < 1.If
wis notnothing:!isempty(w).
Functor
(r::ValueatRisk)(x::VecNum)Computes the Value-at-Risk of a portfolio returns vector x.
Arguments
x::VecNum: Portfolio returns vector.
Examples
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 ┴ nothingRelated
PortfolioOptimisers.ValueatRiskRange Type
struct ValueatRiskRange{__T_settings, __T_alpha, __T_beta, __T_w, __T_alg} <: RiskMeasureRepresents 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
where
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
ValueatRiskRange(;
settings::RiskMeasureSettings = RiskMeasureSettings(),
alpha::Number = 0.05,
beta::Number = 0.05,
w::Option{<:ObsWeights} = nothing,
alg::ValueatRiskFormulation = MIPValueatRisk()
) -> ValueatRiskRangeKeywords correspond to the struct's fields.
Validation
0 < alpha < 1.0 < beta < 1.If
wis notnothing:!isempty(w).
Functor
(r::ValueatRiskRange)(x::VecNum)Computes the VaR Range of a portfolio returns vector x.
Arguments
x::VecNum: Portfolio returns vector.
Examples
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 ┴ nothingRelated
sourcePortfolioOptimisers.DrawdownatRisk Type
struct DrawdownatRisk{__T_settings, __T_alpha, __T_w, __T_b, __T_s} <: RiskMeasureRepresents 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
The Drawdown-at-Risk at level
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 inJuMPmodels.s: Optional small-M lower bound for the binary variable formulation inJuMPmodels.
Constructors
DrawdownatRisk(;
settings::RiskMeasureSettings = RiskMeasureSettings(),
alpha::Number = 0.05,
w::Option{<:ObsWeights} = nothing,
b::Option{<:Number} = nothing,
s::Option{<:Number} = nothing
) -> DrawdownatRiskKeywords correspond to the struct's fields.
Validation
0 < alpha < 1.If
wis notnothing:!isempty(w).If
bis notnothing:b > 0.If
sis notnothing:s > 0.If both
bandsare notnothing:b > s.
Functor
(r::DrawdownatRisk)(x::VecNum)Computes the Drawdown-at-Risk of a portfolio returns vector x.
Arguments
x::VecNum: Portfolio returns vector.
Examples
julia> DrawdownatRisk()
DrawdownatRisk
settings ┼ RiskMeasureSettings
│ scale ┼ Float64: 1.0
│ ub ┼ nothing
│ rke ┴ Bool: true
alpha ┼ Float64: 0.05
w ┼ nothing
b ┼ nothing
s ┴ nothingRelated
sourcePortfolioOptimisers.RelativeDrawdownatRisk Type
struct RelativeDrawdownatRisk{__T_settings, __T_alpha, __T_w} <: HierarchicalRiskMeasureRepresents 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
The Relative Drawdown-at-Risk at level
where
Fields
settings: Hierarchical risk measure configuration.alpha: Significance level for the lower tail.w: Optional observation weights.
Constructors
RelativeDrawdownatRisk(;
settings::HierarchicalRiskMeasureSettings = HierarchicalRiskMeasureSettings(),
alpha::Number = 0.05,
w::Option{<:ObsWeights} = nothing
) -> RelativeDrawdownatRiskKeywords correspond to the struct's fields.
Validation
0 < alpha < 1.If
wis notnothing:!isempty(w).
Functor
(r::RelativeDrawdownatRisk)(x::VecNum)Computes the Relative Drawdown-at-Risk of a portfolio returns vector x.
Arguments
x::VecNum: Portfolio returns vector.
Examples
julia> RelativeDrawdownatRisk()
RelativeDrawdownatRisk
settings ┼ HierarchicalRiskMeasureSettings
│ scale ┴ Float64: 1.0
alpha ┼ Float64: 0.05
w ┴ nothingRelated
PortfolioOptimisers.CholRM Type
const CholRM = Union{<:Variance, <:StandardDeviation, <:DistributionValueatRisk}Union of risk measures that support Cholesky-factor-based computation.
Related
sourcePortfolioOptimisers.absolute_drawdown_vec Function
absolute_drawdown_vec(x::VecNum) -> VectorCompute 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 asx.
Related
source