Generic Value at Risk Range
PortfolioOptimisers.GenericValueatRiskRange — Type
struct GenericValueatRiskRange{__T_settings, __T_loss, __T_gain} <: RangeRiskMeasureMeasures the spread of the returns as the sum of a tail measure of the losses and a tail measure of the gains, two measures that the caller states.
The two tails can be of different kinds and can have different parameters. Each tail is a member of ValueatRiskRMs. A range measure, a drawdown measure and a dispersion measure are not members, so the constructor does not accept them as a tail. With the two tails that a specific range measure builds, such as two ConditionalValueatRisk tails at the levels of a ConditionalValueatRiskRange, the range has the value of that specific measure. The construction is the library's own.
Mathematical definition
\[\begin{align} \mathrm{GenVaRRange}(\boldsymbol{x}) &= \rho_{\mathrm{loss}}(\boldsymbol{x}) + \rho_{\mathrm{gain}}(-\boldsymbol{x})\,. \end{align}\]
Where:
- $\mathrm{GenVaRRange}(\boldsymbol{x})$: Generic Value-at-Risk range.
- $\rho_{\mathrm{loss}}$: Tail measure of the losses, the field
loss. - $\rho_{\mathrm{gain}}$: Tail measure of the gains, the field
gain. - $\boldsymbol{x}$: Portfolio returns vector $T \times 1$.
The upper tail is the base measure applied to the negated returns $-\boldsymbol{x}$, so both tails are reported on the same sign convention and the range is their sum, not their difference.
Fields
settings: Risk measure settings.
loss: Tail measure of the losses, a member ofValueatRiskRMs. The range applies it to the portfolio returns.
gain: Tail measure of the gains, a member ofValueatRiskRMs. The range applies it to the negated portfolio returns.
Constructors
GenericValueatRiskRange(; settings::RiskMeasureSettings = RiskMeasureSettings(), loss::ValueatRiskRMs = ConditionalValueatRisk(), gain::ValueatRiskRMs = ConditionalValueatRisk()) -> GenericValueatRiskRangeKeywords correspond to the struct's fields.
The constructor strips the rke flag from both loss and gain via no_risk_expr_risk_measure, since their risk expressions are combined into the outer settings-controlled expression.
Propagated parameters
factory passes its arguments on to these @fprop fields:
View parameters
port_opt_view takes the view of these @vprop fields at the selected indices:
loss: Recursively viewed throughport_opt_view.gain: Recursively viewed throughport_opt_view.
Functor
(r::GenericValueatRiskRange)(x::VecNum)(r::GenericValueatRiskRange)(w::VecNum, X::MatNum, fees::Option{<:Fees} = nothing)The first method computes the range of a portfolio returns vector x as loss(x) + gain(-x). A tail that needs a solver, such as EntropicValueatRisk, needs its own slv, which factory fills from the solver of the optimiser.
A ValueatRisk tail with DistributionValueatRisk reads the portfolio weights and the moments of the prior, not a returns vector. The second method evaluates each tail on its own input through range_tail_risk. It computes the net returns x of w, then evaluates the loss tail on w and x, and the gain tail on -w and -x. The gain tail of such a ValueatRisk reads the law of the standardised loss of -w, which gain_tail_distribution gives, through gain_tail_measure. It is then dot(mu, w) - zc * sqrt(dot(w, sigma, w)), with zc = compute_value_at_risk_cz(dist, alpha), which is the gain tail that the optimisation model builds and the gain tail of a ValueatRiskRange. For a dist that is symmetric about zero, -zc equals the z of the loss tail. risk_input_kind of the range is WeightsReturnsFeesInput when a tail is such a ValueatRisk, so expected_risk calls the second method. Otherwise it is NetReturnsInput, and expected_risk calls the first method.
Validation
- First method: neither
lossnorgainis aValueatRiskwithDistributionValueatRisk, elseArgumentError.
Arguments
x::VecNum: Portfolio returns vector.w::VecNum: Portfolio weights vectorassets × 1.X::MatNum: Returns matrixobservations × assets.fees::Option{<:Fees}: OptionalFeesstructure.
Examples
julia> GenericValueatRiskRange()GenericValueatRiskRange settings ┼ RiskMeasureSettings │ scale ┼ Float64: 1.0 │ ub ┼ nothing │ rke ┴ Bool: true loss ┼ ConditionalValueatRisk │ settings ┼ RiskMeasureSettings │ │ scale ┼ Float64: 1.0 │ │ ub ┼ nothing │ │ rke ┴ Bool: false │ alpha ┼ Float64: 0.05 │ w ┴ nothing gain ┼ ConditionalValueatRisk │ settings ┼ RiskMeasureSettings │ │ scale ┼ Float64: 1.0 │ │ ub ┼ nothing │ │ rke ┴ Bool: false │ alpha ┼ Float64: 0.05 │ w ┴ nothingRelated
RiskMeasureRiskMeasureSettingsValueatRiskConditionalValueatRiskDistributionallyRobustConditionalValueatRiskEntropicValueatRiskRelativisticValueatRiskPowerNormValueatRiskValueatRiskRMsConditionalValueatRiskRange: the same value, with twoConditionalValueatRisktails.PowerNormValueatRiskRange: the same value, with twoPowerNormValueatRisktails.range_tailsrange_tail_riskgain_tail_measuregain_tail_distributionno_risk_expr_risk_measurefactoryport_opt_view