Skip to content
13

Multiple Randomised Cross Validation

PortfolioOptimisers.SubsetSizeEstimator Type
julia
abstract type SubsetSizeEstimator <: AbstractEstimator

Abstract supertype for estimators that determine the size of each asset subset.

Related

source
PortfolioOptimisers.NumberSubsetsEstimator Type
julia
abstract type NumberSubsetsEstimator <: AbstractEstimator

Abstract supertype for estimators that determine the number of random subsets to draw.

Related

source
PortfolioOptimisers.WindowSizeEstimator Type
julia
abstract type WindowSizeEstimator <: AbstractEstimator

Abstract supertype for estimators that determine the rolling window size.

Related

source
PortfolioOptimisers.SubsetSizeEC Type
julia
const SubsetSizeEC

Union of SubsetSizeEstimator subtypes and plain functions that compute a subset size from a returns dataset.

source
PortfolioOptimisers.NumberSubsetsEC Type
julia
const NumberSubsetsEC

Union of NumberSubsetsEstimator subtypes and plain functions that compute the number of subsets from a returns dataset.

source
PortfolioOptimisers.WindowSizeEC Type
julia
const WindowSizeEC

Union of WindowSizeEstimator subtypes and plain functions that compute a window size from a returns dataset.

source
PortfolioOptimisers.SubsetSizeE Type
julia
const SubsetSizeE

Union of a concrete subset-size value or an estimator/function for it.

source
PortfolioOptimisers.NumberSubsetsE Type
julia
const NumberSubsetsE

Union of a concrete number-of-subsets value or an estimator/function for it.

source
PortfolioOptimisers.WindowSizeE Type
julia
const WindowSizeE

Union of a concrete window-size value or an estimator/function for it.

source
PortfolioOptimisers.MultipleRandomised Type
julia
struct MultipleRandomised{__T_cv, __T_subset_size, __T_n_subsets, __T_max_comb, __T_window_size, __T_rng, __T_seed} <: NonOptimisationSequentialCrossValidationEstimator

Cross-validation scheme that draws multiple random asset subsets and applies a walk-forward estimator to each. Each combination of a random asset subset and a set of walk-forward folds forms one path.

Fields

  • cv::WalkForwardEstimator: Walk-forward estimator applied within each asset subset.

  • subset_size::SubsetSizeE: Size of each asset subset (integer count, fraction of total, or callable).

  • n_subsets::NumberSubsetsE: Number of random subsets to draw.

  • max_comb::Integer: Maximum number of combinations to enumerate exactly. When the total number of combinations exceeds this limit an approximate sampling approach is used.

  • window_size::Option{<:WindowSizeE}: Optional rolling observation window. When set, each subset uses a randomly chosen contiguous window of this length.

  • rng::Random.AbstractRNG: Random number generator.

  • seed::Option{<:Integer}: Optional random seed.

Constructors

julia
MultipleRandomised(
    cv::WalkForwardEstimator;
    subset_size::SubsetSizeE = 1,
    n_subsets::NumberSubsetsE = 2,
    max_comb::Integer = 1_000_000_000,
    window_size::Option{<:WindowSizeE} = nothing,
    rng::Random.AbstractRNG = Random.default_rng(),
    seed::Option{<:Integer} = nothing
) -> MultipleRandomised

Related

source
PortfolioOptimisers.MultipleRandomisedResult Type
julia
struct MultipleRandomisedResult{__T_train_idx, __T_test_idx, __T_asset_idx, __T_path_ids} <: NonOptimisationSequentialCrossValidationResult

Stores the split result produced by MultipleRandomised. Contains the training, test, and asset index sets for every fold across all random paths, along with a path identifier for each fold.

Fields

  • train_idx::VecVecInt: Training observation indices per fold.

  • test_idx::VecVecInt: Test observation indices per fold.

  • asset_idx::VecVecInt: Asset column indices per fold.

  • path_ids::VecInt: Path identifier for each fold.

Related

source
Base.split Method
julia
Base.split(mrcv::MultipleRandomised, rd::ReturnsResult) -> MultipleRandomisedResult

Split the returns data rd by drawing multiple random asset subsets and applying the internal walk-forward estimator to each subset. Each combination of a random asset subset and a set of walk-forward folds forms one path.

Arguments

  • mrcv::MultipleRandomised: Multiple randomised cross-validation estimator.

  • rd::ReturnsResult: Returns data to split.

Returns

  • MultipleRandomisedResult: Result containing training, test, and asset indices for every fold across all random paths, together with a path identifier for each fold.

Related

source
PortfolioOptimisers.path_fit_and_predict Function
julia
path_fit_and_predict(opt, rd, train_idx, test_idx, cols; ex, id)

Fit and predict along a sequence of (train, test, asset) triples, respecting sequential constraints.

Handles sequential and parallel execution. If the optimiser requires previous weights or is time-dependent, runs sequentially and passes weights/state between periods. Otherwise, runs in parallel using the provided executor.

Arguments

  • opt::NonFiniteAllocationOptimisationEstimator: Portfolio optimisation estimator.

  • rd::ReturnsResult: Full returns data.

  • train_idx: Sequence of training index vectors.

  • test_idx: Sequence of test index vectors.

  • cols: Sequence of asset column indices for each fold.

  • ex::FLoops.Transducers.Executor: Executor for parallel processing.

  • id: Optional path identifier.

Returns

Related

source