1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-15 08:46:56 +08:00

recorder refine; signalTemp; fixbug

This commit is contained in:
Young
2020-11-21 15:20:47 +00:00
parent a0fe6941d2
commit e5923333f5
6 changed files with 133 additions and 79 deletions

32
qlib/contrib/eva/alpha.py Normal file
View File

@@ -0,0 +1,32 @@
'''
Here is a batch of evaluation functions.
The interface should be redesigned carefully in the future.
'''
import pandas as pd
def calc_ic(pred: pd.Series, label: pd.Series, date_col='datetime', dropna=False) -> (pd.Series, pd.Series):
"""calc_ic.
Parameters
----------
pred :
pred
label :
label
date_col :
date_col
Returns
-------
(pd.Series, pd.Series)
ic and rank ic
"""
df = pd.DataFrame({'pred': pred, 'label': label})
ic = df.groupby(date_col).apply(lambda df: df['pred'].corr(df['label']))
ric = df.groupby(date_col).apply(lambda df: df['pred'].corr(df['label'], method='spearman'))
if dropna:
return ic.dropna(), ric.dropna()
else:
return ic, ric