Skip to contents

Package

ledgr ledgr-package
ledgr: Deterministic Event-Sourced Backtesting

Experiment Workflow

ledgr_experiment()
Define a reusable ledgr experiment
print(<ledgr_experiment>)
Print a ledgr experiment
ledgr_opening()
Define an opening portfolio state
print(<ledgr_opening>)
Print an opening portfolio state
ledgr_opening_from_broker()
Create opening state from a broker adapter
ledgr_run()
Run a ledgr experiment
ledgr_param_grid()
Create a typed parameter grid
print(<ledgr_param_grid>)
Print a parameter grid
ledgr_precompute_features()
Precompute feature payloads for a parameter grid
print(<ledgr_precomputed_features>)
Print a precomputed feature payload
ledgr_sweep()
Run a sequential parameter sweep
print(<ledgr_sweep_results>)
Print sweep results
ledgr_candidate()
Select one sweep candidate for promotion
print(<ledgr_sweep_candidate>)
Print a sweep candidate
ledgr_promote()
Promote a sweep candidate to a committed run
ledgr_promotion_context()
Read promotion context for a promoted run
ledgr_run_promotion_context()
Read promotion context from an experiment store

Backtests

ledgr_backtest()
Run a backtest (v0.1.2)
print(<ledgr_backtest>)
Print a backtest result
summary(<ledgr_backtest>)
Summarize a backtest result
as_tibble(<ledgr_backtest>)
Extract tidy backtest tables
ledgr_results()
Extract ledgr result tables
as_tibble(<ledgr_result_table>)
Convert a ledgr result table to a tibble
print(<ledgr_result_table>)
Print a ledgr result table
close(<ledgr_backtest>)
Close a backtest result connection
plot(<ledgr_backtest>)
Plot backtest results
ledgr_extract_fills()
Extract fill events from a backtest
ledgr_compute_equity_curve()
Compute an equity curve from a backtest
ledgr_compute_metrics()
Compute standard metrics from backtest results
ledgr_state_reconstruct()
Reconstruct derived state for a run (v0.1.0)

Experiment Store

ledgr_run_list()
List runs in a ledgr experiment store
print(<ledgr_run_list>)
Print a run list
ledgr_run_info()
Inspect one run in a ledgr experiment store
ledgr_compare_runs()
Compare completed runs in a ledgr experiment store
print(<ledgr_comparison>)
Print a run comparison
ledgr_extract_strategy()
Extract stored strategy source for a run
print(<ledgr_extracted_strategy>)
Print extracted strategy metadata
print(<ledgr_run_info>)
Print run information
ledgr_run_open()
Reopen a completed run from a ledgr experiment store
ledgr_run_label()
Set a human-readable label for a run
ledgr_run_archive()
Archive a run without deleting artifacts
ledgr_run_tag()
Add tags to a stored run
ledgr_run_untag()
Remove tags from a stored run
ledgr_run_tags()
List run tags

Snapshots

ledgr_snapshot_close()
Close snapshot database connection
ledgr_snapshot_create()
Create a snapshot (v0.1.1)
ledgr_snapshot_from_csv()
Create a snapshot from a CSV file
ledgr_snapshot_from_df()
Create a snapshot from an in-memory data.frame
ledgr_snapshot_from_yahoo()
Create a snapshot from Yahoo Finance data (quantmod)
ledgr_snapshot_import_bars_csv()
Import snapshot bars from CSV (v0.1.1)
ledgr_snapshot_import_instruments_csv()
Import snapshot instruments from CSV (v0.1.1)
ledgr_snapshot_info()
Snapshot info (v0.1.1)
ledgr_snapshot_list()
List snapshots (v0.1.1)
ledgr_snapshot_load()
Load an existing sealed snapshot
ledgr_snapshot_seal()
Seal a snapshot (v0.1.1)
print(<ledgr_snapshot>)
Print a snapshot
summary(<ledgr_snapshot>)
Summarize a snapshot
close(<ledgr_snapshot>)
Close a snapshot connection

Indicators

ledgr_ind_ema()
Exponential Moving Average
ledgr_ind_returns()
Simple Returns
ledgr_ind_rsi()
Relative Strength Index
ledgr_ind_sma()
Simple Moving Average
ledgr_ind_ttr()
Construct a ledgr indicator from a supported TTR indicator
ledgr_indicator()
Construct a ledgr indicator
print(<ledgr_indicator>)
Print a ledgr indicator
ledgr_feature_id()
Get feature IDs from ledgr indicators
ledgr_feature_contracts()
Inspect feature contracts
ledgr_feature_contract_check()
Check feature warmup feasibility against a snapshot
ledgr_pulse_features()
Inspect pulse feature rows
ledgr_pulse_wide()
Inspect a pulse as one wide row
ledgr_register_indicator()
Register an indicator in the global registry
ledgr_deregister_indicator()
Deregister an indicator from the session registry
ledgr_get_indicator()
Get an indicator by name
ledgr_list_indicators()
List registered indicators
ledgr_ttr_warmup_rules()
Inspect supported TTR warmup inference rules
ledgr_clear_feature_cache()
Clear the session feature cache
ledgr_adapter_r()
Adapt an R package function into a ledgr indicator
ledgr_adapter_csv()
Adapt a CSV of precomputed indicators
ledgr_indicator_dev()
Interactive indicator development session
print(<ledgr_indicator_dev>)
Print an indicator development session
close(<ledgr_indicator_dev>)
Close indicator development session

Strategy Development

ledgr_strategy_context ctx
Strategy pulse context accessors
ledgr_pulse_snapshot()
Freeze a pulse snapshot for interactive strategy development
print(<ledgr_pulse_context>)
Print a pulse snapshot context
close(<ledgr_pulse_context>)
Close pulse context
ledgr_feature_map() print(<ledgr_feature_map>)
Create a feature map
passed_warmup()
Check whether mapped feature values have passed warmup
ledgr_strategy_preflight()
Classify a functional strategy's reproducibility tier
ledgr_signal_strategy()
Wrap a signal-style strategy as numeric targets
ledgr_signal()
Create a strategy signal vector
ledgr_selection()
Create a strategy selection vector
ledgr_weights()
Create a strategy weight vector
ledgr_target()
Create a strategy target vector
signal_return()
Build a return signal from registered return features
select_top_n()
Select the top instruments from a signal
weight_equal()
Convert a selection to equal long-only weights
target_rebalance()
Construct full target quantities from weights

Low-Level Utilities

iso_utc()
Normalize timestamps to ISO 8601 UTC
ledgr_utc()
Parse timestamps as UTC POSIXct values
ledgr_db_init()
Initialize or open a ledgr DuckDB database (v0.1.0)
ledgr_create_schema()
Create the current ledgr DuckDB schema
ledgr_validate_schema()
Validate ledgr DuckDB schema (v0.1.0)
ledgr_data_hash()
Compute deterministic data hash for the legacy bars table (v0.1.0)
print(<ledgr_config>)
Print a ledgr config
ledgr_backtest_run()
Run a deterministic EOD backtest (v0.1.0)
ledgr_backtest_bench()
Summarize per-pulse telemetry
ledgr_sim_bars()
Simulate deterministic synthetic OHLCV bars
ledgr_demo_bars
Synthetic demo OHLCV bars