Description Usage Arguments Details Value Author(s) See Also Examples
View source: R/fct01_frameBuildingFuncs.R
get the TSF ('time-stock-factor') or TSFR('time-stock-factor-rtn') object,by adding the factor score to a TS or TSR object.If necessary,cleaning and stardizing the factor score.
1 2 3 4 5 6 7 8 9 | getTSF(TS, factorFun, factorPar = list(), factorDir = 1,
factorRefine = refinePar_default("none"), FactorList, splitbin = 100000L)
getRawFactor(TS, factorFun, factorPar, FactorList)
getMultiFactor_lcfs(TS, FactorIDs, dir_adj = TRUE, factorRefine = NULL,
wgts, fname_out = c("name", "ID"))
gf_lcfs(TS, factorID, dir_adj = FALSE, factorRefine = NULL)
|
TS |
a TS or TSR objectobject(See detail in |
factorFun |
a character string naming the function to get the factor scores. |
factorPar |
either a list or a character string, containing the parameters of the |
factorDir |
a integer,should be 1 or -1 (1 for the positive factor,-1 for the negative one). |
factorRefine |
a list. |
splitbin |
a integer or a charactor string of 'year','month',... |
getRawFactor
return a TSF object, with 'raw' factorscore, which has not been standardized and not been deal with missing values and outliers. Function getRawFactor
is often called intermediately by function getTSF
.
given a TS object,return a TSF object,a dataframe containing cols:
date: the rebalance dates, with Date
class
stockID: the stockID contained in the index or BK
factorscore:the factor score of the stocks on the rebalancing date
sector(optional):the sector of a stock
given a TSR 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(optional): the next rebalance dates, with Date
class
periodrtn:the period rtn between the rebalance date and the date_end
sector(optional):the sector of a stock
getRawFactor
return a TSF object, with 'raw' factorscore.
Ruifei.Yin
Other frame building functions: getRebDates
,
getTSR
, getTS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | # -- get the TSF step by step --
# - get a TSF object
RebDates <- getRebDates(as.Date('2011-03-17'),as.Date('2012-04-17'),'month')
TS <- getTS(RebDates,'EI000300')
factorFun <- "gf_demo"
factorPar <- list(mean=0,sd=1)
TSF <- getTSF(TS,factorFun,factorPar)
# - get a TSFR object
TSR <- getTSR(TS)
TSFR <- getTSF(TSR)
# -- you can also get the TSF through the modelPar object directively --
modelPar <- modelPar.default()
modelPar <- modelPar.factor(modelPar,factorFun="gf_demo",factorPar=list(0,1))
TSF <- Model.TSF(modelPar)
# -- factorPar as character string
TSF2 <- getTSF(TS,"gf_demo","0,1")
TSF2 <- getTSF(TS,"gf_demo","mean=0,sd=1")
TSF2 <- getTSF(TS,"gf.foo","2,3")
TSF2 <- getTSF(TS,"gf.bar","20,\"IF00\"")
# -- get 'raw' factorscore
TSF_raw <- getRawFactor(TS,"gf.pct_chg_per","20")
# - 3. get multifactor through lcfs
factorIDs <- c("F000001","F000002","F000005")
# -- 3.1 getMultiFactor_lcfs
mTSF <- getMultiFactor_lcfs(TS,factorIDs,factorRefine = refinePar_default("reg"))
# -- 3.2 getRawMultiFactor_lcfs
mTSF <- getMultiFactor_lcfs(TS,factorIDs,dir_adj=FALSE,factorRefine = NULL)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.