Base Risk Constraints

PortfolioOptimisers.risk_constraint_solver — Method
risk_constraint_solver(opt::JuMPOptimisationEstimator)

Returns the solver against which a risk measure builder resolves a Deferred Quantity.

The method for a JuMP optimiser returns the solver of the optimiser, opt.opt.slv. A programme Allocation Set has a method of its own, which AbstractProgrammeAllocationSet states.

Arguments

  • opt: The JuMP optimiser that owns the constraint.

Returns

  • slv: The solver, or the vector of solvers, of the optimiser.

Related

source
PortfolioOptimisers.set_risk_constraints! — Function
set_risk_constraints!(
    model::Model,
    r::RiskMeasure,
    opt::Union{AbstractProgrammeAllocationSet, JuMPOptimisationEstimator},
    pr::AbstractPriorResult,
    pl::Union{Nothing, AbstractPhylogenyConstraintResult, AbstractVector{<:AbstractPhylogenyConstraintResult}},
    fees::Union{Nothing, Fees};
    ...
)
set_risk_constraints!(
    model::Model,
    r::RiskMeasure,
    opt::Union{AbstractProgrammeAllocationSet, JuMPOptimisationEstimator},
    pr::AbstractPriorResult,
    pl::Union{Nothing, AbstractPhylogenyConstraintResult, AbstractVector{<:AbstractPhylogenyConstraintResult}},
    fees::Union{Nothing, Fees},
    b1::Union{Nothing, AbstractMatrix{<:Union{Number, AbstractJuMPScalar}}};
    kwargs...
)

Builds the constraints of one risk measure, or of each measure in a vector, and gives each measure its index.

This route calls no factory, so a measure that states no solver of its own still holds nothing. Both methods resolve the measure against the solver of the owner, risk_constraint_solver. A Calibration Rule that reads the solver then sees the same solver here and on the factory route.

Algorithm

  1. The method for one measure drops the scale of r with unit_scale_risk_measure, and builds the measure at index 1. scale weighs a measure against the other measures of a vector, so it has no effect on one measure alone.
  2. The method for a vector builds each measure rs[i] at index i, and keeps its scale.
  3. Each build calls set_resolved_risk_constraints!, which resolves the measure, builds it and records it as the owner of the :risk_frontier entries that it adds.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.
  • r: A RiskMeasure, or rs, a vector of risk measures.
  • opt: The owner of the constraint, a JuMPOptimisationEstimator or a programme Allocation Set. RiskConstraintOwner states the owners.
  • pr: Prior result.
  • pl: Optional phylogeny constraints.
  • fees: Optional fees structure.
  • b1::Option{<:MatNum} = nothing: Basis of the decision vector of FactorRiskContribution, which maps it to the asset weights: the pseudoinverse of the transposed loadings, followed by the off-factor basis when flag = true. nothing for all other optimisers.

Returns

  • nothing.

Related

source
PortfolioOptimisers.set_risk_constraints! — Method
set_risk_constraints!(
    model::Model,
    i,
    r::RangeRiskMeasure,
    opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
    pr::AbstractPriorResult,
    args...;
    prefix,
    kwargs...
) -> Any

Adds the constraints of a range risk measure to model, as the sum of its loss tail and its gain tail.

This is the build of every RangeRiskMeasure formulation that decomposes. The two tails from range_tails carry rke = false and no bound, so the sum alone reaches the objective and the bound. Each tail builds under its own index, which nested_index composes from the side and i. The keys of the two tails therefore differ, also when a range holds a range. A formulation that fuses its tails has a method of its own, which is more specific.

Two decomposed formulations do work of their own before the tails: OrderedWeightsArrayRange under ApproxOrderedWeightsArray checks w1 and w2 under their names, and GenericValueatRiskRange of two DistributionValueatRisk tails builds the cone that the tails share. Their methods hold a copy of the five steps below, and the copies agree with this method.

Mathematical definition

\[\begin{align} \mathcal{R}_{\mathrm{range}}(\boldsymbol{w}) &= \mathcal{R}_{\mathrm{loss}}(\hat{\boldsymbol{r}}) + \mathcal{R}_{\mathrm{gain}}(-\hat{\boldsymbol{r}})\,. \end{align}\]

Where:

  • $\mathcal{R}_{\mathrm{range}}(\boldsymbol{w})$: The range risk of the portfolio.
  • $\mathcal{R}_{\mathrm{loss}}$, $\mathcal{R}_{\mathrm{gain}}$: The loss tail and the gain tail of the range measure, each a risk measure of a return series.
  • $\hat{\boldsymbol{r}}$: The net portfolio returns, $T \times 1$, with entries $\hat{r}_t$.
  • $\hat{r}_t$: Net portfolio return at observation $t$, $\boldsymbol{x}_t^\intercal \boldsymbol{w}$ less the fees charged at $t$.

