make_labels: Make future-return labels aligned to the decision date

View source: R/ml.R

make_labelsR Documentation

Make future-return labels aligned to the decision date

Description

Compute forward returns over a fixed horizon and align them to the decision date.

Usage

make_labels(prices, horizon = 4L, type = c("log", "simple", "sign"))

Arguments

prices

Wide price panel (Date + symbols).

horizon

Integer >= 1, number of forward steps for the label.

type

Character, one of "log", "simple", "sign".

Details

For each date t, the label is computed from prices at t and t + h.

  • type = "simple": p_{t+h}/p_t - 1

  • type = "log": \log(p_{t+h}) - \log(p_t)

  • type = "sign": sign(simple return)

Trailing dates that do not have horizon steps ahead are set to NA.

Value

A data.table with Date + symbols containing the labels.


PortfolioTesteR documentation built on Nov. 5, 2025, 5:23 p.m.