Skip to contents

ledgr_precompute_features() resolves the feature definitions required by a parameter grid, deduplicates identical indicators by fingerprint, computes their series once against a sealed snapshot, and returns a typed payload for future sweep execution.

Usage

ledgr_precompute_features(exp, param_grid, start = NULL, end = NULL)

Arguments

exp

A ledgr_experiment object.

param_grid

A ledgr_param_grid object.

start

Optional scoring-range start. Defaults to the snapshot start.

end

Optional scoring-range end. Defaults to the snapshot end.

Value

A ledgr_precomputed_features object.

Details

The payload is validated by ledgr_sweep() against the snapshot hash, universe, scoring range, feature engine version, grid labels, and resolved feature fingerprints. Use it for larger exploratory grids; ledgr_sweep() warns when more than 20 combinations run without precomputed features.

Articles

Exploratory sweeps and promotion: vignette("sweeps", package = "ledgr") system.file("doc", "sweeps.html", package = "ledgr")

Examples

bars <- data.frame(
  ts_utc = as.POSIXct("2020-01-01", tz = "UTC") + 86400 * 0:4,
  instrument_id = "AAA",
  open = 100:104,
  high = 101:105,
  low = 99:103,
  close = 100:104,
  volume = 1000
)
snapshot <- ledgr_snapshot_from_df(bars)
strategy <- function(ctx, params) ctx$flat()
exp <- ledgr_experiment(snapshot, strategy, features = list(ledgr_ind_sma(2)))
grid <- ledgr_param_grid(list(qty = 1), list(qty = 2))
features <- ledgr_precompute_features(exp, grid)
print(features)
#> ledgr_precomputed_features
#> ===========================
#> Snapshot:   snapshot_20260515_162021_f712
#> Candidates: 2
#> Features:   1
#> Universe:   AAA
#> Scoring:    2020-01-01T00:00:00Z to 2020-01-05T00:00:00Z
ledgr_snapshot_close(snapshot)