Quantstats (Python library) does not display plot

Quantstats is a commonly used library, but I have problems in running examples given its website. The following code is an example from Quantstats webpage, but it does not display a figure.

import quantstats as qt
stock = qt.utils.download_returns('FB')
qt.plots.snapshot(stock)

Furthermore, the following code (also an example from Quantstats website) raise an error message "ValueError: file must be specified"

qt.reports.html(stock, "SPY")

For your information, I am running Python in Pycharm.

Any comment and advice would be very much appreciated.

1 Answer

ultados de tradução Hello @david78.

I had the same error. Reading the project code on github, I found that:

`if the output is None and not _utils._in_notebook():

 raise ValueError("`file` must be specified")`

The _in_notebook() function checks your environment (notebook, command line, etc).

The output parameter determines whether you download a file or not.

I still had some issues with compatibility requirements for plotting on Jupyter or Google Colab notebooks, and with me plotting on notebooks still has a problem.

But, I found that if you include any value in the output parameter, you will get an html file in your local path. For example, I passed output='analytics.html' or output=True and I can get the html report file in my local path. The final code was:

qs.reports.html(stock, "SPY", output=True).

In Pycharm you don't have a built-in graph, so the specified output parameter solves your problem.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like