Learn R Programming

PortfolioTesteR (version 0.1.4)

calc_relative_strength_rank: Calculate Cross-Sectional Ranking of Indicators

Description

Ranks each stock's indicator value against all other stocks on the same date. Enables relative strength strategies that adapt to market conditions. Optimized using matrix operations for 15x speedup.

Usage

calc_relative_strength_rank(
  indicator_df,
  method = c("percentile", "rank", "z-score")
)

Value

Data frame with same structure containing ranks/scores

Arguments

indicator_df

Data frame with Date column and indicator values

method

Ranking method: "percentile" (0-100), "rank" (1-N), or "z-score"

Examples

Run this code
# Rank RSI across all stocks
data("sample_prices_weekly")
rsi <- calc_rsi(sample_prices_weekly, 14)
rsi_ranks <- calc_relative_strength_rank(rsi, method = "percentile")

# Find relatively overbought (top 10%)
relative_overbought <- filter_above(rsi_ranks, 90)

Run the code above in your browser using DataLab