Reads a CSV file and delegates to ledgr_snapshot_from_df().
Details
CSV parse and OHLC validation errors are snapshot creation errors. They are
raised before a snapshot can be loaded into ledgr_experiment() or executed
with ledgr_run(). High-level validation uses general ledgr argument and
timestamp classes such as ledgr_invalid_args and ledgr_invalid_timestamp;
the low-level CSV import helpers use LEDGR_CSV_FORMAT_ERROR. In both paths,
snapshot creation fails before a usable snapshot artifact is left behind, so
fix the CSV and rerun snapshot creation.
The CSV must contain instrument_id, ts_utc, open, high, low, and
close; volume is optional. ledgr imports only those canonical bar columns.
Other CSV columns are ignored and do not become part of the sealed snapshot or
its hash.
Articles
Durable experiment stores:
vignette("experiment-store", package = "ledgr")
system.file("doc", "experiment-store.html", package = "ledgr")
Examples
csv_path <- tempfile(fileext = ".csv")
utils::write.csv(data.frame(
ts_utc = c("2020-01-01T00:00:00Z", "2020-01-02T00:00:00Z"),
instrument_id = "AAA",
open = c(100, 101),
high = c(101, 102),
low = c(99, 100),
close = c(100, 101),
volume = 1000
), csv_path, row.names = FALSE)
snapshot <- ledgr_snapshot_from_csv(csv_path)
ledgr_snapshot_info(snapshot)
#> # A tibble: 1 × 11
#> snapshot_id status created_at_utc sealed_at_utc snapshot_hash bar_count
#> <chr> <chr> <chr> <chr> <chr> <int>
#> 1 snapshot_20260616… SEALED 2026-06-16T14… 2026-06-16T1… cdce2950fdab… 2
#> # ℹ 5 more variables: instrument_count <int>, start_date <chr>, end_date <chr>,
#> # meta_json <chr>, error_msg <chr>
ledgr_snapshot_close(snapshot)