enzoampil / fastquant

fastquant — Backtest and optimize your ML trading strategies with only 3 lines of code!
MIT License
1.48k stars 236 forks source link

fastquant fails to render backtest() result in Jupyter Notebook #382

Open miohtama opened 2 years ago

miohtama commented 2 years ago

Problem description

fastquant fails to render backtest() result chart

Example

Running Lesson 2 Notebook on Google Colab here:

https://colab.research.google.com/github/enzoampil/fastquant-blog/blob/master/_notebooks/2020-03-09-lesson2-backtest-your-trading-strategy.ipynb

Expected behavior

I get a diagram for backtest function call result

image

Actual behavior

There is no diagram

image

Sometimes diagram may appear if I run the cell again. Sometimes not. Diagrams are definitely not rendered on Run all cells. The size of the diagram seems to be completely random. Most of the time it does not work.

image image

It seems that render success only around 1/4 of time.

Environment

I tested 2x2 different Jupyter Notebook environments

Other

Other plots are rendered without problem, e.g. ones at the start of the notebook

image

This seems to be an underlying matplotlib library issue and affects vanilla Backtrader too. I spend some hours trying to figure out what is causing this and if it could be worked around by, for example, by forcing diagrams to be inline static PNg images. There is something in the Backtrader diagram, especially the backtest result, which causes Jupyter Notebook to choke.

I did not find any solution.