-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
'NaTType' object has no attribute 'ordinal' #678
'NaTType' object has no attribute 'ordinal' #678
Comments
I did a lot of research and the source of the problem is from the function 'plot_drawdown_periods', Line number 403 in plotting.py in pyfolio. Specifically the line that is calculating the drawdown table 'df_drawdowns = timeseries.gen_drawdown_table(returns, top=top)'. Line number 432 in plotting.py in pyfolio. While calculating the drawdowns, it has several NaT and nan values that are not able to convert into datetime and hence the error. The quick fix is to use df_drawdowns.dropna() after calculating but that will create a problem in setting colors[i]. Appreciate the fix. I am trying to understand the function. |
Found the fix. Don't process if the peak or recovery are NaT values. Change the for loop to the following. This is not a fix but just to suppress drawdowns for which we don't have peak/recovery values.
|
I have the returns, positions, and transactions for 30 trading days. It throws an error. But when I run the same for 60 trading days, it works fine.
pyfolio.tears.create_full_tear_sheet(returns1, positions1, transactions1, round_trips=True)
When I run the same code for 60 trading days, it works fine as expected. Looking at the error, it is trying to convert NaT to datetime, but the dataframe has no NaT value.
The text was updated successfully, but these errors were encountered: