Multiple Randomised Cross Validation: private API

PortfolioOptimisers.path_fit_and_predictFunction
path_fit_and_predict(opt, rd, train_idx, test_idx, cols; ex, id, cv)

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

The path runs through fold_loop, which takes each fold's asset-subset view of (opt, rd) and resolves the fold's time-dependent entries. The path runs sequentially when the optimiser needs the previous fold's weights, and in parallel over ex otherwise. A time-dependent optimiser alone does not force sequential execution, because its per-fold values are known upfront. cv is the scheme the path belongs to, handed on so the loop reads its Fold Fit (fold_fit): under an OnlineStep the path's estimator is sliced to the subset once and threaded through the path's folds.

Arguments

  • opt::NonFiniteAllocationOptimisationEstimator: Portfolio optimisation estimator.
  • rd::ReturnsResult: FullMoment 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.
  • cv: The scheme the path belongs to, or nothing.

Returns

Related

source
PortfolioOptimisers.combination_by_indexFunction
combination_by_index(idx::Integer, N::Integer, k::Integer) -> VecInt

Return 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 k item indices.

Related

source
PortfolioOptimisers.get_window_sizeFunction
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

source
PortfolioOptimisers.get_n_subsetsFunction
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.

This is the single point at which the (possibly TimeDependent or callable) subset count becomes a concrete integer, so it is where the RESOURCE_LIMITS max_n_subsets ceiling is enforced — a constructor check could not see the value a schedule or callable ultimately produces. Every subset runs a full inner optimisation, so an absurd count is a compute-exhaustion sink rather than a merely large allocation.

Arguments

  • n_subsets: Integer or callable number-of-subsets specification.
  • args...: Additional arguments (returns result or prior).

Returns

  • Integer number of subsets.

Related

source
PortfolioOptimisers.sample_unique_assetsFunction
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

source
PortfolioOptimisers.get_subset_sizeFunction
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