Skip to content
13

Subset resampling

PortfolioOptimisers.BaseSubsetResamplingOptimisationEstimator Type
julia
abstract type BaseSubsetResamplingOptimisationEstimator <: NonFiniteAllocationOptimisationEstimator

Abstract supertype for subset resampling portfolio optimisation estimators.

Related Types

source
PortfolioOptimisers.SubsetResamplingResult Type
julia
struct SubsetResamplingResult{__T_oe, __T_pr, __T_wb, __T_fees, __T_ress, __T_idx, __T_retcode, __T_w, __T_fb} <: NonJuMPOptimisationResult

Result type for Subset Resampling portfolio optimisation.

Fields

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

  • pr: Prior result.

  • wb: Weight bounds.

  • fees: Fees estimator or result.

  • ress: Vector of sub-optimisation results for each subset.

  • idx: Index vector.

  • retcode: Optimisation return code.

  • w: Aggregated optimal portfolio weights.

  • fb: Fallback result or estimator.

Related

source
PortfolioOptimisers.factory Method
julia
factory(
    sr::SubsetResamplingResult,
    fb::Union{Nothing, NonFiniteAllocationOptimisationEstimator, NonFiniteAllocationOptimisationResult}
) -> SubsetResamplingResult

Rebuild a SubsetResamplingResult with an updated fallback optimiser fb.

source
PortfolioOptimisers.SubsetResampling Type
julia
struct SubsetResampling{__T_pe, __T_wb, __T_fees, __T_sets, __T_scale, __T_opt, __T_wf, __T_ex, __T_subset_size, __T_n_subsets, __T_max_comb, __T_rng, __T_seed, __T_fb, __T_brt, __T_strict} <: BaseSubsetResamplingOptimisationEstimator

Subset Resampling portfolio optimiser.

SubsetResampling applies a resampling strategy by optimising a base optimiser (opt) over randomly drawn subsets of assets, then aggregating the results into a final portfolio weight vector. This improves robustness of portfolio weights to estimation error.

Fields

  • pe: Prior estimator.

  • wb: Weight bounds estimator or weight bounds.

  • fees: Fees estimator.

  • sets: Sets used to map estimator values to features.

  • scale: Optional scaling vector for subset optimiser weights.

  • opt: Base portfolio optimiser applied to each asset subset.

  • wf: Weight finaliser.

  • ex: Parallel execution strategy.

  • subset_size: Size of each random subset.

  • n_subsets: Number of random subsets.

  • max_comb: Maximum number of unique asset subsets.

  • rng: Random number generator.

  • seed: Seed for the random number generator.

  • fb: Fallback result or estimator.

  • brt: Whether to use bootstrap returns.

  • strict: Whether to strictly enforce weight bounds.

Constructors

julia
SubsetResampling(;
    pe::PrE_Pr = EmpiricalPrior(),
    wb::Option{<:WbE_Wb} = nothing,
    fees::Option{<:FeesE_Fees} = nothing,
    sets::Option{<:AssetSets} = nothing,
    scale::Option{<:VecNum} = nothing,
    opt::NonFiniteAllocationOptimisationEstimator,
    wf::WeightFinaliser = IterativeWeightFinaliser(),
    ex::FLoops.Transducers.Executor = FLoops.ThreadedEx(),
    subset_size::SubsetSizeE = 0.5,
    n_subsets::NumberSubsetsE = 100,
    max_comb::Integer = 1000,
    rng::Random.AbstractRNG = Random.default_rng(),
    seed::Option{<:Integer} = nothing,
    fb::Option{<:OptE_Opt} = nothing,
    brt::Bool = false,
    strict::Bool = false
) -> SubsetResampling

Keywords correspond to the struct's fields.

Validation

  • If scale is provided: all elements must be non-empty, > 0, and finite.

  • opt must pass assert_internal_optimiser.

  • If wb is a WeightBoundsEstimator: !isnothing(sets).

  • If fees is a FeesEstimator: !isnothing(sets).

  • If subset_size is an Integer: subset_size >= 1.

  • If subset_size is a Float: 0 < subset_size < 1.

  • If n_subsets is an Integer: n_subsets >= 2.

  • max_comb > 0 and finite.

Mathematical definition

Draw M random subsets S1,,SM of assets (size sN). Optimise on each:

w=1Mm=1MeSm(wSm).

Where:

  • w: Final averaged portfolio weights.

  • M: Number of random subsets.

  • Sm: m-th randomly drawn asset subset (size sN).

  • wSm: Optimal weights from the optimiser applied to subset Sm.

  • eSm(): Embedding operator that places subset weights into full N-asset space (zero-filling excluded assets).

  • N: Total number of assets.

Related

source
PortfolioOptimisers.needs_previous_weights Method
julia
needs_previous_weights(opt::SubsetResampling) -> Any

Return true if any sub-estimator of opt requires previous portfolio weights (fees, base optimiser, or fallback).

source
PortfolioOptimisers.factory Method
julia
factory(
    sr::SubsetResampling,
    w::AbstractVector
) -> SubsetResampling{_A, _B, _C, _D, _E, var"#s179", var"#s1791", var"#s1792", _F, _G, var"#s1793", var"#s1794", _H, _I, Bool, Bool} where {_A, _B, _C, _D, _E, var"#s179"<:NonFiniteAllocationOptimisationEstimator, var"#s1791"<:WeightFinaliser, var"#s1792"<:Transducers.Executor, _F, _G, var"#s1793"<:Integer, var"#s1794"<:AbstractRNG, _H, _I}

Build an updated SubsetResampling with all estimators that track previous weights updated via factory using w.

source
PortfolioOptimisers.port_opt_view Method
julia
port_opt_view(
    sr::SubsetResampling,
    i,
    X::AbstractMatrix{<:Union{var"#s20", var"#s19"} where {var"#s20"<:Number, var"#s19"<:AbstractJuMPScalar}},
    args...
) -> SubsetResampling{_A, _B, _C, _D, _E, var"#s179", var"#s1791", var"#s1792", _F, _G, var"#s1793", var"#s1794", _H, _I, Bool, Bool} where {_A, _B, _C, _D, _E, var"#s179"<:NonFiniteAllocationOptimisationEstimator, var"#s1791"<:WeightFinaliser, var"#s1792"<:Transducers.Executor, _F, _G, var"#s1793"<:Integer, var"#s1794"<:AbstractRNG, _H, _I}

Return a cluster-sliced copy of SubsetResampling for asset index set i and returns matrix X.

source
PortfolioOptimisers.optimise Function
julia
optimise(sr::SubsetResampling{<:Any, <:Any, <: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...) -> SubsetResamplingResult

Run the Subset Resampling portfolio optimisation.

Arguments

  • sr: The subset resampling optimiser to use.

  • rd: The returns result to use.

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

  • branchorder: Passed to the internal optimiser. The branch order to use for the clusterisation.

  • str_names: Passed to the internal optimiser. Whether to use string names for the assets in the optimisation.

  • save: Passed to the internal optimiser. Whether to save the JuMP model in the optimisation result.

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

Related

source
PortfolioOptimisers.subset_resampling_finaliser Function
julia
subset_resampling_finaliser(N, n_subsets, asset_idx, ...)

Aggregate and finalise portfolio weights from subset resampling.

Combines optimised weights from multiple asset subsets, averaging over subsets to produce the final portfolio weights.

Arguments

  • N: Total number of assets.

  • n_subsets: Number of asset subsets used in resampling.

  • asset_idx: Matrix of asset indices for each subset.

  • Additional weight and parameter inputs.

Returns

  • Final aggregated portfolio weight vector.

Related

source