Skip to contents

Summarize per-pulse telemetry

Usage

ledgr_backtest_bench(bt)

Arguments

bt

A ledgr_backtest object. This function does not accept a DuckDB file path; use ledgr_run_info() for persisted run-level telemetry.

Value

A tibble with mean/median/p99 values per telemetry component.

Details

This is a diagnostic helper for engine profiling. It only reports detailed telemetry captured for runs executed in the current R session. Timing components are reported in seconds. The compact telemetry persisted in durable experiment stores is available through ledgr_run_info().

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
)
strategy <- function(ctx, params) {
  targets <- ctx$flat()
  targets["AAA"] <- 1
  targets
}
bt <- ledgr_backtest(data = bars, strategy = strategy, initial_cash = 1000, cost_model = ledgr_cost_zero())
ledgr_backtest_bench(bt)
#> # A tibble: 13 × 4
#>    component    mean  median     p99
#>    <chr>       <dbl>   <dbl>   <dbl>
#>  1 t_pre      0.333   0.333   0.333 
#>  2 t_post     0.0130  0.0130  0.0130
#>  3 t_loop     0.0190  0.0190  0.0190
#>  4 t_pulse   NA      NA      NA     
#>  5 t_bars    NA      NA      NA     
#>  6 t_ctx     NA      NA      NA     
#>  7 t_fill    NA      NA      NA     
#>  8 t_state   NA      NA      NA     
#>  9 t_feats   NA      NA      NA     
#> 10 t_strat   NA      NA      NA     
#> 11 t_target  NA      NA      NA     
#> 12 t_event   NA      NA      NA     
#> 13 t_exec    NA      NA      NA     
close(bt)