Learn R Programming

PortfolioTesteR (version 0.1.4)

make_labels: 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"))

Value

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

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.