Learn R Programming

PortfolioTesteR (version 0.1.4)

ml_prepare_features: Prepare tabular features (weekly + aligned daily volatility)

Description

Constructs a minimal, leakage-safe set of tabular features commonly used in cross-sectional ML: weekly momentum (12/26/52), RSI(14), distance from 20-week MA, and daily rolling volatility aligned to weekly dates (tokens vol{N}d_walign, e.g., "vol20d_walign").

Usage

ml_prepare_features(
  prices_weekly,
  prices_daily = NULL,
  include = c("mom12", "mom26", "mom52", "vol20d_walign", "dist20", "rsi14"),
  interactions = NULL
)

Value

A named list of panels (each a wide data.frame with Date).

Arguments

prices_weekly

Wide panel with Date and symbol columns (weekly).

prices_daily

Optional wide panel (daily) if vol*d_walign are included.

include

Character vector of feature tokens to include.

interactions

Optional named list passed to ml_add_interactions().

Details

All outputs are lagged by one period to avoid look-ahead in backtests.

Examples

Run this code
if (FALSE) {
X <- ml_prepare_features(sample_prices_weekly, sample_prices_daily,
                         include = c("mom12","vol20d_walign","rsi14"))
}

Run the code above in your browser using DataLab