Closed Dgomzi closed 5 years ago
Please have a look at get_clean_factor_and_forward_returns implementation, You will see that it computes forward returns, which you already have and then it calls get_clean_factor, that is what you need to call. In doing so, please make sure your forward returns are properly formatted (the format is documented in get_clean_factor
function).
Once you are sure that your input data is properly formatted everything should work fine. If that's not the case please report the error you get together with a minimal example that is able to reproduce the error.
thanks.
My forward returns column names are ('1M','3M','12M') respectively for monthly/quarterly/annual returns. Will this work? I can see in "get_clean_factor" documentation column names should follow pd.Timedelta format. When I try pd.Timedelta('1M') it returns Timedelta('0 days 00:01:00') i.e. 1 minute object
When I try pd.Timedelta('1M') it returns Timedelta('0 days 00:01:00') i.e. 1 minute object
Exactly, that's the problem. 'M' refers to minute. Also, it wouldn't be a good a idea to specify the forward return period as number of months or years, since those don't represent a specific number of days. I would suggest you to use the exact number of trading days your returns represent (e.g. "252D" for a year or "21D" for a month). Then make sure to call infer_trading_calendar like here, so that Alphalens will be able to handle holidays, weekends and all the non-trading days correctly
Feel free to re-open the issue if you still have problems with this
Hi, I run into similar problems here as I would like to analyze 1 month forward returns at month ends. I used '21D' as the forwarding return name, and it works well. However, may I ask how you solve the freq issue if you have any? I have a month-end price dataset, and the df.index.levels[0].freq = M as I have month-end dates. I don't think using Bday=21 would solve this problem as adding 21 business days does not always return month ends.
use alphalens.tears.create_returns_tear_sheet with quarterly/annually dataseries
Since I have access to return data, I didn't use utils.get_clean_factor_and_forward_returns but created dataframe as suggested. I also set df.index.levels[0].freq = pd.DateOffset(months = 1)
df.head()
But I am not getting graphs. Is there some way to generate quantile performance charts using alphalens using longer frequency dataseries