Concentration limit generation

PortfolioOptimisers.ConcentrationLimitEstimator — Type
struct ConcentrationLimitEstimator{__T_t, __T_c, __T_s, __T_set, __T_pos, __T_alg} <: AbstractConstraintEstimator

Configures a concentration rule, whose positions can be written as issuer names that resolve against a universe.

A concentration rule caps each position at c, and limits the sum of the positions over the threshold t to s. The UCITS rule, the "5/10/40 rule" of Art. 52(2) of Directive 2009/65/EC, is the default: a fund holds at most 10 % of its assets in one issuer, and the issuers over 5 % sum to at most 40 %. The weight bounds give the cap alone. The limit of the sum depends on which positions are over t, so no linear constraint gives it.

concentration_limit_constraints resolves the estimator to a ConcentrationLimit. It reads the positions from set. With set = nothing, each asset is its own position. An AssetSetsMatrixEstimator groups the assets by a key of sets.dict, such as the issuer of each asset. Then the cap is on the issuer, which is what the directive states, and two share classes of one issuer are one position.

The exceptions of Art. 52(3) to 52(5) of the directive are more rules, not more fields of one rule. The field on of AssetSetsMatrixEstimator gives each rule its issuers. A vector of rules goes in the slot conc of ConstraintBlock, and the group constraints give the limit of a government issuer.

sets = UniverseSets(;                    dict = Dict("nx" => ["C1", "C2", "K1", "G1"],                                "nx_issuer" => ["Acme", "Acme", "BankX", "DE"],                                "ucits_standard" => ["C1", "C2"],                                "ucits_covered" => ["K1"]))conc = [ConcentrationLimitEstimator(;                                    set = AssetSetsMatrixEstimator(; val = "nx_issuer",                                                                   on = "ucits_standard")),        ConcentrationLimitEstimator(; c = 0.25, s = 0.8,                                    set = AssetSetsMatrixEstimator(; val = "nx_issuer",                                                                   on = "ucits_covered"))]lcse = LinearConstraintEstimator(; val = "G1 <= 0.35")

The clustering and the naive optimisers take the rule through the block of a JuMPWeightFinaliser. concentration_margins checks the weights of any optimiser against the rule.

Fields

  • t: Threshold of a large position. A position over t counts towards the sum limit s. The UCITS value is 0.05.
  • c: Cap on each position. The UCITS value is 0.10. It is a cap on the issuer when set groups the assets by issuer.
  • s: Limit of the sum of the positions over t. The UCITS value is 0.40.
  • set: The positions that the rule reads. nothing makes each asset its own position. An AssetSetsMatrixEstimator or a membership matrix makes each row of the matrix one position, such as one issuer, so two share classes of one issuer are one position.
  • pos: Reading of a position with a short side: GrossPosition(), NetPosition() or LongPosition(). On a long-only book the three readings are the weights.
  • alg: Form of the rule: ExactConcentration(), the mixed-integer rule itself, or SumLargestConcentration(), a linear form that is stricter than the rule.

Constructors

ConcentrationLimitEstimator(;    t::Number = 0.05,    c::Number = 0.1,    s::Number = 0.4,    set::Option{<:MatNum_ASetMatE} = nothing,    pos::AbstractPositionReading = GrossPosition(),    alg::AbstractConcentrationAlgorithm = ExactConcentration()) -> ConcentrationLimitEstimator

Keywords correspond to the struct's fields.

Validation

View parameters

port_opt_view takes the view of these @vprop fields at the selected indices:

  • set: A membership matrix keeps the columns of the selected assets. An AssetSetsMatrixEstimator stays unchanged, and it resolves against the universe of the view.

Examples

julia> ConcentrationLimitEstimator(; set = AssetSetsMatrixEstimator(; val = "nx_issuer"))ConcentrationLimitEstimator    t ┼ Float64: 0.05    c ┼ Float64: 0.1    s ┼ Float64: 0.4  set ┼ AssetSetsMatrixEstimator      │   val ┼ String: "nx_issuer"      │    on ┴ nothing  pos ┼ GrossPosition()  alg ┴ ExactConcentration()

Related

source
PortfolioOptimisers.ConcentrationLimit — Type
struct ConcentrationLimit{__T_t, __T_c, __T_s, __T_set, __T_pos, __T_alg} <: AbstractConstraintResult

Caps each position at c, and limits the sum of the positions over the threshold t to s.

This is the resolved form of ConcentrationLimitEstimator, whose docstring states the rule and the directive that it comes from. The positions are the rows of set, or the assets when set is nothing. The slot conc of ConstraintBlock takes one rule or a vector of rules, and set_concentration_constraints! adds each rule to the model.

Mathematical definition

The form ExactConcentration states the rule with one binary for each position:

\[\begin{align} x_j &\leq t + (c - t)\, z_j\,, \\ y_j &\geq x_j - c\,(1 - z_j)\,,\quad y_j \geq 0\,, \\ \sum_{j=1}^{M} y_j &\leq s\,,\quad \boldsymbol{z} \in \{0, 1\}^{M}\,. \end{align}\]

Where:

  • $x_j$: Position $j$, row $j$ of set times the reading of the weights that pos gives.
  • $z_j$: Binary that says that position $j$ is over $t$.
  • $y_j$: The part of position $j$ that counts towards the sum.
  • $t$, $c$, $s$: The threshold, the cap and the limit of the sum.
  • $M$: The number of positions.

When $z_j = 0$, the position is at most $t$, and $y_j$ can be zero. When $z_j = 1$, the position is at most $c$, and $y_j \geq x_j$. So the feasible set is the rule itself. A solver has no reason to set $z_j = 1$ for a small position, because that only adds to the sum. The binary is not the held bit of HeldIndicators or LongShortIndicators, because "held" and "over $t$" are two different facts.

The form SumLargestConcentration states a stricter rule with no binary.

Fields

  • t: Threshold of a large position. A position over t counts towards the sum limit s. The UCITS value is 0.05.
  • c: Cap on each position. The UCITS value is 0.10. It is a cap on the issuer when set groups the assets by issuer.
  • s: Limit of the sum of the positions over t. The UCITS value is 0.40.
  • set: Membership matrix whose rows are the positions that the rule reads, or nothing to make each asset its own position.
  • pos: Reading of a position with a short side: GrossPosition(), NetPosition() or LongPosition(). On a long-only book the three readings are the weights.
  • alg: Form of the rule: ExactConcentration(), the mixed-integer rule itself, or SumLargestConcentration(), a linear form that is stricter than the rule.

Constructors

ConcentrationLimit(;    t::Number = 0.05,    c::Number = 0.1,    s::Number = 0.4,    set::Option{<:MatNum} = nothing,    pos::AbstractPositionReading = GrossPosition(),    alg::AbstractConcentrationAlgorithm = ExactConcentration()) -> ConcentrationLimit

Keywords correspond to the struct's fields.

Validation

View parameters

port_opt_view takes the view of these @vprop fields at the selected indices:

  • set: The membership matrix keeps the columns of the selected assets.

Examples

julia> ConcentrationLimit(; set = [1 1 0; 0 0 1])ConcentrationLimit    t ┼ Float64: 0.05    c ┼ Float64: 0.1    s ┼ Float64: 0.4  set ┼ 2×3 Matrix{Int64}  pos ┼ GrossPosition()  alg ┴ ExactConcentration()

Related

source
PortfolioOptimisers.AbstractPositionReading — Type
abstract type AbstractPositionReading <: AbstractAlgorithm end

Abstract supertype of the readings of a position of a ConcentrationLimit.

A reading tells the rule how a short position counts. A long-only book has no short position, so every reading gives the weights there. The name avoids the word "exposure", because the factor exposures use it.

readinggated expressiona short of -30 % of XA1 +8 %, A2 -8 % of one issuer
GrossPositionlw + swcounts as 30 %16 %
NetPositionwnot seen by the rule0 %
LongPositionlwnot seen by the rule8 %

