# Minimal usage
syms <- c("AAPL","MSFT","AMZN","XOM","JPM")
gdf <- demo_sector_map(syms, n_groups = 3L) # columns: Symbol, Group
print(gdf)
# Use with cap_exposure(): convert to a named vector (names = symbols)
gmap <- stats::setNames(gdf$Group, gdf$Symbol)
data(sample_prices_weekly)
mom12 <- calc_momentum(sample_prices_weekly, 12)
sel10 <- filter_top_n(mom12, 10)
w_eq <- weight_equally(sel10)
w_cap <- cap_exposure(
weights = w_eq,
max_per_symbol = 0.10,
group_map = gmap, # <- named vector, OK for current cap_exposure()
max_per_group = 0.45,
renormalize_down = TRUE
)
head(w_cap)
Run the code above in your browser using DataLab