Learn R Programming

RTL (version 0.1.6)

rolladjust: rolladjust

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

Arguments

x

An xts object of prices or returns.

commodityname

Name of commodity in expiry_table. See example below for values.

rolltype

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

...

Other parms

Value

Roll-adjusted xts object of returns

Examples

Run this code
# NOT RUN {
unique(expiry_table$cmdty) # for list of commodity names
ret <- returns(df=dflong,retType="abs",period.return=1,spread=TRUE)[,1:2] 
rolladjust(x=ret,commodityname=c("cmewti"),rolltype=c("Last.Trade"))
# }

Run the code above in your browser using DataLab