Naive optimisation: private API

PortfolioOptimisers.NaiveOptimisationEstimator — Type
abstract type NaiveOptimisationEstimator <: NonFiniteAllocationOptimisationEstimator

Abstract supertype for the optimisers that compute portfolio weights without a solver.

Each subtype gives its weights by a closed form, a random draw, a fixed-point iteration or a copy of the weights it holds, and then imposes its weight bounds with its weight finaliser. PreviousWeights is the exception. It holds its weights as it was given them, and imposes no bounds. Every subtype carries a fees field and a fallback fb, and gives a NaiveOptimisationResult.

Related

source
PortfolioOptimisers.reset_time_dependent_estimator — Method
reset_time_dependent_estimator(
    opt::NaiveOptimisationEstimator
) -> Any

Replace every TimeDependent field of a naive optimiser with its static default, and do the same to its fallback fb.

A fold-less optimise calls it first, so the fit runs with each schedule at its static default.

Algorithm

  1. Return opt unchanged when is_time_dependent is false.
  2. Replace each TimeDependent field of opt with its entry of time_dependent_field_defaults, with reset_time_dependent_fields, giving opt.
  3. Reset the fallback opt.fb the same way, and rebuild opt with it.

Related

source
PortfolioOptimisers.naive_optimiser_td_defaults — Function
naive_optimiser_td_defaults(

) -> @NamedTuple{wb::WeightBounds{Float64, Float64}, wf::IterativeWeightFinaliser{Int64}}

Return the static defaults of the naive-optimiser fields that can hold a TimeDependent.

The constructors pass these defaults to assert_time_dependent_substitution, and time_dependent_field_defaults returns them, so the value of a field outside a fold is written once. A field whose static default is nothing has no entry. RandomWeighted overrides the trait, because its wb default is nothing. InverseVolatility adds its prior estimator pe.

Related

source
PortfolioOptimisers.CoverFixedPointFit — Type
struct CoverFixedPointFit{__T_w, __T_log_wealth, __T_gap, __T_converged, __T_iterations} <: AbstractResult

The fit of one run of Cover's fixed-point iteration: the weights, the log wealth at the weights, the certificate of the shortfall, and how the run stopped.

This type is an implementation detail and is not intended for direct use. cover_fixed_point makes it. optimise reads it.

Fields

  • w: w: The weights, on the simplex.
  • log_wealth: log_wealth: $\sum_t \log(\boldsymbol{x}_t^{\intercal} \boldsymbol{w})$ at w.
  • gap: gap: The certificate at w, an upper bound on the optimal log wealth minus log_wealth.
  • converged: converged: Whether gap met the tolerance.
  • iterations: iterations: The number of multiplicative steps, zero when the uniform start already meets the tolerance.

Related

source
PortfolioOptimisers.cover_fixed_point — Function
cover_fixed_point(X::MatNum, iters::Integer, tol::Number) -> CoverFixedPointFit

Run Cover's fixed-point iteration for the best constant rebalanced portfolio over a matrix of price relatives.

It is the kernel of BestConstantRebalancedPortfolio, on a bare matrix, so a rule that re-solves the portfolio can call it directly. The map, the multipliers $g_i$ and the certificate are the ones that BestConstantRebalancedPortfolio states.

Algorithm

  1. Start from the uniform portfolio w, $1/N$ for every asset, so that every asset can take weight.
  2. Compute the gross returns p = X * w, the log wealth lw, the multipliers g as X' * inv.(p) / T, and the certificate gap, $T \log \max_i g_i$ clamped at zero.
  3. Stop, with converged = true, when gap is at most tol * max(1, abs(lw)).
  4. Stop, with converged = false, after iters steps.
  5. Otherwise multiply w by g entry by entry, divide it by its sum to remove the round-off, add one to iterations, and go back to step 2.

Arguments

  • X: Price relatives, observations × assets, every entry positive.
  • iters: Maximum number of iterations.
  • tol: Relative tolerance on the certificate of the shortfall in log wealth.

Returns

  • fp::CoverFixedPointFit: The record of the fixed point, with five fields. See CoverFixedPointFit.

Related

source