quantopian / pyfolio

Portfolio and risk analytics in Python
https://quantopian.github.io/pyfolio
Apache License 2.0
5.71k stars 1.78k forks source link

attribute 'to_pydatetime' error #623

Open appusinghi opened 5 years ago

appusinghi commented 5 years ago

How do I resolve this ?


AttributeError Traceback (most recent call last)

in ----> 1 pf.create_full_tear_sheet(data) C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\tears.py in create_full_tear_sheet(returns, positions, transactions, market_data, benchmark_rets, slippage, live_start_date, sector_mappings, bayesian, round_trips, estimate_intraday, hide_positions, cone_std, bootstrap, unadjusted_returns, style_factor_panel, sectors, caps, shares_held, volumes, percentile, turnover_denom, set_context, factor_returns, factor_loadings, pos_in_dollars, header_rows, factor_partitions) 209 turnover_denom=turnover_denom, 210 header_rows=header_rows, --> 211 set_context=set_context) 212 213 create_interesting_times_tear_sheet(returns, C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\plotting.py in call_w_context(*args, **kwargs) 50 if set_context: 51 with plotting_context(), axes_style(): ---> 52 return func(*args, **kwargs) 53 else: 54 return func(*args, **kwargs) C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\tears.py in create_returns_tear_sheet(returns, positions, transactions, live_start_date, cone_std, benchmark_rets, bootstrap, turnover_denom, header_rows, return_fig) 502 header_rows=header_rows) 503 --> 504 plotting.show_worst_drawdown_periods(returns) 505 506 vertical_sections = 11 C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\plotting.py in show_worst_drawdown_periods(returns, top) 1662 """ 1663 -> 1664 drawdown_df = timeseries.gen_drawdown_table(returns, top=top) 1665 utils.print_table( 1666 drawdown_df.sort_values('Net drawdown in %', ascending=False), C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\timeseries.py in gen_drawdown_table(returns, top) 1004 recovery, 1005 freq='B')) -> 1006 df_drawdowns.loc[i, 'Peak date'] = (peak.to_pydatetime() 1007 .strftime('%Y-%m-%d')) 1008 df_drawdowns.loc[i, 'Valley date'] = (valley.to_pydatetime() AttributeError: 'datetime.date' object has no attribute 'to_pydatetime'
lionelyoung commented 4 years ago

If you are using pandas >= 1.0, install the latest from git, since the fixed was merged in #634

pip install git+https://github.com/quantopian/pyfolio.git

r8shen commented 4 years ago

Hi, I am using jupyter notebook, I installed pyfolio from pypl and have the "AttributeError: 'datetime.date' object has no attribute 'to_pydatetime'" what should I do if I run my notebook locally?

ngtrunghuan commented 3 years ago

Please close this ticket. This has been resolved in #634