Closed kdg862 closed 3 years ago
I was doing this in a Jupyter notebook running Python 3.8.5. Here is the full error message:
ImportError Traceback (most recent call last)
You have to change matplotlib backend
if you are using a mac you have to change ~/.matplotlib/matplotlibrc to MacOSX. If you are using linux I believe you change it to another option that I forget but try these:
I've also faced the same issue when calling the backtest method. 💔
If we dig deeper the issue is due to the backtrader library that fastquant depends on. 🤔
There's already a fix for this issue https://github.com/mementum/backtrader/commit/0fa63ef4a35dc53cc7320813f8b15480c8f85517 😃
But it is yet to be released in a new version and I sincerely doubt there will be a new release in short time. The latest release for backtrader was way back in the month of May-2020. 😓
I have a hack around it. Just follow the 2 steps below: 🥳
This installs backtrader with fix and enjoy the plots.
If this still persists, one can also change the matplotlib version to 3.2.2 as seen here: https://stackoverflow.com/questions/63471764/importerror-cannot-import-name-warnings-from-matplotlib-dates
@mikeejazmines THANK YOU! Was going mad. Everything is working perfectly for me now. Cheers!
I was just trying to follow the tutorial, but cannot get plotting to work. I was trying to run the following:
from fastquant import backtest from fastquant import get_crypto_data crypto = get_crypto_data("BCH/USDT", "2021-01-01", "2021-04-24") backtest("smac", crypto, fast_period=15, slow_period=40)
And received this error: ImportError: cannot import name 'warnings' from 'matplotlib.dates'
Similar issues on stack overflow suggested downgrading Matplotlib to 3.2.2. I tried this and it unfortunately did not help.