Interfaces

To make a new reading, subtype AbstractPositionReading and implement the method below.

Reading of the weights

  • PortfolioOptimisers.position_reading(pos::AbstractPositionReading, w::AbstractVector, lw::AbstractVector, sw::AbstractVector) -> AbstractVector: The reading of each asset, from the weights w and their long and short parts lw and sw.

One method serves both callers. The model gives the variables of its parts. concentration_margins gives the parts of a weight vector, max.(w, 0) and max.(-w, 0). There is no fallback.

Related

source
PortfolioOptimisers.GrossPosition — Type
struct GrossPosition <: AbstractPositionReading end

Reads a position as the sum of its long and its short part, so a short position counts at its size.

This is the default reading of a ConcentrationLimit, and the safe one: a short position cannot hide a long position of the same issuer. The model reads the parts lw and sw of the weights. They give lw + sw >= |w|, so the reading is never below the gross position. When the short budget sbgt pins the sum of the parts and xbgt is off, the parts can be larger than |w|, and then the rule is stricter than the gross position.

A RiskBudgeting head declares its own parts of the weights, and the reading uses them.

Related

source
PortfolioOptimisers.LongPosition — Type
struct LongPosition <: AbstractPositionReading end

Reads a position as its long part, so the rule does not see a short position.

The model reads the long part lw of the weights. It gives lw >= max(w, 0), so the reading is never below the long position. When the budgets pin the sum of the long part and xbgt is off, lw can be larger than max(w, 0), and then the rule is stricter than the long position.

Related

source
PortfolioOptimisers.AbstractConcentrationAlgorithm — Type
abstract type AbstractConcentrationAlgorithm <: AbstractAlgorithm end

Abstract supertype of the forms of a ConcentrationLimit in the model.

Interfaces

To make a new form, subtype AbstractConcentrationAlgorithm and implement the method below.

Rows of the rule

  • PortfolioOptimisers.set_concentration_rows!(model::JuMP.Model, alg::AbstractConcentrationAlgorithm, sp::ConcentrationMIPSpace, x::AbstractVector, wb::WeightBounds, ss::Option{<:Number}) -> Nothing: Add the rows of the rule sp.cl on the positions x. Register each entry with state_set!(model, Symbol(""), mip_key(sp, name), val), so that two rules do not collide. A form with a binary declares it and its gate with declare_mip_gate!, so that its rows hold under a ratio objective too.

There is no fallback. concentration_margins reads the rule itself whatever the form, so a new form needs no method there.

Related

source
PortfolioOptimisers.ExactConcentration — Type
struct ExactConcentration <: AbstractConcentrationAlgorithm end

States a ConcentrationLimit exactly, with one binary for each position.

The binary says that the position is over the threshold t. The feasible set is the rule itself, see the mathematical definition of ConcentrationLimit. It is the default form. It needs a solver that takes integer variables.

The rule holds to the tolerance of the solver. A solver takes a binary at $\epsilon$ as zero when $\epsilon$ is under its integrality tolerance. Under a constant budget, a position with such a binary can be at $t + (c - t) \epsilon$. Under a ratio objective or a RiskBudgeting head, the gate multiplies $\epsilon$ by the big-M constant ss of the block, see declare_mip_gate!. So the position can be at $t + (c - t) M_s \epsilon / k$. With $M_s = 1000$, $\epsilon = 10^{-6}$ and $k = 1$, the excess is 0.005 % of the book under 5/10/40. The sum of the rule is a step, so a check with no tolerance then counts the whole position. Use one of these remedies:

  • A smaller constant, such as ss = 10 in the block. It must stay above the k of the solution.
  • A smaller integrality tolerance in the settings of the solver.
  • A threshold t a little under the limit of the mandate.
  • A tol at the size of the excess in concentration_margins, for a check that accepts the excess.

Related

