Skip to contents

These constructors define calendar-time walk-forward fold value objects. Folds describe train and test scoring windows only; they do not execute strategies, select candidates, persist artifacts, or perform statistical validation.

Usage

ledgr_fold(
  train_start,
  train_end,
  test_start,
  test_end,
  fold_seq = 1L,
  scheme = c("rolling", "anchored"),
  gap = NULL
)

ledgr_folds_rolling(
  start,
  end,
  train_window,
  test_window,
  step = test_window,
  gap = NULL
)

ledgr_folds_anchored(
  start,
  end,
  train_window_initial,
  test_window,
  step = test_window,
  gap = NULL
)

Arguments

train_start, train_end, test_start, test_end

Fold boundary timestamps.

fold_seq

Positive integer fold sequence.

scheme

Fold scheme, currently "rolling" or "anchored".

gap

Reserved. Must be NULL in v1.

start, end

Calendar range used to generate a fold list.

train_window, test_window, step

Positive calendar durations such as "1 year", "3 months", or "10 days".

train_window_initial

Initial anchored train-window duration.

Value

A ledgr_fold or ledgr_fold_list object.

Details

ledgr_fold() creates a single explicit fold. ledgr_folds_rolling() and ledgr_folds_anchored() create ordered fold lists from calendar durations. V1 supports only gap = NULL; purged and embargoed gap semantics are reserved for a later validation-diagnostics layer. Duration-based constructors produce inclusive end timestamps one second before the next period boundary.

Examples

ledgr_fold(
  train_start = "2020-01-01",
  train_end = "2020-12-31",
  test_start = "2021-01-01",
  test_end = "2021-03-31"
)
#> ledgr fold
#> ==========
#> ID:     f5402a40d7df
#> Seq:    1
#> Scheme: rolling
#> Train:  2020-01-01T00:00:00Z to 2020-12-31T00:00:00Z
#> Test:   2021-01-01T00:00:00Z to 2021-03-31T00:00:00Z

ledgr_folds_rolling(
  start = "2020-01-01",
  end = "2021-12-31",
  train_window = "1 year",
  test_window = "3 months",
  step = "3 months"
)
#> ledgr fold list
#> ================
#> Scheme: rolling
#> Folds:  3
#> Hash:   c2e2c95a74b1
#> 
#> # A tibble: 3 × 3
#>    fold train                    test                    
#>   <int> <chr>                    <chr>                   
#> 1     1 2020-01-01 -> 2020-12-31 2021-01-01 -> 2021-03-31
#> 2     2 2020-04-01 -> 2021-03-31 2021-04-01 -> 2021-06-30
#> 3     3 2020-07-01 -> 2021-06-30 2021-07-01 -> 2021-09-30