Stacking: private API

PortfolioOptimisers.BaseStackingOptimisationEstimator — Type
abstract type BaseStackingOptimisationEstimator <: NonFiniteAllocationOptimisationEstimator

Abstract supertype of the optimisers that combine several inner optimisers through one outer optimiser.

A stacking optimiser treats the portfolio of each inner optimiser as one synthetic asset, and an outer optimiser allocates across these synthetic assets. So the returns of the inner portfolios set their weights, and no fixed rule averages them. This is the stacked generalisation of [246], with portfolios in place of predictors.

No method of the library dispatches on this type, so a subtype implements no method for it. Stacking is its one subtype.

Related

References

  • [246] D. H. Wolpert. Stacked generalization. Neural Networks 5, 241–259 (1992).
source
PortfolioOptimisers.stacking_td_defaults — Function
stacking_td_defaults(

) -> @NamedTuple{pe::EmpiricalPrior{PortfolioOptimisersCovariance{Covariance{SimpleExpectedReturns{Nothing, Nothing, Nothing}, GeneralCovariance{SimpleCovariance, Nothing, Nothing}, FullMoment, Nothing, Nothing, Nothing}, MatrixProcessing{Posdef{UnionAll, @NamedTuple{}}, Nothing, Nothing, Nothing, NTuple{4, Symbol}}, Nothing}, SimpleExpectedReturns{Nothing, Nothing, Nothing}, Nothing, Nothing, Nothing, Nothing, Nothing}, opti::NoDefault, opto::NoDefault, wf::IterativeWeightFinaliser{Int64}}

Return the static defaults of the Stacking fields that can hold a TimeDependent schedule.

The constructor reads them when it tests each entry of a schedule, and time_dependent_field_defaults returns them. opti and opto are required and have no static default, so their entry is NoDefault. A schedule in one of them must carry its own default, or it cannot run outside a fold loop. The entries of pe and wf are their keyword defaults. The tuple holds no entry for wb, fees, sets, scale and fb, because their static default is nothing.

Returns

  • NamedTuple: The defaults of pe, opti, opto and wf.

Related

source
PortfolioOptimisers.erase_optimiser_vector — Function
erase_optimiser_vector(opti::AbstractVector) -> Any

Erase the element type of a vector of inner optimisers to OptE_Opt_TD, so that the type of a Stacking does not change with the types of its inner optimisers.

A literal such as [MeanRisk(), TimeDependent(…)] infers the element type AbstractEstimator. The VecOptE_Opt_TD bound refuses that type, but it accepts each element. So the keyword constructor of Stacking calls this method on opti. The positional constructor calls it too, so a vector that a lens writes, or that a schedule resolves to, leaves with the same element type.

The element type is erased and not narrowed. A narrow element type, the union of the types of the elements, puts the type of each inner optimiser into the type of the Stacking, and optimise then compiles again for each combination of inner optimisers. The loop over opti dispatches on each element at run time, and that dispatch costs nothing next to the inner solve.

Algorithm

  1. Check that every element of opti is an OptE_Opt_TD.
  2. Convert opti to a Vector{OptE_Opt_TD}. A vector of that type returns unchanged.

The method for a TimeDependent returns the schedule unchanged.

Arguments

  • opti: Vector of inner optimisers, or a TimeDependent schedule for the whole field.

Validation

  • Every element of opti is an OptE_Opt_TD. The method throws an ArgumentError otherwise.

Returns

  • The Vector{OptE_Opt_TD} of the same elements, or the schedule itself.

Related

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

Replace each TimeDependent field of a Stacking with its static default.

The method does not recurse into the optimisers that opt holds. The inner cross-validation of opt resolves the element schedules of opti for each fold, and each full-sample inner solve resets its own schedules in its own _optimise. An element schedule of opti stays in place, because opti is then a vector and not a schedule. A field schedule of opti binds :outermost, and the method replaces it with its default.

Arguments

  • opt: The stacking optimiser.

Returns

  • Stacking: The optimiser with no schedule in its own fields.

Related

source
PortfolioOptimisers.assert_special_nco_requirements_stacking_opti — Function
assert_special_nco_requirements_stacking_opti(
    opti::AbstractVector
)

Refuse a precomputed result among the inner optimisers of a Stacking that a NestedClustered holds.

NestedClustered solves its inner optimiser on each cluster, and its outer optimiser on the synthetic assets of the clusters. So a Stacking inside it runs on a universe that it does not know in advance. A NonFiniteAllocationOptimisationResult holds weights over the universe of its own solve, so it cannot give the returns of a synthetic asset on a new universe. A Stacking that runs alone accepts a result in opti.

assert_special_nco_requirements calls this method on opti, and on each entry and the default of a schedule in opti.

Arguments

  • opti: Inner optimisers of the Stacking.

Validation

Returns

  • nothing.

Related

source

References

[246]
D. H. Wolpert. Stacked generalization. Neural Networks 5, 241–259 (1992).