mhallsmoore / qstrader

QuantStart.com - QSTrader backtesting simulation engine.
https://www.quantstart.com/qstrader/
MIT License
2.84k stars 851 forks source link

KeyError: 'gridOn' on focal and Fedora 33 #347

Closed b4d0n3 closed 3 years ago

b4d0n3 commented 3 years ago
Ending backtest simulation.
Plotting the tearsheet...
Traceback (most recent call last):
  File "examples/sixty_forty.py", line 72, in <module>
    tearsheet.plot_results()
  File "/qstrader/qstrader/statistics/tearsheet.py", line 308, in plot_results
    self._plot_equity(stats, bench_stats=bench_stats, ax=ax_equity)
  File "/qstrader/qstrader/statistics/tearsheet.py", line 76, in _plot_equity
    ax.xaxis.grid(linestyle=':')
  File "/usr/local/lib/python3.8/dist-packages/matplotlib/axis.py", line 1448, in grid
    gridkw['gridOn'] = not self._major_tick_kw['gridOn']
KeyError: 'gridOn'

This seems specific to matplotlib 3.3.3 as if I downgrade to any other version it works.

$ pip3 install matplotlib==3.3.2
$ python3 examples/sixty_forty.py
...
(2019-12-31 14:30:00+00:00) - market_open
(2019-12-31 21:00:00+00:00) - market_close
Ending backtest simulation.
Plotting the tearsheet...
$

It's not clear, at least to me, whether this is a bug in this version of matplotlib but I suspect the most expedient solution for now would be to disallow this version and see if the next release fixes the issue?

I'll create a PR for this in case you want to go this way.