Row-wise caps on a wide weights table (Date + symbols):
per-symbol cap (max_per_symbol)
optional per-group cap (max_per_group) using group_map
cap_exposure(
weights,
max_per_symbol = NULL,
group_map = NULL,
max_per_group = NULL,
allow_short = FALSE,
renormalize = c("none", "down", "both"),
renormalize_down = FALSE,
renorm = NULL,
cash_col = NULL,
caps = NULL
)cap_exposure(
weights,
max_per_symbol = NULL,
group_map = NULL,
max_per_group = NULL,
allow_short = FALSE,
renormalize = c("none", "down", "both"),
renormalize_down = FALSE,
renorm = NULL,
cash_col = NULL,
caps = NULL
)
data.table of capped (and optionally renormalized) weights.
data.frame/data.table: columns Date, then symbols.
numeric scalar or named vector (absolute cap per symbol).
optional named character vector or data.frame(symbol,group).
optional numeric scalar (per-group gross cap).
logical; if FALSE clamp negatives to 0.
character: one of "none", "down", "both". Default "none".
logical; deprecated alias for down-only (kept for compatibility).
logical; deprecated alias; if TRUE acts like renormalize="both".
optional character; if provided, set to 1 - sum(pmax(w,0)).
optional list; alternative to split args (see details above).
Negatives are clamped to 0 unless allow_short = TRUE.
Renormalization options:
renormalize = "none": leave gross (sum of positive weights) as is.
renormalize = "down": if gross > 1, scale down so gross == 1.
renormalize = "both": if 0 < gross != 1, scale so gross == 1.
The argument renorm (logical) is a deprecated alias;
TRUE behaves like renormalize = "both".
The caps list form is supported:
Maximum absolute weight per symbol (0-1).
Maximum gross weight per group (0-1).
Named character vector mapping symbol -> group.