Learn R Programming

PortfolioTesteR (version 0.1.4)

ml_backtest_seq: One-call backtest wrapper (sequence features)

Description

One-call backtest wrapper (sequence features)

Usage

ml_backtest_seq(
  features_list,
  labels,
  steps = 26L,
  horizon = 4L,
  fit_fn,
  predict_fn,
  schedule = list(is = 156L, oos = 4L, step = 4L),
  group = c("pooled", "per_symbol", "per_group"),
  group_map = NULL,
  normalize = c("none", "zscore", "minmax"),
  selection = list(top_k = 15L, max_per_group = NULL),
  weighting = list(method = "softmax", temperature = 12, floor = 0),
  caps = list(max_per_symbol = 0.1, max_per_group = NULL),
  prices,
  initial_capital = 1e+05,
  name = "SEQ backtest"
)

Value

list: scores, mask, weights, backtest.

Arguments

features_list

list of panels to be stacked over steps history.

labels

future-return panel aligned to the features.

steps

int; lookback length (e.g., 26).

horizon

int; label horizon (e.g., 4).

fit_fn

function (X, y) -> model trained on in-sample stacked rows.

predict_fn

function (model, Xnew) -> numeric scores.

schedule

list with elements is, oos, step.

group

one of "pooled", "per_symbol", "per_group".

group_map

optional data.frame(Symbol, Group) if group = "per_group".

normalize

"none", "zscore", or "minmax" applied using IS data only.

selection

list: top_k, max_per_group (optional).

weighting

list: method, temperature, floor.

caps

list: max_per_symbol, optionally max_per_group.

prices

price panel used by the backtester (Date + symbols).

initial_capital

starting capital.

name

string for the backtest result.

Examples

Run this code
# \donttest{
# as above, but with steps/horizon and normalize
# }

Run the code above in your browser using DataLab