View source: R/cross_sectional.R
| calc_sector_breadth | R Documentation |
Measures participation within each sector separately, revealing which sectors have broad strength vs concentrated leadership. Optimized using pre-splitting for speed.
calc_sector_breadth(
condition_df,
sector_mapping,
min_stocks_per_sector = 3,
na_sector_action = c("exclude", "separate", "market")
)
condition_df |
Data frame with Date column and TRUE/FALSE values |
sector_mapping |
Data frame with |
min_stocks_per_sector |
Minimum stocks for valid sector breadth (default: 3) |
na_sector_action |
How to handle unmapped stocks: "exclude", "separate", or "market" |
A data.table with Date and Breadth_[Sector] columns (0-100 scale)
data("sample_prices_weekly")
data("sample_sp500_sectors")
ma200 <- calc_moving_average(sample_prices_weekly, 200)
above_ma <- filter_above(calc_distance(sample_prices_weekly, ma200), 0)
sector_breadth <- calc_sector_breadth(above_ma, sample_sp500_sectors)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.