weight_by_rank: Rank-Based Portfolio Weighting

View source: R/weighting.R

weight_by_rankR Documentation

Rank-Based Portfolio Weighting

Description

Weights securities based on their rank rather than raw signal values. Useful when signal magnitudes are unreliable but ordering is meaningful.

Usage

weight_by_rank(
  selected_df,
  signal_df,
  method = c("linear", "exponential"),
  ascending = FALSE
)

Arguments

selected_df

Binary selection matrix

signal_df

Signal values for ranking

method

Weighting method: "linear" or "exponential"

ascending

Sort order for ranking (default: FALSE)

Value

Data.table with rank-based weights

Examples

data("sample_prices_weekly")
momentum <- calc_momentum(sample_prices_weekly, lookback = 12)
selected <- filter_top_n(momentum, 10)
# Linear rank weighting (best gets most)
weights <- weight_by_rank(selected, momentum, method = "linear")
# Exponential (heavy on top stocks)
weights_exp <- weight_by_rank(selected, momentum, method = "exponential")

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