L1 uncertainty sets: private API

PortfolioOptimisers.expand_investable_ucs — Method
expand_investable_ucs(
    set::L1UncertaintySet,
    imsk::BitVector,
    pr::AbstractPriorResult
) -> L1UncertaintySet

Writes an L1UncertaintySet fitted on the Investable Mask back onto the full asset universe.

The expansion is the inverse of port_opt_view. The view slices sd and mu by the asset index, and keeps the radius. So the view removes all of the frame outside the mask, and it gives back the fitted set. The radius is one budget for the total error over the assets that the set covers, so it passes through.

The scale sd is geometry. The set is the norm ball with the map $\mathrm{diag}(\boldsymbol{\sigma})$, so the frame is zero and not NaN, as the zero row of the map of a NormBallUncertaintySet. A zero scale fixes the entry at its estimate, so the set moves nothing on an asset that the prior did not estimate. The worst case $\epsilon \lVert \boldsymbol{\sigma} \odot \boldsymbol{w} \rVert_{\infty}$ then reads only the assets inside the mask. A sd of nothing holds no entry for an asset, so it passes through, and the view gives back nothing. The centre mu is the full pr.mu, with its NaN entries, as the centre val of the other sets.

Algorithm

  1. If set.sd is nothing, keep nothing. Else, make a zero frame of length(imsk) entries, and write set.sd at the entries that the mask keeps.
  2. Build an L1UncertaintySet from set.eps and the frame, with pr.mu as mu.

Arguments

  • set: $\ell_1$ uncertainty set, fitted on the reduced prior.
  • imsk: The Investable Mask of the full prior.
  • pr: Prior result.

Returns

  • set::L1UncertaintySet: The set on the full asset universe.

Related

source
PortfolioOptimisers.expand_investable_ucs — Method
expand_investable_ucs(
    set::SignedL1UncertaintySet,
    imsk::BitVector,
    pr::AbstractPriorResult
) -> SignedL1UncertaintySet

Writes a SignedL1UncertaintySet fitted on the Investable Mask back onto the full asset universe.

The expansion is the inverse of port_opt_view, and it writes the same frame as the L1UncertaintySet method. The two radii are budgets for the total error of each sign over the assets that the set covers, so they pass through. The scale sd is geometry, so its frame is zero. A zero scale fixes the entry at its estimate, and the two positive parts of the worst case then read only the assets inside the mask. A sd of nothing passes through. The centre mu is the full pr.mu, with its NaN entries.

Algorithm

  1. If set.sd is nothing, keep nothing. Else, make a zero frame of length(imsk) entries, and write set.sd at the entries that the mask keeps.
  2. Rebuild the set from the frame, with pr.mu as mu, with rebuild_struct. set.ep and set.en do not change.

Arguments

  • set: Signed $\ell_1$ uncertainty set, fitted on the reduced prior.
  • imsk: The Investable Mask of the full prior.
  • pr: Prior result.

Returns

  • set::SignedL1UncertaintySet: The set on the full asset universe.

Related

source
PortfolioOptimisers.l1_activation_ladder — Function
l1_activation_ladder(mu::VecNum, sd::Option{<:VecNum})

Return the vector g whose k-th entry is the radius at which the k-th asset becomes active in the long-only problem.

mu must be sorted in non-increasing order. If sd is a vector, it must have the same permutation.

Mathematical definition

\[\begin{align} L_k &= \sum_{i=1}^{k} \frac{\hat{\mu}_i - \hat{\mu}_k}{\sigma_i}\,, \quad k = 1,\, \ldots,\, N\,. \end{align}\]

Where:

  • $L_k$: Activation threshold of the $k$-th asset of the ranking.
  • $\hat{\mu}_i$: $i$-th entry of the characteristic vector, sorted non-increasing.
  • $\sigma_i$: Scale factor of the $i$-th entry of the characteristic vector. It is $1$ when the set has no scaling.
  • $N$: Number of assets.

$L_k$ is the threshold of Lemma 2 of [8] when $\sigma_i = 1$, and of its Lemma 9 when the ladder is scaled. Both lemmas state that the number of active assets is the largest $k$ with $L_k < \epsilon$. So a radius in the open interval $(L_q,\, L_{q+1})$ activates exactly $q$ assets. The active weights are equal under Lemma 2, and they are inverse-volatility weights under Lemma 9. Corollaries 4 and 11 of [8] apply this result at the quintile.

The sequence has two properties. Every summand of $L_1$ is zero, so $L_1 = 0$, and a radius above zero always activates at least one asset. The difference of two adjacent rungs is $L_{k+1} - L_k = \sum_{i=1}^{k} (\hat{\mu}_k - \hat{\mu}_{k+1}) / \sigma_i \geq 0$, because the ranking is non-increasing. The sum stops at $k$ because the summand $i = k+1$ of $L_{k+1}$ is zero. So the sequence is non-decreasing, and two adjacent rungs bracket each count.

Two adjacent rungs are equal exactly when $\hat{\mu}_k = \hat{\mu}_{k+1}$. [8] admits such a tie. Its Assumption 1 excludes only a radius equal to a rung, so that the number of active assets is unique.

Algorithm

  1. Read N = length(mu), the number of rungs to build.
  2. For each k in 1:N, sum $(\hat{\mu}_i - \hat{\mu}_k) / \sigma_i$ over i in 1:k. Use $\sigma_i = 1$ when sd is nothing. The sum is the k-th rung.

Arguments

  • mu: Characteristic vector, sorted in non-increasing order.
  • sd: Scaling of each asset in the same permutation, or nothing for a ladder with no scaling.

