Score weight bounds: private API

PortfolioOptimisers.score_cap — Function
score_cap(v::Number, s::Number, nf::Number) -> Number

Return the score bound of one asset, $c = v s$.

Algorithm

  1. Compute c = v * s. The bound takes the type of this product.
  2. If s is not finite, return nf in the type of c.
  3. If v is infinite, return v in the type of c. The product Inf * 0 is NaN, and an infinite multiple states no bound.
  4. Otherwise return c.

Arguments

  • v: The multiple of the asset, from the val of a ScoreWeightBounds.
  • 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.0

Related

source
PortfolioOptimisers.score_bounds — Function
score_bounds(wb::WeightBounds, c::VecNum, symmetric::Bool) -> WeightBounds

Join the resolved static bounds wb with the score bounds c.

Algorithm

  1. Check that no entry of c is negative, that no lower bound of wb is above its entry of c, and, when symmetric is true, that no upper bound of wb is below the negative of its entry of c.
  2. Take the lower side max.(wb.lb, -c) when symmetric is true, and wb.lb otherwise.
  3. Take the upper side min.(wb.ub, c).
  4. Build the WeightBounds of the two sides.

Arguments

  • wb: The static bounds, one entry per asset on each side.
  • c: The score bounds, one entry per asset.
  • symmetric: If true, 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. A DomainError that names the count of the assets is thrown otherwise.
  • all(wb.lb .<= c). A lower bound above the score bound admits no weight. A DomainError that 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. A DomainError that 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

source