panel_returns_simple: Panel simple returns from prices

View source: R/ml.R

panel_returns_simpleR Documentation

Panel simple returns from prices

Description

Converts a wide price panel (Date + symbols) into arithmetic simple returns at the same cadence, dropping the first row per symbol.

Usage

panel_returns_simple(prices)

Arguments

prices

A data frame or data.table with columns Date and one column per symbol containing adjusted prices at a common frequency (daily, weekly, monthly).

Value

A data frame with Date and one column per symbol containing simple returns R_{t} = P_{t}/P_{t-1} - 1.

Examples


  data(sample_prices_weekly)
  rets <- panel_returns_simple(sample_prices_weekly)
  head(rets)



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