powered by
Selects the top N (best) or worst N stocks based on signal strength. Optimized using matrix operations for 5-10x speedup.
filter_rank(signal_df, n, type = c("top", "worst"))
Binary selection matrix (1 = selected, 0 = not selected)
Data frame with Date column and signal values
Number of stocks to select
"top" for highest values, "worst" for lowest values
data("sample_prices_weekly") momentum <- calc_momentum(sample_prices_weekly, 12) # Select 10 highest momentum stocks top10 <- filter_rank(momentum, 10, type = "top")
Run the code above in your browser using DataLab