1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-06-06 05:51:17 +08:00

add CSRankNorm impl

This commit is contained in:
Dong Zhou
2020-11-24 10:20:29 +08:00
parent 641e7f38bc
commit e2485bcf2b

View File

@@ -215,5 +215,8 @@ class CSRankNorm(Processor):
def __call__(self, df):
# try not modify original dataframe
cols = get_group_columns(df, self.fields_group)
df[cols] = df[cols].groupby("datetime").apply(lambda df: (df - df.mean()).div(df.std()))
t = df[cols].groupby("datetime").rank(pct=True)
t -= 0.5
t *= 3.46 # NOTE: towards unit std
df[cols] = t
return df