Skip to contents

select_top_n() selects the highest finite/non-missing signal values. Missing values are ignored. Ties are broken deterministically by instrument ID in alphabetical order. If no values are usable, the function returns a classed empty selection without warning. The empty selection carries the original universe and signal origin so it can flow through weight_equal() and target_rebalance() to a flat full-universe target.

Usage

select_top_n(signal, n)

Arguments

signal

A ledgr_signal object.

n

Number of instruments to select.

Value

A ledgr_selection object. When all signal values are missing, the object also inherits from ledgr_empty_selection.

Details

Selection and warning classes:

  • ledgr_empty_selection for the classed object returned when every signal value is missing;

  • ledgr_partial_selection for the warning emitted when fewer than n finite values are available.

Articles

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

Examples

signal <- ledgr_signal(c(AAA = 0.03, BBB = NA, CCC = 0.01), origin = "return_5")
select_top_n(signal, n = 1)
#> <ledgr_selection> [3 assets]
#> origin: return_5
#> 1 selected
#>   AAA   BBB   CCC 
#>  TRUE FALSE FALSE