Returns

  • g::Vector{<:Number}: The Activation Ladder, with one rung for each asset.

Examples

julia> PortfolioOptimisers.l1_activation_ladder([0.125, 0.0625, 0.03125], nothing)3-element Vector{Float64}: 0.0 0.0625 0.125julia> PortfolioOptimisers.l1_activation_ladder([0.125, 0.0625, 0.03125], [0.5, 0.25, 0.125])3-element Vector{Float64}: 0.0 0.125 0.3125

Related

References

  • [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
source
PortfolioOptimisers.l1_active_count — Function
l1_active_count(active::CountOf, N::Integer)
l1_active_count(active::FractionOf, N::Integer)

Convert an active target, a count or a fraction of the universe, to a number of assets in 1:N.

The member of AbstractCountOrFraction selects the rule. The function clamps a target outside 1:N, and it does not throw an error. A count above N becomes N, and a fraction that rounds to zero becomes 1.

Algorithm

  1. For a CountOf, use active.val as the count q.
  2. For a FractionOf, take q = round(Int, active.val * N), the fraction of the universe rounded to the nearest asset.
  3. Return clamp(q, 1, N), a count that the ranking can give.

Arguments

  • active: Target number of active assets, as a CountOf of assets or a FractionOf of the universe.
  • N: Number of assets in the universe.

Returns

  • q::Int: The target count, in 1:N.

Examples

julia> PortfolioOptimisers.l1_active_count(CountOf(3), 10)3julia> PortfolioOptimisers.l1_active_count(FractionOf(0.2), 10)2julia> PortfolioOptimisers.l1_active_count(CountOf(20), 10)10

Related

References

  • [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
source
PortfolioOptimisers.l1_active_pairs — Function
l1_active_pairs(active::CountOf, N::Integer)
l1_active_pairs(active::FractionOf, N::Integer)

Convert an active target, a count or a fraction of the universe, to a number of long and short pairs for the paired ladder of l1_resolve_eps.

active counts assets, and each entry of the paired ladder activates a pair of one long asset and one short asset. A count and the equal fraction give the same number of pairs when the count is even. For an odd count, the integer division rounds down and the fraction rounds to the nearest integer, so the two can differ by one pair. For example, with N = 10, CountOf(7) gives three pairs, and FractionOf(0.7) gives four.

Algorithm

  1. For a CountOf, return max(active.val ÷ 2, 1).
  2. For a FractionOf, return clamp(round(Int, active.val * N / 2), 1, N ÷ 2).

Arguments

  • active: Target number of active assets, as a CountOf of assets or a FractionOf of the universe.
  • N: Number of assets in the universe.

Returns

  • q::Int: The target number of pairs.

Examples

julia> PortfolioOptimisers.l1_active_pairs(CountOf(7), 10)3julia> PortfolioOptimisers.l1_active_pairs(FractionOf(0.7), 10)4

Related

References

  • [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020). Corollary 7.
source
PortfolioOptimisers.l1_eps_from_ladder — Function
l1_eps_from_ladder(method, ladder::VecNum, q::Int)

Find the radius of a Num_UcSEps on an Activation Ladder.

The method that takes a Number returns the radius that the caller gave. It has no procedure, so the # Algorithm and # Validation sections are not about it. The method that takes an ActiveAssetsUncertaintyAlgorithm returns the midpoint of the open interval $(L_q,\, L_{q+1})$. The closed forms of [8] need a radius in that interval for exactly q active entries.

Every radius above the last rung activates every entry. So the top of the ladder has no interval with a midpoint, and the method adds half of the last increment to the last rung. A ladder of one rung has no increment, and the method returns one(eltype(ladder)). That radius has no effect. A ladder of one rung belongs to a universe of one asset, where the budget sets the single weight. Every radius then gives the same portfolio.

Algorithm

  1. Read L = length(ladder), the number of rungs.
  2. Clamp q to 1:L, so that the target is a rung of the ladder.
  3. If q < L, read lo, hi = ladder[q], ladder[q+1], the two rungs on each side of the target. Return their midpoint, a radius inside the open interval.
  4. Else, q == L. If L == 1, return one(eltype(ladder)), because the ladder has no increment. Else, return ladder[L] + (ladder[L] - ladder[L-1]) / 2, half of the last increment above the last rung.

Arguments

Validation

  • length(ladder) >= 1. Else, the method throws an IsEmptyError.
  • ladder[q+1] > ladder[q] when q < L. Else, the method throws a DomainError. The two rungs are equal when the q-th and the (q+1)-th entries of the ranking are equal. The interval that the closed form needs is then empty, and no radius gives the target count. [8] admits ties, and its Assumption 1 excludes only a radius equal to a rung. The midpoint needs a strictly increasing ladder, so the message names two fixes. The caller can break the tie, or give a radius.

Returns

  • eps::Number: The radius.

Examples

julia> PortfolioOptimisers.l1_eps_from_ladder(0.5)0.5julia> alg = ActiveAssetsUncertaintyAlgorithm(; active = 2);julia> PortfolioOptimisers.l1_eps_from_ladder(alg, [0.0, 0.0625, 0.125], 2)0.09375julia> PortfolioOptimisers.l1_eps_from_ladder(alg, [0.0, 0.0625, 0.125], 3)0.15625julia> PortfolioOptimisers.l1_eps_from_ladder(alg, [0.0], 1)1.0

Related

References

  • [8] R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).
source

References

[8]
R. Zhou and D. P. Palomar. Understanding the Quintile Portfolio. IEEE Transactions on Signal Processing 68, 4030–4040 (2020).