Concentration limit generation: private API

PortfolioOptimisers.sum_largest_count — Function
sum_largest_count(t::Number, s::Number) -> Int

Return the smallest integer k with k t >= s, the count of positions of SumLargestConcentration.

A division in floating point can give ceil(s / t) one too large: 0.14 / 0.02 is 7.000000000000001, so ceil gives 8 where 7 is enough. A count that is too large keeps the form safe, but makes it stricter than it must be. So the function lowers the count while one less still gives k t >= s.

Algorithm

  1. Set k = ceil(Int, s / t).
  2. While k > 1 and (k - 1) t >= s, lower k by one.
  3. Return k.

Arguments

  • t: The threshold of a large position.
  • s: The limit of the sum.

Returns

  • k::Int: The count of positions.

Examples

julia> PortfolioOptimisers.sum_largest_count(0.05, 0.4)8julia> PortfolioOptimisers.sum_largest_count(0.05, 0.42)9julia> PortfolioOptimisers.sum_largest_count(0.02, 0.14)7

Related

source
PortfolioOptimisers.assert_concentration_limit — Function
assert_concentration_limit(t::Number, c::Number, s::Number)

Check the three numbers of a concentration rule.

ConcentrationLimitEstimator and ConcentrationLimit call it, because the numbers alone decide whether a rule has a meaning.

Validation

  • t, c and s are finite and > 0, through assert_nonempty_gt0_finite_val.
  • c > t. A cap at or below the threshold leaves no position over the threshold, so the sum limit has no meaning. A DomainError is thrown otherwise.

Returns

  • nothing.

Related

source
PortfolioOptimisers.VecCnlE_Cnl — Type
const VecCnlE_Cnl = AbstractVector{<:CnlE_Cnl}

Alias for a vector of concentration rules, resolved or not.

A mandate can hold more than one rule, such as a 5/10/40 rule over the standard issuers and a 5/25/80 rule over the issuers of covered bonds. The model adds each rule on its own, and the rules intersect.

Related

source
PortfolioOptimisers.concentration_positions — Function
concentration_positions(set::Option{<:MatNum}, v::AbstractVector)

Return the positions of a rule from the reading v of each asset: v itself when set is nothing, and set * v otherwise.

concentration_margins gives it a vector of numbers, and the builder mip_wx! gives it a vector of model expressions.

Arguments

  • set: The membership matrix of the rule, or nothing.
  • v: The reading of each asset.

Returns

  • x::AbstractVector: The position of each row of the rule.

Related

source