Learn R Programming

PortfolioTesteR (version 0.1.4)

filter_rank: Select Top or Bottom N Stocks by Signal

Description

Selects the top N (best) or worst N stocks based on signal strength. Optimized using matrix operations for 5-10x speedup.

Usage

filter_rank(signal_df, n, type = c("top", "worst"))

Value

Binary selection matrix (1 = selected, 0 = not selected)

Arguments

signal_df

Data frame with Date column and signal values

n

Number of stocks to select

type

"top" for highest values, "worst" for lowest values

Examples

Run this code
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