Subset resampling
PortfolioOptimisers.BaseSubsetResamplingOptimisationEstimator Type
abstract type BaseSubsetResamplingOptimisationEstimator <: NonFiniteAllocationOptimisationEstimatorAbstract supertype for subset resampling portfolio optimisation estimators.
Related Types
sourcePortfolioOptimisers.SubsetResamplingResult Type
struct SubsetResamplingResult{__T_oe, __T_pr, __T_wb, __T_fees, __T_ress, __T_idx, __T_retcode, __T_w, __T_fb} <: NonJuMPOptimisationResultResult 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
sourcePortfolioOptimisers.factory Method
factory(
sr::SubsetResamplingResult,
fb::Union{Nothing, NonFiniteAllocationOptimisationEstimator, NonFiniteAllocationOptimisationResult}
) -> SubsetResamplingResultRebuild a SubsetResamplingResult with an updated fallback optimiser fb.
PortfolioOptimisers.SubsetResampling Type
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} <: BaseSubsetResamplingOptimisationEstimatorSubset 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
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
) -> SubsetResamplingKeywords correspond to the struct's fields.
Validation
If
scaleis provided: all elements must be non-empty,> 0, and finite.optmust passassert_internal_optimiser.If
wbis aWeightBoundsEstimator:!isnothing(sets).If
feesis aFeesEstimator:!isnothing(sets).If
subset_sizeis anInteger:subset_size >= 1.If
subset_sizeis aFloat:0 < subset_size < 1.If
n_subsetsis anInteger:n_subsets >= 2.max_comb > 0and finite.
Mathematical definition
Draw
Where:
: Final averaged portfolio weights. : Number of random subsets. : -th randomly drawn asset subset (size ). : Optimal weights from the optimiser applied to subset . : Embedding operator that places subset weights into full -asset space (zero-filling excluded assets). : Total number of assets.
Related
sourcePortfolioOptimisers.needs_previous_weights Method
needs_previous_weights(opt::SubsetResampling) -> AnyReturn true if any sub-estimator of opt requires previous portfolio weights (fees, base optimiser, or fallback).
PortfolioOptimisers.factory Method
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.
PortfolioOptimisers.port_opt_view Method
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.
PortfolioOptimisers.optimise Function
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...) -> SubsetResamplingResultRun 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
sourcePortfolioOptimisers.subset_resampling_finaliser Function
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