因子诊断与样本覆盖
原能力
输出因子诊断、有效样本及覆盖情况,不以不足样本给出确定判断。(合同附件 R7 10.9)
首选项目
Alphalens(Apache-2.0)。 Alphalens
匹配范围
因子收益分析和样本结构验证。
源码
Alphalens · def get_clean_factor_and_forward_returns(
alphalens/utils.py · 666–679 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def get_clean_factor_and_forward_returns(factor,
prices,
groupby=None,
binning_by_group=False,
quantiles=5,
bins=None,
periods=(1, 5, 10),
filter_zscore=20,
groupby_labels=None,
max_loss=0.35,
zero_aware=False,
cumulative_returns=True):
"""
Formats the factor data, pricing data, and group mappings into a DataFrame
- # Copyright 2018 Quantopian, Inc.
Alphalens · def factor_information_coefficient(
alphalens/performance.py · 28–41 行。 在 GitHub 查看源码 · 许可证与声明
源码片段
def factor_information_coefficient(factor_data,
group_adjust=False,
by_group=False):
"""
Computes the Spearman Rank Correlation based Information Coefficient (IC)
between factor values and N period forward returns for each period in
the factor index.
Parameters
----------
factor_data : pd.DataFrame - MultiIndex
A MultiIndex DataFrame indexed by date (level 0) and asset (level 1),
containing the values for a single alpha factor, forward returns for
each period, the factor quantile/bin that factor value belongs to, and
- # Copyright 2017 Quantopian, Inc.
实现与验收要点
分组口径、样本母集、截断、数据可得性和封存。