Learn R Programming

PortfolioTesteR (version 0.1.4)

panel_returns_simple: 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)

Value

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

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).

Examples

Run this code
# \donttest{
  data(sample_prices_weekly)
  rets <- panel_returns_simple(sample_prices_weekly)
  head(rets)
# }

Run the code above in your browser using DataLab