source
PortfolioOptimisers.SumLargestConcentration — Type
struct SumLargestConcentration <: AbstractConcentrationAlgorithm end

States a ConcentrationLimit as a linear form with no integer variable: the sum of the k largest positions is at most s, with k = ceil(s / t), and each position is at most c.

The form is safe: a book that meets it meets the rule. A book with more than k positions over t has a sum of its k largest positions over k t >= s. So at most k positions are over t. They are among the k largest positions, so their sum is at most s. The form reads the positive part of each position, so a negative net position adds nothing.

The form is stricter than the rule. With 5/10/40, k = 8. A book of four positions at 10 % and six at 5 % meets the rule, because only the four positions at 10 % are over 5 %, and their sum is 40 %. Its eight largest positions sum to 50 %, so the form refuses it.

bookthe rulethis formthe sum of the 4 largest
8 x 9 %failsfailspasses (not safe)
4 x 10 % + 6 x 5 %passesfails (stricter)passes
20 x 5 %passespassespasses

The form "the sum of the 4 largest positions is at most 40 %" is not safe. A book of eight positions at 9 % meets it, but the sum of its positions over 5 % is 72 %.

Use the form for a solver with no integer variables, for a large universe, or for a loop of folds with many solves.

Related

source
PortfolioOptimisers.concentration_limit_constraints — Function
concentration_limit_constraints(cl::Option{<:ConcentrationLimit}, args...; kwargs...)
concentration_limit_constraints(cl::ConcentrationLimitEstimator,
                                sets::Option{<:UniverseSets}; strict::Bool = false,
                                kwargs...)
concentration_limit_constraints(cl::VecCnlE_Cnl, sets::Option{<:UniverseSets};
                                kwargs...)

Resolve a concentration rule, or a vector of rules, against a universe.

The method for a ConcentrationLimit or nothing returns its input unchanged. The method for a ConcentrationLimitEstimator resolves its set with asset_sets_matrix, and keeps the other fields. The method for a vector resolves each entry and keeps the order.

The block resolves the rule at stage 1, resolve_constraint_block_names, before the reduction to the Investable Mask. So the matrix has one column for each asset of the caller, and the view at the mask keeps the columns of the investable assets, as it does for smtx.

Algorithm

  1. Resolve cl.set with asset_sets_matrix(cl.set, sets; strict = strict). nothing and a matrix stay unchanged.
  2. Return a ConcentrationLimit with the resolved matrix and the other fields of cl.

Arguments

  • cl: The rule, or a vector of rules.
  • sets: A UniverseSets that holds the asset universe and the groups. A rule whose set holds no estimator does not read it, so it can be nothing.
  • strict: Whether to throw an error if sets does not contain the desired value in sets.dict[key].
  • args..., kwargs...: More arguments, which the method for a resolved rule ignores, and which the method for a vector gives to the method of each entry.

Validation

Returns

  • cl::Option{<:Cnl_VecCnl}: The resolved rule, or one resolved rule for each entry of a vector.

Examples

julia> sets = UniverseSets(;                           dict = Dict("nx" => ["A1", "A2", "B"], "nx_issuer" => ["A", "A", "B"]));julia> cl = ConcentrationLimitEstimator(; set = AssetSetsMatrixEstimator(; val = "nx_issuer"));julia> concentration_limit_constraints(cl, sets).set2×3 transpose(::BitMatrix) with eltype Bool: 1  1  0 0  0  1

Related

source
PortfolioOptimisers.position_reading — Function
position_reading(pos::AbstractPositionReading, w::AbstractVector, lw::AbstractVector,
                 sw::AbstractVector)

Return the reading of each asset that pos gives, from the weights and their long and short parts.

The builder mip_wx! gives the variables of the parts of the model. concentration_margins gives the smallest parts of a weight vector, max.(w, 0) and max.(-w, 0). Then the gross reading is |w|, and the long reading is the positive part of w.

Algorithm

The method that Julia selects is the algorithm:

Arguments

  • pos: The reading.
  • w: The weights.
  • lw, sw: The long and the short parts of the weights.

