Learn R Programming

RTL (version 1.3.7)

rolladjust: Adjusts daily returns for futures contracts roll

Description

Returns a xts price or return object adjusted for contract roll. The methodology used to adjust returns is to remove the daily returns on the day after expiry and for prices to adjust historical rolling front month contracts by the size of the roll at each expiry. This is conducive to quantitative trading strategies as it reflects the PL of a financial trader.

Usage

rolladjust(x, commodityname = c("cmewti"), rolltype = c("Last.Trade"), ...)

Value

Roll-adjusted xts object of returns

Arguments

x

A df of returns.

commodityname

Name of commodity in expiry_table: unique(expiry_table$cmdty) or "cmecan" for WCW

rolltype

Type of contract roll: "Last.Trade" or "First.Notice".

...

Other parms

Author

Philippe Cote

Examples

Run this code
ret <- dplyr::tibble(date = seq.Date(Sys.Date() - 60, Sys.Date(), 1), CL01 = rnorm(61, 0, 1))
rolladjust(x = ret, commodityname = c("cmewti"), rolltype = c("Last.Trade"))

Run the code above in your browser using DataLab