Description Usage Arguments Value Author(s) See Also Examples
View source: R/fct01_frameBuildingFuncs.R
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.
1 |
TS |
a TS or TSF object (See detail in |
dure |
a period object from package |
date_end_pad |
a Date value, padding the NAs of the last date_end. if missing, calculated automatically. |
given a TS object,return a TSR object,a dataframe containing cols:
stockID: the stockID contained in the index or BK
date: the rebalance dates, with Date
class
date_end: the next rebalance dates, with Date
class
periodrtn:the period rtn between the rebalance date and the date_end
given a TSF object,return a TSFR object,a dataframe containing cols:
stockID: the stockID contained in the index or BK
date: the rebalance dates, with Date
class
factorscore:the factor score of the stocks on the rebalancing date
date_end: the next rebalance dates, with Date
class
periodrtn:the period rtn between the rebalance date and the date_end
Ruifei.Yin
Other frame building functions: getRebDates
,
getTSF
, getTS
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.