Returns

  • v::AbstractVector: The reading of each asset.

Related

source
PortfolioOptimisers.concentration_margins — Function
concentration_margins(cl::ConcentrationLimit, w::VecNum;
                      tol::Number = weights_bound_tolerance(eltype(w)), kwargs...)
concentration_margins(cl::ConcentrationLimitEstimator, w::VecNum;
                      sets::Option{<:UniverseSets} = nothing, strict::Bool = false,
                      kwargs...)
concentration_margins(cl::VecCnlE_Cnl, w::VecNum; kwargs...)

Check a weight vector against a concentration rule, and return its margins.

The check serves the mandate check of a book from any optimiser. The clustering and the naive optimisers have no slot for the rule, so their weights can break it. A rule holds when every margin is <= 0. The precedent of a check on weights is weights_meet_bounds.

Mathematical definition

\[\begin{align} \mathrm{cap}_j &= x_j - c\,, \\ \mathrm{total} &= \sum_{j\,:\,x_j > t + \tau} x_j - s\,. \end{align}\]

Where:

  • $x_j$: Position $j$, row $j$ of set times the reading of the weights that position_reading gives for pos.
  • $t$, $c$, $s$: The threshold, the cap and the limit of the sum.
  • $\tau$: The tolerance tol.

The sum is a step: a position that passes $t + \tau$ adds its whole size, and not its excess over $t$. So the check of a book of a solver needs a tol at the size of the tolerance of the solver. ExactConcentration states the excess that a mixed-integer solver can give, and how to lower it. tol does not move the margins of the cap and of the sum, so compare them with a tolerance too.

Algorithm

  1. Resolve an estimator with concentration_limit_constraints against sets.
  2. Read the weights with position_reading, with the parts max.(w, 0) and max.(-w, 0), and make the positions with concentration_positions.
  3. Return the margins of the formulas above. The method for a vector returns one ConcentrationMargins for each rule, in order.

Arguments

  • cl: The rule, or a vector of rules.
  • w: The weights, one for each asset of the universe of the rule.
  • tol: The excess over t up to which a position does not count towards the sum. The default is the tolerance of weights_bound_tolerance.
  • sets: A UniverseSets against which an estimator resolves, or nothing.
  • strict: Whether to throw an error if sets does not contain the desired value in sets.dict[key].
  • kwargs...: The method for a resolved rule ignores them. The method for an estimator gives them to the method for its resolved rule, and the method for a vector gives them to each entry.

Validation

Returns

  • cm::ConcentrationMargins: The margins of one rule, or one for each rule of a vector.

Examples

Six positions at 10 % sum to 60 %, so the book is 20 % over the limit of the sum, and no position is over the cap.

julia> w = [fill(0.1, 6); fill(0.04, 10)];julia> cm = concentration_margins(ConcentrationLimit(), w);julia> maximum(cm.cap) <= 0, round(cm.total; digits = 10)(true, 0.2)

Related

source
PortfolioOptimisers.ConcentrationMargins — Type
struct ConcentrationMargins{__T_x, __T_cap, __T_total} <: AbstractResult

Holds the margins of a weight vector against one concentration rule.

concentration_margins makes it. A margin <= 0 passes, so a book meets the rule when every entry of cap is <= 0 and total <= 0. A positive margin is the excess over the rule. A position counts towards the sum only when it is over the threshold by more than the keyword tol of that function. The check reads the rule itself, the form of ExactConcentration, whatever the field alg of the rule holds.

Fields

  • x: The position of each row of the rule, as pos and set read the weights.
  • cap: The cap margin of each position, x - c. A margin <= 0 passes.
  • total: The sum margin, the sum of the positions over t minus s. A margin <= 0 passes.

Constructors

ConcentrationMargins(;    x::VecNum,    cap::VecNum,    total::Number) -> ConcentrationMargins

Keywords correspond to the struct's fields.

Validation

  • length(x) == length(cap).

Related

source