Concentration limit generation: private API
PortfolioOptimisers.sum_largest_count — Function
sum_largest_count(t::Number, s::Number) -> IntReturn 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
- Set
k = ceil(Int, s / t). - While
k > 1and(k - 1) t >= s, lowerkby one. - 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)7Related
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,candsare finite and> 0, throughassert_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. ADomainErroris thrown otherwise.
Returns
nothing.
Related
PortfolioOptimisers.CnlE_Cnl — Type
const CnlE_Cnl = Union{ConcentrationLimit, ConcentrationLimitEstimator}Alias for a concentration rule, resolved or not.
A caller can write a rule in either form, so the slot conc accepts both. concentration_limit_constraints gives a ConcentrationLimit for either form.
Related
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
PortfolioOptimisers.CnlE_Cnl_VecCnlE_Cnl — Type
const CnlE_Cnl_VecCnlE_Cnl = Union{CnlE_Cnl, VecCnlE_Cnl}Alias for one concentration rule or a vector of rules, resolved or not. The slot conc of ConstraintBlock takes it.
Related
PortfolioOptimisers.Cnl_VecCnl — Type
const Cnl_VecCnl = Union{ConcentrationLimit, AbstractVector{<:ConcentrationLimit}}Alias for one resolved concentration rule or a vector of resolved rules.
This is the resolved form of CnlE_Cnl_VecCnlE_Cnl. The field conc of ResolvedConstraintBlock and the builder set_concentration_constraints! take it, so they refuse an estimator.
Related
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, ornothing.v: The reading of each asset.
Returns
x::AbstractVector: The position of each row of the rule.
Related