Power Norm X at Risk: private API
PortfolioOptimisers.PRM — Function
PRM(x::VecNum, slv::Option{<:Slv_VecSlv}, alpha::Number = 0.05, p::Number = 2.0,
w::Option{<:ObsWeights} = nothing) -> NumberCompute the Power Norm Value-at-Risk of the returns x with a power cone programme.
PowerNormValueatRisk states the measure, its programme and the condition under which it is the largest loss. Under that condition the function returns the largest loss and builds no model. Otherwise every call builds a new JuMP model. The model holds the rows of the observations of positive weight only. An observation of weight zero does not change the optimum, but the rows of a large loss can stop the solver away from the optimum.
Algorithm
- Check
wagainstxwithchecked_observation_weights. - Check that
slvis a solver, and not empty when it is a vector, withchecked_kernel_solver. The check comes before step 3, so the function refusesslv = nothingalso when it needs no model. - When
power_norm_is_worst_lossholds, return the largest loss among the observations of positive weight, withworst_positive_weight_loss. This step builds no model. - Build and solve the power cone programme that
PRM_modelstates. - When a solver solves the model, return its objective value. Otherwise, return
NaN.
Arguments
x: Vector of portfolio returns.slv: Solver or vector of solvers.alpha: Significance level, $\alpha \in (0, 1)$.p: Order of the power norm, $p > 1$.w: Observation weights, ornothingfor equal weights.
Validation
wpasseschecked_observation_weightsagainstx. Otherwise that function raises its error.slvis notnothing, elseIsNothingError, and ifslvis aVecSlv:!isempty(slv), elseIsEmptyError. Seechecked_kernel_solver.
The function does not check alpha or p. The constructors of the measures check them.
Returns
- The Power Norm Value-at-Risk of
x, orNaNwhen step 6 does not return and no solver ofslvsolves the programme.
Related
PowerNormValueatRiskPRM_modelPRM_worst_caseERMRRMpower_norm_is_worst_lossworst_positive_weight_losspositive_weight_rowschecked_observation_weightsoptimise_JuMP_model!Slv_VecSlv
References
- [205] P. A. Krokhmal. Higher moment coherent risk measures. Quantitative Finance 7, 373–387 (2007). Equation 32.
- [206] P. R. Chares. Cones and interior-point algorithms for structured convex optimization involving powers and exponentials. Ph.D. Thesis, Université catholique de Louvain, Louvain-la-Neuve, Belgium (2009). Section 4.1, Equations 4.4 and 4.5.
PortfolioOptimisers.PRM_worst_case — Function
PRM_worst_case(x::VecNum, slv::Option{<:Slv_VecSlv}, alpha::Number = 0.05, p::Number = 2.0,
w::Option{<:ObsWeights} = nothing) -> Option{<:VecNum}Compute the Worst-Case Distribution of the Power Norm Value-at-Risk of the returns x, from the dual of the programme of PRM_model.
The Power Norm Value-at-Risk is a coherent measure, so it is the largest expected loss over a set of distributions, and the Worst-Case Distribution $\boldsymbol{q}$ is the distribution in the set that reaches it. So the expected loss under $\boldsymbol{q}$ equals the value of PRM, to the tolerance of the solver, and $-\boldsymbol{q}$ is the gradient of that value with respect to x. risk_contribution and risk_gradient read it through worst_case_distribution. PRM does not compute it, so a call of expected_risk does not pay for it.
Algorithm
- Check
wagainstxwithchecked_observation_weights. - Check that
slvis a solver, and not empty when it is a vector, withchecked_kernel_solver. The check comes before step 3, so the function refusesslv = nothingalso when it needs no model. - When
power_norm_is_worst_lossholds, return the distribution of the largest loss, withworst_loss_distribution. This step builds no model. - Build and solve the programme with
PRM_model. - When no solver solves the model, or the solver gives no dual, return
nothing. - Otherwise, take the dual of each row of
prm_loss, and expand it toTentries withexpand_positive_weight_rows.
Arguments
x: Vector of portfolio returns.slv: Solver or vector of solvers.alpha: Significance level, $\alpha \in (0, 1)$.p: Order of the power norm, $p > 1$.w: Observation weights, ornothingfor equal weights.
Validation
wpasseschecked_observation_weightsagainstx. Otherwise that function raises its error.slvis notnothing, elseIsNothingError, and ifslvis aVecSlv:!isempty(slv), elseIsEmptyError. Seechecked_kernel_solver.
Returns
q::VecNum: The Worst-Case Distribution, one entry for each observation. An observation of weight zero has the entry zero.nothing: When no solver ofslvsolves the programme, or the solver gives no dual.
Related
PortfolioOptimisers.power_norm_is_worst_loss — Function
power_norm_is_worst_loss(x::VecNum, alpha::Number, p::Number, w::Option{<:VecNum})
-> BoolReturn whether the Power Norm Value-at-Risk of x is the largest loss among the observations of positive weight.
PowerNormValueatRisk states the condition: alpha is at most the probability of the largest loss to the power 1/p. PRM and PRM_worst_case read it, and build no model when it holds.
Algorithm
- Find
l, the largest loss among the observations of positive weight, withworst_positive_weight_loss. - Find
pl, the probability of the observations at the lossl. It is their number divided by the number of observations withoutw, and their share of the sum ofwwith it. - Return whether
alphais at mostplto the power1/p.
Arguments
x: Vector of portfolio returns.alpha: Significance level, $\alpha \in (0, 1)$.p: Order of the power norm, $p > 1$.w: Checked observation weights, ornothingfor equal weights.
Returns
Bool: Whether the measure is the largest loss.
Related
PortfolioOptimisers.PRM_model — Function
PRM_model(x::VecNum, slv::Slv_VecSlv, alpha::Number, p::Number, w::Option{<:VecNum})
-> Option{JuMP.Model}Build the power cone programme of PRM in a new model, and solve it.
PRM reads the objective value of the solved model, and PRM_worst_case reads the dual of its rows prm_loss. The callers check w and slv first, and they answer the case of power_norm_is_worst_loss without a model.
Algorithm
- Find
rows, the indices of the observations of positive weight, andN, their number. Withoutw,rowsholds every observation. - Build the programme below in a new model. Its objective reads
iaT, which is the inverse ofalphatimes the number of observations to the power1/pwithoutw, and the inverse ofalphatimes the sum ofwto the power1/pwith it. The rows readxr, the entries ofxinrows. - Solve the model with the solvers of
slvin turn. - When a solver solves the model, return the model. Otherwise, return
nothing.
JuMP formulation
Variables
pvar_eta: free scalar $\eta$.pvar_t: free scalar $t$.pvar_w: $N \times 1$ vector $\boldsymbol{w}$, bounded below by zero, with one entry for each observation in $\mathcal{I}$.pvar_v: free $N \times 1$ vector $\boldsymbol{v}$, with one entry for each observation in $\mathcal{I}$.
Constraints
No row carries a string name. The model registers these rows:
- $\sum_{i \in \mathcal{I}} v_i - t \leq 0$ without observation weights, and $\sum_{i \in \mathcal{I}} q_i v_i - t \leq 0$ with them.
prm_loss: $x_i + w_i + \eta \geq 0$, one row for each $i \in \mathcal{I}$.- $(v_i,\, t,\, w_i) \in \mathcal{K}_{\mathrm{pow}}(1/p)$, one row for each $i \in \mathcal{I}$.
The cone rows give $v_i \geq w_i^{p} / t^{p-1}$, so the first row gives $t \geq \left(\sum_{i \in \mathcal{I}} w_i^{p}\right)^{1/p}$ without observation weights. At the optimum $w_i = \max(L_i - \eta, 0)$, so the objective is the minimum of PowerNormValueatRisk over $\eta$. An observation of weight zero has $p_i = 0$, so it adds no term to that minimum.
The dual of the row of observation $i$ in prm_loss is the entry of that observation in the Worst-Case Distribution of the measure, the distribution whose expected loss is the value of the measure. PRM_worst_case reads it.
Objective
- The model minimises $\eta + t / (\alpha T^{1/p})$ without observation weights, and $\eta + t / (\alpha W_{T}^{1/p})$ with them.
Where:
- $\boldsymbol{x}$: Portfolio returns vector $T \times 1$.
- $T$: Number of observations.
- $\alpha$: Significance level (left tail probability), $\alpha \in (0, 1)$.
- $p > 1$: Order of the power norm.
- $L_i = -x_i$: Loss at observation $i$.
- $\mathcal{I}$: Set of the observations of positive weight. Without observation weights, it holds all $T$ observations.
- $q_i$: Observation weight of observation $i$.
- $W_{T} = \sum_{t=1}^{T} q_t$: Total observation weight.
- $p_i$: Probability of observation $i$. It is $1/T$ without observation weights, and the $i$-th observation weight divided by the sum of the weights with them.
- $\eta$: Threshold of the losses.
- $t$: Power norm bound on $\boldsymbol{w}$.
- $w_i$: Excess loss of observation $i$ above the threshold $\eta$.
- $v_i$: Power term bound of observation $i$, a bound on $w_i^{p} / t^{p-1}$.
- $\mathcal{K}_{\mathrm{pow}}(p) = \{(a,b,c) : a^{p} b^{1-p} \geq |c|,\, a \geq 0,\, b \geq 0\}$: Power cone.
Arguments
x: Vector of portfolio returns.slv: Solver or vector of solvers.alpha: Significance level, $\alpha \in (0, 1)$.p: Order of the power norm, $p > 1$.w: Checked observation weights, ornothingfor equal weights.
Returns
model::JuMP.Model: The solved model.nothing: When no solver ofslvsolves the programme.
Related
References
- [205]
- P. A. Krokhmal. Higher moment coherent risk measures. Quantitative Finance 7, 373–387 (2007).
- [206]
- P. R. Chares. Cones and Interior-Point Algorithms for Structured Convex Optimization Involving Powers and Exponentials. Ph.D. Thesis, Université catholique de Louvain (Louvain-la-Neuve, Belgium, 2009).