Create weights based on predictions with given constraints

quantile_weights(return_predictions, errors, constraints = NULL)

Arguments

return_predictions

tibble of stock_id, date, and various predictions

errors

tibble of stock_id, date, and various errors

constraints

list of constraints for the weights. possible values are:

  • quantiles: list with long and short quantiles (default: median portfolios)

  • allow_short_sale: logical, if TRUE, allow short sales (default: FALSE)

  • max_weight: numeric, maximum weight for a single stock (default: 0.1)

  • min_weight: numeric, minimum weight for a single stock (default: -0.1)

  • b: numeric, in case of allow_short_sale=TRUE this is the max weight sum in both legs, in case of allow_short_sale=FALSE this is the max weight sum in long leg

Value

tibble with stock_id, date, and weight

Examples

constraints <- list(
  quantiles = list(long = 0.10, short = 0.10)
 )

 # Example return predictions
 return_predictions <- data.frame(
   stock_id = sample(1:100, 100, replace = TRUE),
   date = seq.Date(from = Sys.Date() - 100, by = "day", length.out = 100),
   pred = runif(100, -1, 1)
   )