Naive optimisation: private API
PortfolioOptimisers.NaiveOptimisationEstimator — Type
abstract type NaiveOptimisationEstimator <: NonFiniteAllocationOptimisationEstimatorAbstract 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
PortfolioOptimisers.is_time_dependent — Method
is_time_dependent(opt::NaiveOptimisationEstimator) -> Any
Return true when a field of the naive optimiser holds a TimeDependent schedule, or when its fallback fb is time-dependent.
Related
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
- Return
optunchanged whenis_time_dependentisfalse. - Replace each
TimeDependentfield ofoptwith its entry oftime_dependent_field_defaults, withreset_time_dependent_fields, givingopt. - Reset the fallback
opt.fbthe same way, and rebuildoptwith it.
Related
PortfolioOptimisers.assert_internal_optimiser — Method
assert_internal_optimiser(_::NaiveOptimisationEstimator)
Assert internal validity for a naive optimisation estimator.
The default method checks nothing and returns nothing.
Related
PortfolioOptimisers.assert_external_optimiser — Method
assert_external_optimiser(_::NaiveOptimisationEstimator)
Assert external validity for a naive optimisation estimator.
The default method checks nothing and returns nothing. InverseVolatility overrides it, because its prior estimator can hold a result.
Related
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
PortfolioOptimisers.assert_external_optimiser — Method
assert_external_optimiser(opt::InverseVolatility)
Assert that InverseVolatility is valid for external use.
It throws an ArgumentError when opt.pe holds an AbstractPriorResult, directly or through a TimeDependent schedule.
Related
PortfolioOptimisers.failed_hold_weights — Function
failed_hold_weights(X::Nothing)
failed_hold_weights(X::MatNum)Return the weights of a PreviousWeights that has nothing to hold.
The weights are NaN at every column of X, or nothing when X is nothing. They take the element type of X, which must hold NaN.
Related
PortfolioOptimisers.CoverFixedPointFit — Type
struct CoverFixedPointFit{__T_w, __T_log_wealth, __T_gap, __T_converged, __T_iterations} <: AbstractResultThe 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})$ atw.
gap:gap: The certificate atw, an upper bound on the optimal log wealth minuslog_wealth.
converged:converged: Whethergapmet the tolerance.
iterations:iterations: The number of multiplicative steps, zero when the uniform start already meets the tolerance.
Related
PortfolioOptimisers.cover_fixed_point — Function
cover_fixed_point(X::MatNum, iters::Integer, tol::Number) -> CoverFixedPointFitRun 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
- Start from the uniform portfolio
w, $1/N$ for every asset, so that every asset can take weight. - Compute the gross returns
p = X * w, the log wealthlw, the multipliersgasX' * inv.(p) / T, and the certificategap, $T \log \max_i g_i$ clamped at zero. - Stop, with
converged = true, whengapis at mosttol * max(1, abs(lw)). - Stop, with
converged = false, afteriterssteps. - Otherwise multiply
wbygentry by entry, divide it by its sum to remove the round-off, add one toiterations, 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. SeeCoverFixedPointFit.
Related
PortfolioOptimisers.group_frames — Method
group_frames(iv::InverseVolatility) -> ReturnsFramesWalk the readers of an InverseVolatility head, for the warning of a forgotten raw reader and the gap rule of the head. The only reader of the head is its prior pe. field_frames walks every field, and the walk stops at the fallback.
Arguments
iv: The head.
Returns
fr::ReturnsFrames: The frames of the group ofiv.
Related