Back to Community
How to get the correct (if any) factor boundary from Alphalens result?

Hi,

I am tinkering around get_clean_factor_and_forward_returns function to decide the factor value to put threshold hold at.
For that, I group by "factor_quantile" and get the max / min of the "factor" value within each group.

def p_05(a):
return np.percentile(a, 10)

def p_95(a):
return np.percentile(a, 90)

print factor_data.groupby('factor_quantile')['factor'].agg([p_05, p_95, np.median, np.mean])

which gives,

p_05 p_95 median mean factor_quantile
1 -0.254382 -0.020922 -0.111486 -0.129380
2 -0.105813 0.041763 -0.020395 -0.025799
3 -0.054055 0.085466 0.022410 0.019584
4 -0.018197 0.120158 0.056063 0.054079
5 0.012889 0.152255 0.085542 0.084698
6 0.042355 0.183583 0.114337 0.114602
7 0.073873 0.221787 0.146994 0.148372
8 0.112517 0.271692 0.186717 0.189632
9 0.161270 0.345069 0.247513 0.250814
10 0.260082 0.797860 0.397690 0.530298

I even used the 5 / 95 percentile values to avoid buggy outliers in each factor_group, but the top value of lower factor_group surpasses that of the bottom value of the next higher factor_group.

So I would like to know
a. why I get such result
b. is Alphalens' factor analysis correct?
c. what is the correct way of getting factor_group boundary value? (maybe should I use bins instead of quantiles?)

Thank you.

1 response

bump