Skip to contents

Returns a ledgr_backtest-compatible handle over an existing completed run. The run is not recomputed and strategy code is not executed.

Usage

ledgr_run_open(snapshot, run_id)

Arguments

snapshot

A sealed ledgr_snapshot object. Use ledgr_snapshot_load(db_path, snapshot_id) to resume from a durable DuckDB file in a new R session.

run_id

Run identifier. The run must have status DONE.

Value

A ledgr_backtest object.

Examples

bars <- subset(ledgr_demo_bars, instrument_id == "DEMO_01")
snapshot <- ledgr_snapshot_from_df(utils::head(bars, 10))
strategy <- function(ctx, params) ctx$flat()
exp <- ledgr_experiment(snapshot, strategy, opening = ledgr_opening(cash = 1000))
bt <- ledgr_run(exp, params = list(), run_id = "flat")
run_id <- bt$run_id
close(bt)
reopened <- ledgr_run_open(snapshot, run_id)
summary(reopened)
#> ledgr Backtest Summary
#> ======================
#> 
#> Performance Metrics:
#>   Total Return:        0.00%
#>   Annualized Return:   0.00%
#>   Max Drawdown:        0.00%
#> 
#> Risk Metrics:
#>   Volatility (annual): 0.00%
#>   Sharpe Ratio:        N/A
#> 
#> Trade Statistics:
#>   Total Trades:        0
#>   Win Rate:            N/A (no trades)
#>   Avg Trade:           N/A (no trades)
#> 
#> Exposure:
#>   Time in Market:      0.00%
close(reopened)
ledgr_snapshot_close(snapshot)