quantopian / alphalens

Performance analysis of predictive (alpha) stock factors
http://quantopian.github.io/alphalens
Apache License 2.0
3.26k stars 1.13k forks source link

compute_mean_return_spread returns error if no std_err argument #299

Closed MichaelJMath closed 6 years ago

MichaelJMath commented 6 years ago

https://github.com/quantopian/alphalens/blob/b45d508f63140ce325096306a3df5c76cd68c729/alphalens/performance.py#L649-L656

https://github.com/quantopian/alphalens/blob/b45d508f63140ce325096306a3df5c76cd68c729/alphalens/performance.py#L685-L690

The docstring states that the function optionally computes the standard error this difference. However, if no argument is provided for std_err, the function will raise an error. Should the docstring be changed or should we change the code to something like:

if std_err is None:  
    joint_std_err = None  
else:
    std1 = std_err.xs(upper_quant, level='factor_quantile')
    std2 = std_err.xs(lower_quant, level='factor_quantile')
    joint_std_err = np.sqrt(std1**2 + std2**2)
luca-s commented 6 years ago

Good catch! I would prefer to set joint_std_err = None

luca-s commented 6 years ago

Closed by #302