Algorithm

  1. Read the tails loss and gain of r with range_tails, and the key name of the sum with range_risk_key.
  2. Build loss at index nested_index(:loss_, i) with loss = true, giving loss_risk.
  3. Build gain at index nested_index(:gain_, i) with loss = false, giving gain_risk. The builder then reads the negated net portfolio returns.
  4. Register range_risk = loss_risk + gain_risk under the Model State key of name and i.
  5. Bound range_risk and add it to risk_vec with set_risk_bounds_and_expression!, from r.settings.

JuMP formulation

Expressions

  • <prefix><name><i>: $\mathcal{R}_{\mathrm{loss}} + \mathcal{R}_{\mathrm{gain}}$, registered as a Model State entry. name is range_risk_key(r).

Where:

  • $\mathcal{R}_{\mathrm{loss}}$, $\mathcal{R}_{\mathrm{gain}}$: The risk expressions that the two tail builds return.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.
  • i: Constraint index for unique variable and constraint naming.
  • r::RangeRiskMeasure: The range risk measure, a formulation that decomposes.
  • opt::RiskConstraintOwner: The owner of the risk constraint, a risk-based JuMP optimisation estimator or a programme Allocation Set.
  • pr::AbstractPriorResult: Prior result containing the returns matrix X.

Keyword arguments

  • prefix::Symbol: Model State namespace (default: empty, i.e. the bare key).

Returns

  • range_risk: The combined loss + gain risk expression added to the model.

Related

source
PortfolioOptimisers.range_risk_key — Function
range_risk_key(r::RangeRiskMeasure) -> Symbol

Returns the Model State key of the sum of the two tails of the range r.

Every RangeRiskMeasure formulation that decomposes implements a method, beside its builder. The key follows the convention <base>_range_risk_, where <base> is the key of the point measure, so a reader of the model finds the range from the name of its base.

FormulationKey
ValueatRiskRange under MIPValueatRisk:var_range_risk_
ConditionalValueatRiskRange:cvar_range_risk_
DistributionallyRobustConditionalValueatRiskRange:drcvar_range_risk_
EntropicValueatRiskRange:evar_range_risk_
RelativisticValueatRiskRange:rlvar_range_risk_
PowerNormValueatRiskRange:pvar_range_risk_
GenericValueatRiskRange:genvar_range_risk_
OrderedWeightsArrayRange under ApproxOrderedWeightsArray:aowa_range_risk_

There is no fallback. A formulation that fuses its tails states its key in its own builder, so a missing method stays a MethodError.

Arguments

  • r::RangeRiskMeasure: The range risk measure.

Returns

  • name::Symbol: The bare Model State key of the sum. state_set! adds the prefix and the index.

Related

source
PortfolioOptimisers.set_risk_bounds_and_expression! — Function
set_risk_bounds_and_expression!(
    model::Model,
    opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
    r_expr::AbstractJuMPScalar,
    settings::RiskMeasureSettings,
    name::Symbol;
    ...
)
set_risk_bounds_and_expression!(
    model::Model,
    opt::Union{AbstractProgrammeAllocationSet, RiskJuMPOptimisationEstimator},
    r_expr::AbstractJuMPScalar,
    settings::RiskMeasureSettings,
    name::Symbol,
    flag::Bool;
    prefix
)

Bounds a risk expression by settings.ub, and adds it to the risk that the objective reads.

Every risk measure builder ends with this call, or with a sibling that takes a separate bound expression.

Algorithm

  1. Compose key from prefix, name and, in the index method, i, with state_key. The builder registered its risk expression under the same key, so the bound keys cannot differ from it.
  2. Bound r_expr by settings.ub with set_risk_upper_bound!, in the direction that flag gives.
  3. Append r_expr times settings.scale to risk_vec with set_risk_expression!, when settings.rke is true.

Arguments

  • model::JuMP.Model: The JuMP optimisation model.
  • opt: The owner of the constraint, a RiskConstraintOwner.
  • r_expr::JuMP.AbstractJuMPScalar: The risk expression.
  • settings::RiskMeasureSettings: The settings of the measure, which give the bound, the weight and rke.
  • name::Symbol: The Model State name of the risk expression. The bound keys <name>_ub and <name>_ub_var derive from it.
  • i: The index of the measure, in the index method.
  • flag::Bool: true for an upper bound and false for a lower bound (default: true).

Keyword arguments

  • prefix::Symbol: Model State namespace for name (default: empty, i.e. the bare key).

Returns

  • nothing.

Related

source