WalkForward: private API
PortfolioOptimisers.WalkForwardEstimator — Type
abstract type WalkForwardEstimator <: SequentialCrossValidationEstimatorAbstract supertype for all walk-forward cross-validation estimators.
Walk-forward estimators split time series data into sequential training and testing windows, advancing the test window forward at each step. Subtypes implement index-based or date-based walk-forward schemes.
Related
PortfolioOptimisers.WFCVER — Type
const WFCVER = Union{<:WalkForwardEstimator, <:WalkForwardResult}Alias for a walk-forward cross-validation estimator or result.
Matches either a WalkForwardEstimator or a WalkForwardResult.
Related
PortfolioOptimisers.AbstractFoldFit — Type
abstract type AbstractFoldFit <: AbstractAlgorithmAbstract supertype of the Fold Fit selectors: how the fold loop fits each fold of a walk-forward.
A walk-forward carries one in its ff field, read by fold_fit, beside its other execution switches. nothing refits every fold from its training window, which is the released behaviour; a member selects another fit. The family is a selector-tag family like AbstractWeightDrift: a member carries no data, and a caller's own subtype extends the loop through a method of its own.
Related
PortfolioOptimisers.DateAdjusterEstimator — Type
abstract type DateAdjusterEstimator <: AbstractEstimatorAbstract supertype for date adjustment estimators in walk-forward cross-validation.
Subtypes implement specific strategies for adjusting dates used in walk-forward splits. A subtype reaches a DateWalkForward through its adjuster field, whose type bound is DateAdjType.
Related
PortfolioOptimisers.DatesUnionPeriod — Type
const DatesUnionPeriod = Union{<:Dates.Period, <:Dates.CompoundPeriod}Alias for a Dates period or compound period.
Used internally to accept either simple date periods (e.g., Dates.Month(1)) or compound periods (e.g., Dates.Month(1) + Dates.Day(1)) as date offsets in walk-forward cross-validation.
Related
PortfolioOptimisers.DateAdjType — Type
const DateAdjType = Union{<:Function, <:DateAdjusterEstimator}Alias for a date adjustment function or estimator.
Matches either a plain Function or a DateAdjusterEstimator for adjusting dates in walk-forward cross-validation.
Related
PortfolioOptimisers.IntPeriodDateRange — Type
const IntPeriodDateRange = Union{<:Integer, <:DatesUnionPeriod}Alias for an integer or date period used to specify window sizes.
Matches either a plain integer (number of observations) or a date period (DatesUnionPeriod) for walk-forward cross-validation splits.
Related
PortfolioOptimisers.special_div — Method
special_div(a::Integer, b::Integer)Return the number of steps of size b that fit in the span 1:a.
The result is the largest k for which 1 + k * b <= a, which is div(a - 1, b) for a positive a. A walk-forward fold count uses it this way: the first window starts at the first position of the span and every later window starts b positions after the previous one, so the number of windows is special_div(a, b) + 1. The caller passes the length of the span, not the difference between its last and its first position. b must not be zero.
Arguments
a: Length of the span of positions at which a window may start.b: Step between two window starts.
Returns
Integer: The number of steps after the first window,div(a - 1, b).
Related
PortfolioOptimisers.walk_forward_date_range — Function
walk_forward_date_range(ts::AbstractVector, period::DatesUnionPeriod,
period_offset::Option{<:DatesUnionPeriod}, adjuster::DateAdjType)Build the date range that a DateWalkForward estimator walks over the timestamps ts.
The range runs from the first to the last timestamp with a step of period. If period_offset is not nothing, the start moves to min(ts[1], ts[1] - period_offset), the adjuster is applied, and the offset is added to every date. This shifts each date by the offset without losing the start of ts.
Arguments
ts: Sorted timestamp vector (cv_timestamps).period: Step of the date range.period_offset: Offset applied to every date of the range, ornothing.adjuster: Function applied to the unshifted range, e.g. a business-day adjuster.
Returns
- The date range walked by
Base.splitandn_splits.
Related
PortfolioOptimisers.date_index_positions — Function
date_index_positions(ts::AbstractVector, date_range, previous::Bool,
::Type{T} = Int) where {T <: Integer}Map every date of date_range to a position in the sorted timestamp vector ts.
A date that falls between two timestamps maps to the previous timestamp if previous is true, and to the next timestamp if previous is false. A date before ts[1] maps to the first timestamp. The mapping stops at the first date that falls after ts[end], so the result is not longer than date_range.
Arguments
ts: Sorted timestamp vector (cv_timestamps).date_range: Date range fromwalk_forward_date_range.previous: Iftrue, a date between two timestamps takes the previous timestamp.T: Element type of the returned vector.
Returns
Vector{T}: Positions ints, in the order ofdate_range.
Related
PortfolioOptimisers.resolve_expand_train — Function
resolve_expand_train(expand_train::Option{Bool}, ff::Option{<:AbstractFoldFit})Derive a walk-forward's expand_train from its Fold Fit when the keyword is left unset.
nothing resolves to true under a Fold Fit and to false without one, because a Fold Fit steps rows into one estimator and cannot un-fold an observation, so an online run is expanding by construction; a bare call therefore resolves to the released false. An explicit value is returned as it is, and the inner constructor refuses the one that contradicts the switch through assert_fold_fit_expands.
Related
PortfolioOptimisers.assert_fold_fit_expands — Function
assert_fold_fit_expands(expand_train::Bool, ff::Option{<:AbstractFoldFit}, window::Option{<:Integer})Refuse expand_train = false beside a Fold Fit, by name.
A Fold Fit cannot un-fold an observation, so the loop's window only ever grows and a rolling window is not the loop's to give. The message points at the composition that gives one: Online(pe; max_history = window) caps the prior's buffer, and the read-out is a batch fit over the window. window is train_size - purged_size for an index scheme, which names the cap outright, and nothing for a date scheme, whose window is counted in periods rather than rows.
Related