The programme Allocation Set and the Constrained Update's programme: private API

PortfolioOptimisers.name_keyed — Function
name_keyed(x)
name_keyed(x::AbstractVector)

Tells whether a constraint slot holds an estimator that resolves its names over sets.

The owner of such a slot must carry sets. The estimators are WeightBoundsEstimator, LinearConstraintEstimator, ExposureConstraintEstimator, ThresholdEstimator, AssetSetsMatrixEstimator and TurnoverEstimator. A vector is keyed by name when one of its entries is.

Returns

  • ::Bool: true when the slot holds such an estimator.

Related

source
PortfolioOptimisers.exposure_keyed — Function
exposure_keyed(x)
exposure_keyed(x::AbstractVector)

Tells whether a linear-constraint slot holds an ExposureConstraintEstimator.

An exposure estimator writes its rows in the basis of the factors, and the loadings of a factor prior take them to the assets. So such a slot resolves on the head's rows at every step, and not once per fold. A vector is keyed by exposure when one of its entries is.

Returns

  • ::Bool: true when the slot holds an exposure estimator.

Related

source
PortfolioOptimisers.assert_mirror_base — Function
assert_mirror_base(base::AbstractVector, s::AbstractVector)

Refuses a barrier mirror step that has a base at or below zero.

The error names the scaled gradient s that gave the base.

Validation

  • all(> 0, base). A DomainError is thrown otherwise.

Returns

  • nothing.

Related

source
PortfolioOptimisers.barrier_projection — Function
barrier_projection(
    b::AbstractVector,
    phi,
    wb::WeightBounds
) -> Any

Projects a raw step onto a bounded set in a barrier geometry, through the scalar root of the budget.

The root is the budget multiplier mu at which Σ_i clip(phi(b_i + mu), lb_i, ub_i) is one. Here b is the mirror image of the raw step and phi is the inverse mirror map. A base at or below zero puts its asset at its cap. phi decreases on positive bases and has no bound as the base falls to zero, so the clipped budget does not increase in mu and has no jump. A zero raw entry has the base Inf, and it stays at its floor. TsallisProjection and LogBarrierProjection state the root as $\boldsymbol{w}(\theta)$.

Algorithm

  1. Check that Σ lb ≤ 1 ≤ Σ ub with assert_feasible_bounds.
  2. When the floors sum to one, return lb.
  3. Collect the finite entries of b in finite, and refuse an empty finite.
  4. Write the clipped budget f(mu). An asset whose base b_i + mu is at or below zero takes ub_i, and every other asset takes clamp(phi(b_i + mu), lb_i, ub_i).
  5. Set the lower end lo = -maximum(finite), at which every finite entry is at its cap. Refuse f(lo) < 1.
  6. Find the upper end hi with barrier_upper_bracket.
  7. Bisect [lo, hi] for mu with bounded_root.
  8. Return the clipped allocation at mu.

Arguments

  • b: The mirror image of the raw step, Inf at a zero entry.
  • phi: The inverse mirror map of a positive base.
  • wb: The resolved bounds.

Validation

  • Σ lb ≤ 1 ≤ Σ ub. An ArgumentError is thrown otherwise.
  • At least one raw entry is positive. A DomainError is thrown otherwise.
  • The caps of the positive entries and the floors of the zero entries reach the budget. A DomainError is thrown otherwise, because a zero entry stays at its floor under a barrier.

Returns

  • w'::Vector: The projected allocation, a new vector.

Related

source
PortfolioOptimisers.barrier_upper_bracket — Function
barrier_upper_bracket(f, lo) -> Any

Finds the upper end of the bracket of a barrier root, a positive multiplier above lo at which the clipped budget is at most one.

The loop stops, because the clipped budget tends to Σ lb < 1 as the multiplier grows. barrier_projection returns lb before it calls this function when Σ lb = 1.

Algorithm

  1. Start from hi = max(lo, 0) + 1.
  2. Double hi while f(hi) > 1.
  3. Return hi.

Arguments

  • f: The clipped budget as a function of the multiplier, non-increasing.
  • lo: The lower end of the bracket.

Returns

  • hi: The upper end of the bracket.

Related

source
PortfolioOptimisers.assert_barrier_raw_step — Function
assert_barrier_raw_step(q::AbstractVector, wb::WeightBounds)

Refuses, for a barrier geometry, a raw step with a negative or non-finite entry, and a bound with a negative floor.

The potential of a barrier geometry is undefined below zero.

Validation

  • Every entry of q is finite and non-negative. A DomainError is thrown otherwise.
  • all(>= 0, wb.lb). A DomainError is thrown otherwise.

Returns

  • nothing.

Related

source
PortfolioOptimisers.assert_geometry_admits_set — Function
assert_geometry_admits_set(proj::AbstractProjectionGeometry, set::AbstractAllocationSet)

Refuses a negative lower bound under a geometry whose potential is undefined below zero.

The head calls this function at its construction, with the geometry of its rule and its set. The entropic, Tsallis and log-barrier geometries refuse a negative bound. This function refuses a bound that is a value. The projection refuses a bound that an estimator resolves. The Euclidean, Gram and diagonal geometries admit a negative bound, so a long-short rule needs no other set.

Validation

Returns

  • nothing.

Related

source