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_feature_grid() ledgr_strategy_grid() ledgr_grid_cross() ledgr_grid_named() ledgr_grid_add_baseline()
Create feature, strategy, and executable sweep grids
ledgr_precompute_features()
Precompute feature payloads for a parameter grid
print(<ledgr_precomputed_features>)
Print a precomputed feature payload
ledgr_sweep()
Run a parameter sweep
ledgr_sweep_retention()
Sweep retention policy
ledgr_sweep_returns() ledgr_sweep_returns_wide() ledgr_sweep_returns_panel() ledgr_sweep_returns_matrix() ledgr_sweep_returns_data_frame() ledgr_sweep_returns_xts()
Retained sweep return series
ledgr_sweep_review() print(<ledgr_sweep_review>)
Review sweep candidates without selecting one
ledgr_sweep_pbo() as_tibble(<ledgr_sweep_pbo>) print(<ledgr_sweep_pbo>)
Sweep-level PBO/CSCV diagnostic
ledgr_sweep_min_track_record() as_tibble(<ledgr_sweep_min_track_record>) print(<ledgr_sweep_min_track_record>)
Sweep-level minimum track record length diagnostic
ledgr_sweep_cluster() as_tibble(<ledgr_sweep_cluster>) print(<ledgr_sweep_cluster>)
Sweep candidate clustering diagnostic
ledgr_sweep_dsr() as_tibble(<ledgr_sweep_dsr>) print(<ledgr_sweep_dsr>)
Sweep-level deflated Sharpe ratio diagnostic
ledgr_sweep_save() ledgr_sweep_open() ledgr_sweep_list() ledgr_sweep_info()
Save, reopen, list, and inspect sweep artifacts
print(<ledgr_sweep_results>)
Print sweep results
ledgr_candidate()
Select one sweep candidate for promotion
ledgr_candidate_reproduction_key()
Return the compact reproduction key for a sweep candidate
print(<ledgr_sweep_candidate>)
Print a sweep candidate
ledgr_promote()
Promote a sweep candidate to a committed run
ledgr_fold() ledgr_folds_rolling() ledgr_folds_anchored()
Walk-forward fold constructors
ledgr_select_argmax() ledgr_select_argmin()
Walk-forward scalar selection rules
ledgr_walk_forward()
Run walk-forward evaluation
ledgr_walk_forward_open() ledgr_walk_forward_scores() ledgr_walk_forward_folds()
Inspect a persisted walk-forward session
print(<ledgr_walk_forward_degradation>)
Print a walk-forward degradation table
ledgr_promotion_context()
Read promotion context for a promoted run
ledgr_run_promotion_context()
Read promotion context from an experiment store

Cost And Timing

Target Risk

Identity And Diagnostics

ledgr_identity_fields ledgr_identity
ledgr identity fields
ledgr_condition_classes ledgr_legacy_fill_model_shape ledgr_legacy_config_shape ledgr_cost_model_unspecified ledgr_invalid_cost_chain_order ledgr_invalid_cost_model ledgr_invalid_timing_model ledgr_invalid_fill_proposal ledgr_invalid_fill_context ledgr_run_not_found ledgr_unresolved_feature_id ledgr_run_window_too_short ledgr_invalid_lot_fill ledgr_snapshot_hash_invalid_timestamp ledgr_invalid_sweep_id ledgr_sweep_id_exists ledgr_sweep_not_found ledgr_sweep_snapshot_not_found ledgr_sweep_snapshot_hash_mismatch ledgr_sweep_schema_incompatible ledgr_invalid_sweep_retention ledgr_sweep_returns_unretained ledgr_sweep_returns_candidate_not_found ledgr_sweep_returns_candidate_not_completed ledgr_sweep_returns_first_row_invalid ledgr_sweep_returns_incomplete_panel ledgr_validation_pbo_incomplete_panel ledgr_validation_pbo_invalid_s ledgr_validation_pbo_too_few_candidates ledgr_validation_pbo_too_few_observations ledgr_validation_pbo_invalid_metric ledgr_validation_pbo_invalid_panel ledgr_validation_pbo_invalid_threshold ledgr_validation_min_trl_invalid_reference ledgr_validation_min_trl_invalid_confidence ledgr_validation_min_trl_invalid_risk_free ledgr_validation_min_trl_too_few_observations ledgr_validation_min_trl_invalid_returns ledgr_missing_package ledgr_walk_forward_metric_missing ledgr_walk_forward_metric_class_invalid ledgr_walk_forward_no_selection ledgr_walk_forward_candidate_key_missing ledgr_walk_forward_test_run_failed ledgr_walk_forward_session_not_found ledgr_walk_forward_snapshot_hash_mismatch ledgr_walk_forward_snapshot_override_mismatch ledgr_walk_forward_invalid_session ledgr_walk_forward_latest_without_rationale ledgr_walk_forward_candidate_not_found
ledgr condition classes
LEDGR_LAST_BAR_NO_FILL ledgr_last_bar_no_fill ledgr_final_bar_no_fill
LEDGR_LAST_BAR_NO_FILL warning code

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_run_fills()
Extract fill events from a backtest
ledgr_compute_metrics()
Compute standard metrics from backtest results
ledgr_state_reconstruct()
Reconstruct derived state for a run (v0.1.0)

