Back to Community
pyfolio create_full_tear_sheet problem in research

I run zipline in research, then take the backtest results and run them through pyfolio, but it fails. Can someone suggest what went wrong? I attach the notebook.

/usr/local/lib/python2.7/dist-packages/numpy/lib/nanfunctions.py:598: RuntimeWarning: Mean of empty slice
  warnings.warn("Mean of empty slice", RuntimeWarning)  
/usr/local/lib/python2.7/dist-packages/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.
  warnings.warn("Mean of empty slice.", RuntimeWarning)  
/usr/local/lib/python2.7/dist-packages/numpy/lib/function_base.py:1890: RuntimeWarning: Degrees of freedom <= 0 for slice
  warnings.warn("Degrees of freedom <= 0 for slice", RuntimeWarning)  
---------------------------------------------------------------------------  
TypeError                                 Traceback (most recent call last)  
<ipython-input-24-f15a0a2e7356> in <module>()  
      1 pf.create_full_tear_sheet(returns, positions=positions, transactions=transactions,  
----> 2                           gross_lev=gross_lev, live_start_date='2000-01-01')

/usr/local/lib/python2.7/dist-packages/pyfolio/tears.pyc in create_full_tear_sheet(returns, positions, transactions, benchmark_rets, gross_lev, slippage, live_start_date, sector_mappings, bayesian, round_trips, hide_positions, cone_std, set_context)
    157         cone_std=cone_std,  
    158         benchmark_rets=benchmark_rets,  
--> 159         set_context=set_context)  
    160  
    161     create_interesting_times_tear_sheet(returns,

/usr/local/lib/python2.7/dist-packages/pyfolio/plotting.pyc in call_w_context(*args, **kwargs)
     44         if set_context:  
     45             with context():  
---> 46                 return func(*args, **kwargs)  
     47         else:  
     48             return func(*args, **kwargs)

/usr/local/lib/python2.7/dist-packages/pyfolio/tears.pyc in create_returns_tear_sheet(returns, live_start_date, cone_std, benchmark_rets, return_fig)
    274         live_start_date=live_start_date,  
    275         cone_std=cone_std,  
--> 276         ax=ax_rolling_returns)  
    277     ax_rolling_returns.set_title(  
    278         'Cumulative Returns')

/usr/local/lib/python2.7/dist-packages/pyfolio/plotting.pyc in plot_rolling_returns(returns, factor_returns, live_start_date, cone_std, legend_loc, volatility_match, cone_function, ax, **kwargs)
    613  
    614     is_cum_returns.plot(lw=3, color='forestgreen', alpha=0.6,  
--> 615                         label='Backtest', ax=ax, **kwargs)  
    616  
    617     if len(oos_cum_returns) > 0:

/usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in plot_series(data, kind, ax, figsize, use_index, title, grid, legend, style, logx, logy, loglog, xticks, yticks, xlim, ylim, rot, fontsize, colormap, table, yerr, xerr, label, secondary_y, **kwds)
   2517                  yerr=yerr, xerr=xerr,  
   2518                  label=label, secondary_y=secondary_y,  
-> 2519                  **kwds)  
   2520  
   2521 

/usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in _plot(data, x, y, subplots, ax, kind, **kwds)
   2322         plot_obj = klass(data, subplots=subplots, ax=ax, kind=kind, **kwds)  
   2323  
-> 2324     plot_obj.generate()  
   2325     plot_obj.draw()  
   2326     return plot_obj.result

/usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in generate(self)
    910     def generate(self):  
    911         self._args_adjust()  
--> 912         self._compute_plot_data()  
    913         self._setup_subplots()  
    914         self._make_plot()

/usr/local/lib/python2.7/dist-packages/pandas/tools/plotting.pyc in _compute_plot_data(self)
   1015         if is_empty:  
   1016             raise TypeError('Empty {0!r}: no numeric data to '  
-> 1017                             'plot'.format(numeric_data.__class__.__name__))  
   1018  
   1019         self.data = numeric_data

TypeError: Empty 'DataFrame': no numeric data to plot

Loading notebook preview...
Notebook previews are currently unavailable.
1 response

Hi Paul! A shot in the dark here, but the summary table at the beginning indicates that Entire data start date: 2002-01-04, but you pass in live_start_date='2000-01-01': before any of your data even begins. This may explain why you get a warning of a "Mean of an empty slice"... there's no in-sample data. Try passing in a live_start_date after 2002-01-04. Let me know if that works!