View source: R/cross_sectional.R
| rank_within_sector | R Documentation |
Ranks stocks within their sector for sector-neutral strategies. Enables selecting best stocks from each sector regardless of sector performance. Optimized using matrix operations within groups.
rank_within_sector(
indicator_df,
sector_mapping,
method = c("percentile", "rank", "z-score"),
min_sector_size = 3
)
indicator_df |
Data frame with Date column and indicator values |
sector_mapping |
Data frame with |
method |
"percentile" (0-100), "rank" (1-N), or "z-score" |
min_sector_size |
Minimum stocks per sector (default: 3) |
Data frame with within-sector ranks/scores
data("sample_prices_weekly")
data("sample_sp500_sectors")
momentum <- calc_momentum(sample_prices_weekly, 12)
sector_ranks <- rank_within_sector(momentum, sample_sp500_sectors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.