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:truewhen the slot holds such an estimator.
Related
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:truewhen the slot holds an exposure estimator.
Related
PortfolioOptimisers.fitted_on_rows — Function
fitted_on_rows(x)
fitted_on_rows(x::AbstractVector)Tells whether a centrality or phylogeny slot holds an estimator that the set fits on the head's rows at every step.
A precomputed LinearConstraint, IntegerPhylogeny or SemiDefinitePhylogeny reads no rows. A vector reads the rows when one of its entries does.
Returns
::Bool:truewhen the slot holds a centrality or phylogeny estimator.
Related
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). ADomainErroris thrown otherwise.
Returns
nothing.
Related
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
- Check that
Σ lb ≤ 1 ≤ Σ ubwithassert_feasible_bounds. - When the floors sum to one, return
lb. - Collect the finite entries of
binfinite, and refuse an emptyfinite. - Write the clipped budget
f(mu). An asset whose baseb_i + muis at or below zero takesub_i, and every other asset takesclamp(phi(b_i + mu), lb_i, ub_i). - Set the lower end
lo = -maximum(finite), at which every finite entry is at its cap. Refusef(lo) < 1. - Find the upper end
hiwithbarrier_upper_bracket. - Bisect
[lo, hi]formuwithbounded_root. - Return the clipped allocation at
mu.
Arguments
b: The mirror image of the raw step,Infat a zero entry.phi: The inverse mirror map of a positive base.wb: The resolved bounds.
Validation
Σ lb ≤ 1 ≤ Σ ub. AnArgumentErroris thrown otherwise.- At least one raw entry is positive. A
DomainErroris thrown otherwise. - The caps of the positive entries and the floors of the zero entries reach the budget. A
DomainErroris thrown otherwise, because a zero entry stays at its floor under a barrier.
Returns
w'::Vector: The projected allocation, a new vector.
Related
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
- Start from
hi = max(lo, 0) + 1. - Double
hiwhilef(hi) > 1. - 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
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
qis finite and non-negative. ADomainErroris thrown otherwise. all(>= 0, wb.lb). ADomainErroris thrown otherwise.
Returns
nothing.
Related
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
- Under
EntropicProjection,TsallisProjectionorLogBarrierProjectionwith aWeightBoundswhoselbis a number or a vector:all(>= 0, lb). ADomainErroris thrown otherwise.
Returns
nothing.
Related