Skip to content
13

Stacking

PortfolioOptimisers.BaseStackingOptimisationEstimator Type
julia
abstract type BaseStackingOptimisationEstimator <: NonFiniteAllocationOptimisationEstimator

Abstract supertype for stacking-based portfolio optimisation estimators.

Related Types

source
PortfolioOptimisers.StackingResult Type
julia
struct StackingResult{__T_oe, __T_pr, __T_wb, __T_fees, __T_resi, __T_reso, __T_cv, __T_retcode, __T_w, __T_fb} <: NonFiniteAllocationOptimisationResult

Result type for Stacking portfolio optimisation.

Fields

  • oe: Type of the optimisation estimator that produced this result.

  • pr: Prior result used in optimisation.

  • wb: Weight bounds applied.

  • fees: Fee structure applied (or nothing).

  • resi: Inner optimisation results.

  • reso: Outer optimisation result.

  • cv: Cross-validation result (or nothing).

  • retcode: Overall return code.

  • w: Final aggregated portfolio weights.

  • fb: Fallback result.

Related

source
PortfolioOptimisers.Stacking Type
julia
struct Stacking{__T_pe, __T_wb, __T_fees, __T_sets, __T_scale, __T_opti, __T_opto, __T_cv, __T_wf, __T_ex, __T_fb, __T_brt, __T_strict} <: BaseStackingOptimisationEstimator

Stacking portfolio optimiser.

Stacking implements a stacking (model combination) approach to portfolio optimisation. It applies multiple inner optimisers (opti) to the data, then combines their outputs with a single outer optimiser (opto) to produce a final portfolio. Optionally, cross-validation can be used to weight the inner optimisers' contributions.

Fields

  • pe: Prior estimator or prior result.

  • wb: Weight bounds estimator or bounds.

  • fees: Fee estimator or fee structure.

  • sets: Asset sets.

  • scale: Optional scaling vector for inner optimiser weights (length must match opti).

  • opti: Vector of inner portfolio optimisers.

  • opto: Outer portfolio optimiser combining inner results.

  • cv: Cross-validation configuration for weighting inner optimisers.

  • wf: Weight finaliser for enforcing bounds.

  • ex: FLoops executor for parallelism.

  • fb: Fallback optimiser.

  • brt: If true, uses bootstrap returns.

  • strict: If true, strictly enforces weight bounds.

Constructors

julia
Stacking(;
    pe::PrE_Pr = EmpiricalPrior(),
    wb::Option{<:WbE_Wb} = nothing,
    fees::Option{<:FeesE_Fees} = nothing,
    sets::Option{<:AssetSets} = nothing,
    scale::Option{<:VecNum} = nothing,
    opti::VecOptE_Opt,
    opto::NonFiniteAllocationOptimisationEstimator,
    cv::Option{<:OptimisationCrossValidation} = nothing,
    wf::WeightFinaliser = IterativeWeightFinaliser(),
    ex::FLoops.Transducers.Executor = FLoops.ThreadedEx(),
    fb::Option{<:OptE_Opt} = nothing,
    brt::Bool = false,
    strict::Bool = false
) -> Stacking

Keywords correspond to the struct's fields.

Validation

  • !isempty(opti).

  • If scale is provided: length(scale) == length(opti) and all elements are finite.

Related

source
PortfolioOptimisers.predict_outer_st_estimator_returns Function

Overload this using st.cv for custom cross-validation prediction

source
PortfolioOptimisers.assert_special_nco_requirements Method
julia
assert_special_nco_requirements(opt)

Assert that the optimiser meets special requirements for Nested Clustered Optimisation (NCO).

The default implementation does nothing. Overridden for estimators (e.g. Stacking) that have requirements which must be validated before NCO can proceed.

Arguments

  • opt: Optimisation estimator, result, or vector thereof.

Returns

  • nothing.

Related

source
PortfolioOptimisers.optimise Method
julia
optimise(st::Stacking{<:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any, <:Any,
                 <:Any, <:Any, Nothing
             }, rd::ReturnsResult;
         dims::Int = 1, branchorder::Symbol = :optimal, str_names::Bool = false,
         save::Bool = true, kwargs...) -> StackingResult

Arguments

  • nco: The nested clustered optimiser to use.

  • rd: The returns result to use.

  • dims: The dimension along which observations advance in time.

  • branchorder: Passed to the inner and outer optimisers. The branch order to use for the clusterisation.

  • str_names: Passed to the inner and outer optimisers. Whether to use string names for the assets in the optimisation.

  • save: Passed to the inner and outer optimisers. Whether to save the JuMP model in the optimisation result.

  • kwargs: Additional keyword arguments passed to the optimisation function.

source