Skip to contents

ledgr_signal_strategy() is a small convenience wrapper for tutorial-style strategies that emit explicit signals. It does not change the runner contract: the returned strategy maps signals to a full named numeric target vector before the shared StrategyResult validator runs.

Usage

ledgr_signal_strategy(fn, long_qty = 1, flat_qty = 0, short_qty = -1)

Arguments

fn

Signal function called as fn(ctx). It receives the ledgr pulse context, not params, and must return either a scalar signal for a single-instrument universe or a named character vector with one signal per instrument in ctx$universe.

long_qty

Target quantity for "LONG".

flat_qty

Target quantity for "FLAT".

short_qty

Target quantity for "SHORT".

Value

A function(ctx, params) strategy suitable for ledgr execution. The returned strategy follows the normal ledgr strategy convention and maps the inner signal function's "LONG", "FLAT", and "SHORT" values to a full named numeric target vector.

Articles

Strategy helper pipelines: vignette("strategy-development", package = "ledgr") system.file("doc", "strategy-development.html", package = "ledgr")

Examples

strategy <- ledgr_signal_strategy(
  function(ctx) c(AAA = "LONG"),
  long_qty = 10
)
strategy(list(universe = "AAA"), list())
#> AAA 
#>  10