Metric Assumptions

ledgr_metric_context() ledgr_metric_us_equity() ledgr_metric_crypto()
Create or access metric context
ledgr_metric_context_hash()
Hash a metric context
ledgr_risk_free_rate()
Create a scalar risk-free-rate assumption
ledgr_calendar() ledgr_calendar_us_equity() ledgr_calendar_crypto()
Create a ledgr calendar

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_run_compare()
Compare completed runs in a ledgr experiment store
print(<ledgr_comparison>)
Print a run comparison
ledgr_run_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_condition_classes ledgr_legacy_fill_model_shape ledgr_legacy_config_shape ledgr_cost_model_unspecified ledgr_invalid_cost_chain_order ledgr_invalid_cost_model ledgr_invalid_timing_model ledgr_invalid_fill_proposal ledgr_invalid_fill_context ledgr_run_not_found ledgr_unresolved_feature_id ledgr_run_window_too_short ledgr_invalid_lot_fill ledgr_snapshot_hash_invalid_timestamp ledgr_invalid_sweep_id ledgr_sweep_id_exists ledgr_sweep_not_found ledgr_sweep_snapshot_not_found ledgr_sweep_snapshot_hash_mismatch ledgr_sweep_schema_incompatible ledgr_invalid_sweep_retention ledgr_sweep_returns_unretained ledgr_sweep_returns_candidate_not_found ledgr_sweep_returns_candidate_not_completed ledgr_sweep_returns_first_row_invalid ledgr_sweep_returns_incomplete_panel ledgr_validation_pbo_incomplete_panel ledgr_validation_pbo_invalid_s ledgr_validation_pbo_too_few_candidates ledgr_validation_pbo_too_few_observations ledgr_validation_pbo_invalid_metric ledgr_validation_pbo_invalid_panel ledgr_validation_pbo_invalid_threshold ledgr_validation_min_trl_invalid_reference ledgr_validation_min_trl_invalid_confidence ledgr_validation_min_trl_invalid_risk_free ledgr_validation_min_trl_too_few_observations ledgr_validation_min_trl_invalid_returns ledgr_missing_package ledgr_walk_forward_metric_missing ledgr_walk_forward_metric_class_invalid ledgr_walk_forward_no_selection ledgr_walk_forward_candidate_key_missing ledgr_walk_forward_test_run_failed ledgr_walk_forward_session_not_found ledgr_walk_forward_snapshot_hash_mismatch ledgr_walk_forward_snapshot_override_mismatch ledgr_walk_forward_invalid_session ledgr_walk_forward_latest_without_rationale ledgr_walk_forward_candidate_not_found
ledgr condition classes
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
ledgr_snapshot_import_instruments_csv()
Import snapshot instruments from CSV
ledgr_snapshot_info()
Snapshot info
ledgr_snapshot_list()
List snapshots (v0.1.1)
ledgr_snapshot_open()
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_ind_ttr_outputs()
Construct a bundle from all or selected outputs of a TTR indicator
ledgr_ind_ttr_warmup_rules()
Inspect supported TTR warmup inference rules
ledgr_indicator()
Construct a ledgr indicator
print(<ledgr_indicator>)
Print a ledgr indicator
ledgr_feature_id()
Get feature IDs from ledgr indicators
ledgr_param()
Declare a feature parameter reference
ledgr_parameters()
Inspect parameter references in feature declarations
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_indicator_register()
Register an indicator in the global registry
ledgr_indicator_remove()
Deregister an indicator from the session registry
ledgr_indicator_get()
Get an indicator by name
ledgr_indicator_list()
List registered indicators
ledgr_feature_cache_clear()
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
ledgr_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_demo_sma_crossover_strategy()
Demo SMA crossover strategy
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
ledgr_signal_return()
Build a return signal from registered return features
ledgr_select_top_n()
Select the top instruments from a signal
ledgr_weight_equal()
Convert a selection to equal long-only weights
ledgr_target_rebalance()
Construct full target quantities from weights

Low-Level Utilities

ledgr_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_temp_store()
Create a disposable ledgr store path
ledgr_validate_schema()
Validate ledgr DuckDB schema (v0.1.0)
print(<ledgr_config>)
Print a ledgr config
ledgr_backtest_bench()
Summarize per-pulse telemetry
ledgr_sim_bars()
Simulate deterministic synthetic OHLCV bars
ledgr_demo_bars
Synthetic demo OHLCV bars