View source: R/utils.R View source: R/ml.R
| cap_exposure | R Documentation |
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
)
weights |
data.frame/data.table: columns |
max_per_symbol |
numeric scalar or named vector (absolute cap per symbol). |
group_map |
optional named character vector or data.frame( |
max_per_group |
optional numeric scalar (per-group gross cap). |
allow_short |
logical; if |
renormalize |
character: one of |
renormalize_down |
logical; deprecated alias for down-only (kept for compatibility). |
renorm |
logical; deprecated alias; if |
cash_col |
optional character; if provided, set to |
caps |
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.
data.table of capped (and optionally renormalized) weights.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.