quantopian / alphalens

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

performance.py error when weights freq is None #316

Closed javifalces closed 5 years ago

javifalces commented 5 years ago

On line 205 , method to_weights .

the expression

weights.index.levels[0].freq = factor_data.index.levels[0].freq

is trying to assign a freq , but when is None, raise an error

same as here

I think could be fixed just with that

weights.index.levels[0].freq= pd.tseries.frequencies.to_offset(factor_data.index.levels[0].freq)

luca-s commented 5 years ago

factor_data should conform to the output of utils.get_clean_factor_and_forward_returns and there documented. it requires freq to be set. So I don't know why you encountered that error. Could you please share some code that produces that error so that we can better understand the issue?

luca-s commented 5 years ago

There is a function, infer_trading_calendar, which can be used to computed freq but that doesn't solve the problem: why isn't freq set in your code?

luca-s commented 5 years ago

Feel free to reopen this issue if you have a test case where Alphalens fails