Closed DonedaDiego closed 1 year ago
We've just updated to Pyfolio 0.9.5. Please try with the current version; if you install Zipline, please use the new 2.4.0b1.
Closing for now, feel free to reopen if the issue persists with the current versions.
Problem Description
ttributeError Traceback (most recent call last) Input In [142], in <cell line: 1>() ----> 1 pf.create_full_tear_sheet(carteira["retorno"], benchmark_rets=retorno["^BVSP"])
File C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\tears.py:201, 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) 195 returns = txn.adjust_returns_for_slippage(returns, positions, 196 transactions, slippage) 198 positions = utils.check_intraday(estimate_intraday, returns, 199 positions, transactions) --> 201 create_returns_tear_sheet( 202 returns, 203 positions=positions, 204 transactions=transactions, 205 live_start_date=live_start_date, 206 cone_std=cone_std, 207 benchmark_rets=benchmark_rets, 208 bootstrap=bootstrap, 209 turnover_denom=turnover_denom, 210 header_rows=header_rows, 211 set_context=set_context) 213 create_interesting_times_tear_sheet(returns, 214 benchmark_rets=benchmark_rets, 215 set_context=set_context) 217 if positions is not None:
File C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\plotting.py:52, in customize..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)
File C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\tears.py:504, in create_returns_tear_sheet(returns, positions, transactions, live_start_date, cone_std, benchmark_rets, bootstrap, turnover_denom, header_rows, return_fig) 494 returns = utils.clip_returns_to_benchmark(returns, benchmark_rets) 496 plotting.show_perf_stats(returns, benchmark_rets, 497 positions=positions, 498 transactions=transactions, (...) 501 live_start_date=live_start_date, 502 header_rows=header_rows) --> 504 plotting.show_worst_drawdown_periods(returns) 506 vertical_sections = 11 508 if live_start_date is not None:
File C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\plotting.py:1664, in show_worst_drawdown_periods(returns, top) 1648 def show_worst_drawdown_periods(returns, top=5): 1649 """ 1650 Prints information about the worst drawdown periods. 1651 (...) 1661 Amount of top drawdowns periods to plot (default 5). 1662 """ -> 1664 drawdown_df = timeseries.gen_drawdown_table(returns, top=top) 1665 utils.print_table( 1666 drawdown_df.sort_values('Net drawdown in %', ascending=False), 1667 name='Worst drawdown periods', 1668 float_format='{0:.2f}'.format, 1669 )
File C:\ProgramData\Anaconda3\lib\site-packages\pyfolio\timeseries.py:1008, in gen_drawdown_table(returns, top) 1003 df_drawdowns.loc[i, 'Duration'] = len(pd.date_range(peak, 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() 1009 .strftime('%Y-%m-%d')) 1010 if isinstance(recovery, float): 1011 df_drawdowns.loc[i, 'Recovery date'] = recovery
AttributeError: 'numpy.int64' object has no attribute 'to_pydatetime'
Versions