Check whether mapped feature values have passed warmup
Source:R/feature-map.R
ledgr_passed_warmup.Rdledgr_passed_warmup() is a strategy-authoring guard for named numeric vectors
returned by ctx$features(id, feature_map). For those vectors, TRUE means
every requested feature is usable at the current pulse. For an intact
ledgr_history frame or ledgr_history_matrix, it returns the recorded
min_observations and min_instruments result without rescanning values.
For arbitrary vectors, it is only an all(!is.na(x)) predicate.
Details
ledgr_passed_warmup() is not a signal pipeline transformation. It is a guard for
strategy conditions after feature values have been read. Zero-length input
aborts with classes ledgr_empty_warmup_input and
ledgr_invalid_warmup_input; non-numeric input aborts with class
ledgr_invalid_warmup_input.
The context-aware form ledgr_passed_warmup(ctx, values) checks one value
per instrument on the decision axis, such as ctx$vec$feature(id) or a
context signal. It considers eligible instruments only (ctx$vec$admissible):
a missing value on a held nonmember or a target-restricted member does not
fail the check, and with no eligible instrument the check passes. values
aligns by position when unnamed and by name when named, as for
ledgr_signal(ctx, values = ...); named values must cover every eligible
instrument. Non-numeric values, or values with an x that is not a pulse
context, abort with class ledgr_invalid_warmup_input.
Articles
Feature-map strategy authoring is taught in:
vignette("strategy-development", package = "ledgr")
system.file("doc", "strategy-development.html", package = "ledgr")
Indicator warmup is covered in:
vignette("indicators", package = "ledgr")
system.file("doc", "indicators.html", package = "ledgr")
Causal history requirements are covered in:
vignette("causal-history", package = "ledgr")
system.file("doc", "causal-history.html", package = "ledgr")
Examples
ledgr_passed_warmup(c(ret_5 = NA_real_, sma_10 = 101))
#> [1] FALSE
ledgr_passed_warmup(c(ret_5 = 0.02, sma_10 = 101))
#> [1] TRUE
try(ledgr_passed_warmup(numeric(0)))
#> Error in ledgr_passed_warmup(numeric(0)) :
#> `x` must contain at least one feature value.
# Inside a strategy, over every eligible instrument:
# if (!ledgr_passed_warmup(ctx, ctx$vec$feature("sma_10"))) return(ctx$hold())