Multiple Randomised Cross Validation
PortfolioOptimisers.SubsetSizeEstimator Type
abstract type SubsetSizeEstimator <: AbstractEstimatorAbstract supertype for estimators that determine the size of each asset subset.
Related
sourcePortfolioOptimisers.NumberSubsetsEstimator Type
abstract type NumberSubsetsEstimator <: AbstractEstimatorAbstract supertype for estimators that determine the number of random subsets to draw.
Related
sourcePortfolioOptimisers.WindowSizeEstimator Type
abstract type WindowSizeEstimator <: AbstractEstimatorAbstract supertype for estimators that determine the rolling window size.
Related
sourcePortfolioOptimisers.SubsetSizeEC Type
const SubsetSizeECUnion of SubsetSizeEstimator subtypes and plain functions that compute a subset size from a returns dataset.
PortfolioOptimisers.NumberSubsetsEC Type
const NumberSubsetsECUnion of NumberSubsetsEstimator subtypes and plain functions that compute the number of subsets from a returns dataset.
PortfolioOptimisers.WindowSizeEC Type
const WindowSizeECUnion of WindowSizeEstimator subtypes and plain functions that compute a window size from a returns dataset.
PortfolioOptimisers.SubsetSizeE Type
const SubsetSizeEUnion of a concrete subset-size value or an estimator/function for it.
sourcePortfolioOptimisers.NumberSubsetsE Type
const NumberSubsetsEUnion of a concrete number-of-subsets value or an estimator/function for it.
sourcePortfolioOptimisers.WindowSizeE Type
const WindowSizeEUnion of a concrete window-size value or an estimator/function for it.
sourcePortfolioOptimisers.MultipleRandomised Type
struct MultipleRandomised{__T_cv, __T_subset_size, __T_n_subsets, __T_max_comb, __T_window_size, __T_rng, __T_seed} <: NonOptimisationSequentialCrossValidationEstimatorCross-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: Cross-validation estimator.subset_size: Size of each random subset.n_subsets: Number of random subsets.max_comb: Maximum number of unique asset subsets.window_size: Rolling window size for randomised cross-validation.rng: Random number generator.seed: Seed for the random number generator.
Constructors
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
) -> MultipleRandomisedcv is positional; remaining arguments are keyword and correspond to the struct's fields.
Validation
If
subset_sizeis anInteger:subset_size >= 1.If
subset_sizeis a float:0 < subset_size < 1.If
n_subsetsis anInteger:n_subsets >= 2.max_comb > 0and finite.If
window_sizeis anInteger:window_size >= 2.If
window_sizeis a float:0 < window_size < 1.
Related
sourcePortfolioOptimisers.MultipleRandomisedResult Type
struct MultipleRandomisedResult{__T_train_idx, __T_test_idx, __T_asset_idx, __T_path_ids} <: NonOptimisationSequentialCrossValidationResultStores 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: Training set indices.test_idx: Test set indices.asset_idx: Asset column indices per fold.path_ids: Path identifiers for cross-validation splits.
Constructors
MultipleRandomisedResult(;
train_idx::VecVecInt,
test_idx::VecVecInt,
asset_idx::VecVecInt,
path_ids::VecInt
) -> MultipleRandomisedResultKeywords correspond to the struct's fields.
Validation
!isempty(train_idx).!isempty(test_idx).!isempty(asset_idx).!isempty(path_ids).length(train_idx) == length(test_idx) == length(asset_idx) == length(path_ids).
Related
sourcePortfolioOptimisers.MRCVR Type
const MRCVR = Union{<:MultipleRandomised, <:MultipleRandomisedResult}Alias for a multiple-randomised cross-validation estimator or result.
Matches either a MultipleRandomised estimator or a MultipleRandomisedResult.
Related
sourceBase.split Method
Base.split(mrcv::MultipleRandomised, rd::ReturnsResult) -> MultipleRandomisedResultSplit 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
sourcePortfolioOptimisers.path_fit_and_predict Function
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
MultiPeriodPredictionResultwith predictions sorted by test index.
Related
sourcePortfolioOptimisers.combination_by_index Function
combination_by_index(idx::Integer, N::Integer, k::Integer) -> VecIntReturn the idx-th combination of k items from N total items.
Internal helper for combinatorial path generation. Converts a lexicographic combination index to the actual combination elements.
Arguments
idx: Combination index (1-based).N: Total number of items.k: Number of items in each combination.
Returns
- Vector of
kitem indices.
Related
sourcePortfolioOptimisers.get_window_size Function
get_window_size(window_size, rd, args...)Get the actual rolling window size for multiple-randomised cross-validation.
Resolves the window size from nothing (no windowing), an integer (direct count), a float (fraction of observations), or a callable.
Arguments
window_size: Window size specification (nothing, integer, float, or callable).rd: Returns result or prior.args...: Additional arguments.
Returns
- Integer window size or
nothing.
Related
sourcePortfolioOptimisers.get_n_subsets Function
get_n_subsets(n_subsets, args...)Get the number of asset subsets for multiple-randomised cross-validation.
Resolves the number of subsets from either an integer (direct count) or a callable that computes it from the returns data.
Arguments
n_subsets: Integer or callable number-of-subsets specification.args...: Additional arguments (returns result or prior).
Returns
- Integer number of subsets.
Related
sourcePortfolioOptimisers.sample_unique_assets Function
sample_unique_assets(N, k, n_subsets; kwargs...)Sample n_subsets unique asset subsets of size k from N assets.
Internal function used in multiple-randomised cross-validation to generate diverse asset subsets for resampling.
Arguments
N: Total number of assets.k: Subset size.n_subsets: Number of unique subsets to sample.kwargs...: Additional keyword arguments (e.g., random seed).
Returns
- Matrix of size
(k, n_subsets)with asset indices.
Related
sourcePortfolioOptimisers.get_subset_size Function
get_subset_size(subset_size, rd, args...)Get the actual asset subset size for multiple-randomised cross-validation.
Resolves the subset size from either an integer (direct count) or a fraction of the total assets.
Arguments
subset_size: Integer or float subset size specification.rd: Returns result or prior.args...: Additional arguments.
Returns
- Integer subset size.
Related
source