ledgr_run() is the public single-run API for the v0.1.7
experiment-first workflow. It evaluates run-time feature definitions,
builds the canonical backtest config, and delegates to the shared runner.
Arguments
- exp
A
ledgr_experimentobject.- params
JSON-safe list passed to
function(ctx, params)strategy.- feature_params
JSON-safe list used to resolve parameterized feature declarations before execution.
- run_id
Optional run identifier.
- seed
Optional integer-like execution seed. When non-
NULL, ledgr applies it at fold entry and stores it in run identity.- compiled_accounting_model
Optional accounting accelerator selector.
NULLuses the canonical R accounting path."spot_fifo"is a scoped spot-asset FIFO accelerator for memory-backed sweep execution; committed durable runs currently fail closed because durable compiled integration is deferred.
Identity
Run identity fields, including config_hash, feature_set_hash,
cost_model_hash, cost_plan_json, risk_chain_hash, and
risk_plan_json, are summarized in
ledgr_identity_fields.
Articles
Strategy authoring:
vignette("strategy-development", package = "ledgr")
system.file("doc", "strategy-development.html", package = "ledgr")
Metrics and accounting:
vignette("metrics-and-accounting", package = "ledgr")
system.file("doc", "metrics-and-accounting.html", package = "ledgr")
Examples
bars <- data.frame(
ts_utc = as.POSIXct("2020-01-01", tz = "UTC") + 86400 * 0:2,
instrument_id = "AAA",
open = c(100, 101, 102),
high = c(101, 102, 103),
low = c(99, 100, 101),
close = c(100, 101, 102),
volume = 1000
)
snapshot <- ledgr_snapshot_from_df(bars)
strategy <- function(ctx, params) {
targets <- ctx$flat()
targets["AAA"] <- params$qty
targets
}
exp <- ledgr_experiment(snapshot, strategy, cost_model = ledgr_cost_zero())
bt <- ledgr_run(exp, params = list(qty = 1), run_id = "example-run")
close(bt)
ledgr_snapshot_close(snapshot)