getTSR: getTSR

Description Usage Arguments Value Author(s) See Also Examples

View source: R/fct01_frameBuildingFuncs.R

Description

Get the TSR('time-stock-rtn') or TSFR('time-stock-factor-rtn') object by adding the period rtn between the rebalance date and the date_end((close of "date_end")/(prevclose of the day after "date")-1)) to the TS or TSF object.

Usage

1
getTSR(TS, dure = NULL, date_end_pad)

Arguments

TS

a TS or TSF object (See detail in getTS and getTSF)

dure

a period object from package lubridate. (ie. months(1),weeks(2). See example in trday.offset.) If null, then get periodrtn between date and the next date, else get periodrtn of 'dure' starting from date.

date_end_pad

a Date value, padding the NAs of the last date_end. if missing, calculated automatically.

Value

given a TS object,return a TSR object,a dataframe containing cols:

given a TSF object,return a TSFR object,a dataframe containing cols:

Author(s)

Ruifei.Yin

See Also

Other frame building functions: getRebDates, getTSF, getTS

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
## -- get a TSR object
RebDates <- getRebDates(as.Date('2011-03-17'),as.Date('2012-04-17'),'month')
TS <- getTS(RebDates,'EI000300') 
TSR <- getTSR(TS) # rebalance properly joined
require(lubridate)
TSR2 <- getTSR(TS,weeks(2)); TSR3 <- getTSR(TS,months(2))  # rebalance not properly joined
## -- get a TSFR object
factorFun <- "gf_demo"
factorPar <- list(0,1)
TSF <- getTSF(TS,factorFun,factorPar)
TSFR <-  getTSR(TSF)

QuantAndrew/QDataGet documentation built on May 14, 2019, 7:35 a.m.