Score weight bounds: private API
PortfolioOptimisers.score_cap — Function
score_cap(v::Number, s::Number, nf::Number) -> NumberReturn the score bound of one asset, $c = v s$.
Algorithm
- Compute
c = v * s. The bound takes the type of this product. - If
sis not finite, returnnfin the type ofc. - If
vis infinite, returnvin the type ofc. The productInf * 0isNaN, and an infinite multiple states no bound. - Otherwise return
c.
Arguments
v: The multiple of the asset, from thevalof aScoreWeightBounds.s: The score of the asset.nf: The bound of an asset whose score is not finite.
Returns
c::Number: The score bound of the asset.
Examples
julia> PortfolioOptimisers.score_cap(0.5, 2.0, 0)1.0julia> PortfolioOptimisers.score_cap(0.5, NaN, 0)0.0Related
PortfolioOptimisers.score_bounds — Function
score_bounds(wb::WeightBounds, c::VecNum, symmetric::Bool) -> WeightBoundsJoin the resolved static bounds wb with the score bounds c.
Algorithm
- Check that no entry of
cis negative, that no lower bound ofwbis above its entry ofc, and, whensymmetricistrue, that no upper bound ofwbis below the negative of its entry ofc. - Take the lower side
max.(wb.lb, -c)whensymmetricistrue, andwb.lbotherwise. - Take the upper side
min.(wb.ub, c). - Build the
WeightBoundsof the two sides.
Arguments
wb: The static bounds, one entry per asset on each side.c: The score bounds, one entry per asset.symmetric: Iftrue, the score bounds both sides of the weight.
Validation
all(c .>= 0). A score bound is a magnitude, so a negative score has no bound. ADomainErrorthat names the count of the assets is thrown otherwise.all(wb.lb .<= c). A lower bound above the score bound admits no weight. ADomainErrorthat names the count of the assets is thrown otherwise.- If
symmetric:all(wb.ub .>= -c). An upper bound below the negative of the score bound admits no weight. ADomainErrorthat names the count of the assets is thrown otherwise.
Returns
wb::WeightBounds: The joined bounds.
Examples
julia> PortfolioOptimisers.score_bounds(WeightBounds([0.0, 0.0], [1.0, 0.2]), [0.5, 0.25], true)WeightBounds lb ┼ Vector{Float64}: [0.0, 0.0] ub ┴ Vector{Float64}: [0.5, 0.2]Related