fastquant icon indicating copy to clipboard operation
fastquant copied to clipboard

fastquant fails to render backtest() result in Jupyter Notebook

Open miohtama opened this issue 4 years ago • 0 comments

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

  • Both Firefox and Chrome web browsers

  • Google Colab and locally running Jupyter Server on macOS

  • Making sure "Trusted Notebook" is on (see in the screenshots above)

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.

miohtama avatar Jul 22 '21 20:07 miohtama