# \donttest{
library(PortfolioTesteR)
data(sample_prices_weekly, package = "PortfolioTesteR")
# Minimal features for the example
X <- ml_prepare_features(
prices_weekly = sample_prices_weekly,
include = c("mom12","mom26")
)
# Simple deterministic model
model <- ml_make_model("linear")
sched <- list(is = 156L, oos = 4L, step = 4L)
set.seed(42)
bt_list <- ml_backtest_multi(
features_list = X,
prices_weekly = sample_prices_weekly,
horizons = c(1L, 4L),
fit_fn = model$fit,
predict_fn = model$predict,
schedule = sched,
selection = list(top_k = 5L),
weighting = list(method = "softmax", temperature = 12),
caps = list(max_per_symbol = 0.10),
group_mode = "pooled",
name_prefix = "Demo ",
seed = 42
)
names(bt_list) # "H1w" "H4w"
# }
Run the code above in your browser using DataLab