filter_by_percentile: Filter by Percentile

View source: R/filters.R

filter_by_percentileR Documentation

Filter by Percentile

Description

Select securities in the top or bottom X percentile. More intuitive than filter_top_n when universe size varies.

Usage

filter_by_percentile(signal_df, percentile, type = c("top", "bottom"))

Arguments

signal_df

DataFrame with signal values

percentile

Percentile threshold (0-100)

type

"top" for highest signals, "bottom" for lowest

Value

Binary selection matrix

Examples

data("sample_prices_weekly")
momentum <- calc_momentum(sample_prices_weekly, 12)
# Select top 20th percentile
top_20pct <- filter_by_percentile(momentum, 20, type = "top")

PortfolioTesteR documentation built on Nov. 5, 2025, 5:23 p.m.