Entropic X at Risk: private API

PortfolioOptimisers.ERM — Function
ERM(x::VecNum, slv::Option{<:Slv_VecSlv}, alpha::Number = 0.05,
    w::Option{<:ObsWeights} = nothing) -> Number

Compute the Entropic Value-at-Risk of the returns x with an exponential cone programme.

EntropicValueatRisk states the measure, its Kullback-Leibler ball and its programme. Every call builds a new JuMP model. The model holds the cone rows of the observations of positive weight only. An observation of weight zero does not change the optimum, but the cone row of a large loss can stop the solver far from the optimum.

Algorithm

  1. Check w against x with checked_observation_weights.
  2. Check that slv is a solver, and not empty when it is a vector, with checked_kernel_solver.
  3. When alpha is zero, return the largest loss among the observations of positive weight, with worst_positive_weight_loss. This step builds no model.
  4. Build and solve the exponential cone programme that ERM_model states.
  5. 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)$.
  • w: Observation weights, or nothing for equal weights.

Validation

The function does not check alpha. The constructors of the measures check it.

Returns

  • The Entropic Value-at-Risk of x, or NaN when no solver of slv solves the programme.

Related

source
PortfolioOptimisers.ERM_worst_case — Function
ERM_worst_case(x::VecNum, slv::Option{<:Slv_VecSlv}, alpha::Number = 0.05,
               w::Option{<:ObsWeights} = nothing) -> Option{<:VecNum}

Compute the Worst-Case Distribution of the Entropic Value-at-Risk of the returns x, from the dual of the programme of ERM_model.

The Entropic Value-at-Risk is the largest expected loss over a Kullback-Leibler ball, and the Worst-Case Distribution $\boldsymbol{q}$ is the distribution in the ball that reaches it. So the expected loss under $\boldsymbol{q}$ equals the value of ERM, 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, so that their finite difference does not difference two solves. ERM does not compute it, so a call of expected_risk does not pay for it.

Algorithm

  1. Check w against x with checked_observation_weights.
  2. Check that slv is a solver, and not empty when it is a vector, with checked_kernel_solver.
  3. When alpha is zero, return the distribution of the largest loss, with worst_loss_distribution. This step builds no model.
  4. Build and solve the programme with ERM_model.
  5. When no solver solves the model, or the solver gives no dual, return nothing.
  6. Otherwise, negate the first entry of the dual of each row of erm_cone, and expand it to T entries with expand_positive_weight_rows.

Arguments

  • x: Vector of portfolio returns.
  • slv: Solver or vector of solvers.
  • alpha: Significance level, $\alpha \in [0, 1)$.
  • w: Observation weights, or nothing for equal weights.

Validation

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 of slv solves the programme, or the solver gives no dual.

Related

source
PortfolioOptimisers.ERM_model — Function
ERM_model(x::VecNum, slv::Slv_VecSlv, alpha::Number, w::Option{<:VecNum})
    -> Option{JuMP.Model}

Build the exponential cone programme of ERM in a new model, and solve it.

ERM reads the objective value of the solved model, and ERM_worst_case reads the dual of its cone rows. The callers check w and slv first, and they answer alpha = 0 without a model.

Algorithm

  1. Find rows, the indices of the observations of positive weight, and N, their number. Without w, rows holds every observation.
  2. Build the programme below in a new model. Its radius term reads aT, which is alpha times the number of observations without w, and alpha times the sum of w with it. The cone rows read xr and ur, the entries of x and of u in rows.
  3. Solve the model with the solvers of slv in turn.
  4. When a solver solves the model, return the model. Otherwise, return nothing.

JuMP formulation

Variables

  • t: free scalar $t$.
  • z: scalar $z$, bounded below by zero.
  • u: free $T \times 1$ vector $\boldsymbol{u}$. The entry of an observation of weight zero has a zero coefficient in the budget row, and no cone row reads it.

Expressions

  • risk: $t - z \ln(\alpha T)$ without observation weights, and $t - z \ln(\alpha W_{T})$ with them.

Constraints

No row carries a string name. The model registers these rows:

  • $\sum_{i=1}^{T} u_i - z \leq 0$ without observation weights, and $\sum_{i=1}^{T} w_i u_i - z \leq 0$ with them.
  • erm_cone: $(-x_i - t,\, z,\, u_i) \in \mathcal{K}_{\exp}$, one row for each $i \in \mathcal{I}$.

The cone rows give $u_i \geq z\, e^{(L_i - t)/z}$. So at the optimum, risk is the minimum over $z$ of $z \ln\!\left(\tfrac{1}{\alpha} \sum_{i \in \mathcal{I}} p_i e^{L_i / z}\right)$, the Chernoff bound of EntropicValueatRisk. An observation of weight zero has $p_i = 0$, so it adds no term to that sum.

The first entry of the dual of the cone row of observation $i$ is $-q_i$, where $\boldsymbol{q}$ is the Worst-Case Distribution of the Kullback-Leibler ball. ERM_worst_case reads it.

Objective

  • The model minimises risk.

Where:

  • $\boldsymbol{x}$: Portfolio returns vector $T \times 1$.
  • $T$: Number of observations.
  • $\alpha$: Significance level (left tail probability), $\alpha \in (0, 1)$.
  • $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.
  • $w_i$: Observation weight of observation $i$.
  • $W_{T} = \sum_{t=1}^{T} w_{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.
  • $t$, $z$: Scalar variables of the exponential cone programme.
  • $u_i$: Variable of observation $i$ in the exponential cone programme.
  • $\mathcal{K}_{\exp} = \mathrm{cl}\,\{(a,b,c) : b\, e^{a/b} \leq c,\, b > 0\}$: Exponential cone.

Arguments

  • x: Vector of portfolio returns.
  • slv: Solver or vector of solvers.
  • alpha: Significance level, $\alpha \in (0, 1)$.
  • w: Checked observation weights, or nothing for equal weights.

Returns

  • model::JuMP.Model: The solved model.
  • nothing: When no solver of slv solves the programme.

Related

source