The algorithms of the short-term sparse portfolio: private API

PortfolioOptimisers.huber_multiplier — Function
huber_multiplier(
    alg::HuberOptimum,
    phi::AbstractVector,
    lo::Real,
    hi::Real
) -> Any

Finds the multiplier of HuberOptimum in [lo, hi].

The sum of the coordinates is linear between two knots, so the linear interpolation between the two knots that bracket the root gives the root.

Algorithm

  1. Compute budget(nu), the sum of the coordinates of huber_coordinates at a multiplier nu.
  2. When budget(lo) <= 1, return lo. When budget(hi) >= 1, return hi.
  3. Collect the knots -phi .- lambda and -phi .+ lambda that lie strictly between lo and hi, giving inner.
  4. Sort inner, and put lo before it and hi after it, giving knots.
  5. Compute sums, the budget at each knot.
  6. Find the first knot i whose sum is at most one.
  7. Interpolate linearly between the knots i - 1 and i, and return the multiplier where the budget is one.

Related

source
PortfolioOptimisers.huber_remainder! — Function
huber_remainder!(
    b::AbstractVector,
    phi::AbstractVector
) -> AbstractVector

Adds the remainder of the budget to b in place, in equal parts between tied assets.

At an end of the interval of the multiplier, the assets that take the remainder are the assets where the Huber penalty is linear, so they can hold any amount past gamma. Inside the interval the remainder is rounding.

Algorithm

  1. Compute the remainder r = 1 - sum(b).
  2. Find the assets K, which have the smallest entry of phi when r is not negative, and the largest entry when r is negative.
  3. Add r / count(K) to each asset of K, and return b.

Related

source