bt
bt copied to clipboard
bt.get gives IndexError: tuple index out of range
import bt
data = bt.get('aapl', start='2020-01-01')
Gives the following error:
`---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-12-d7d21c925953> in <module>
1 # download data
----> 2 data = bt.get('aapl', start='2020-01-01')
3
4 # calculate moving average DataFrame using pandas' rolling_mean
5 #import pandas as pd
~/anaconda3/envs/stocks/lib/python3.8/site-packages/decorator.py in fun(*args, **kw)
229 if not kwsyntax:
230 args, kw = fix(args, kw, sig)
--> 231 return caller(func, *(extras + args), **kw)
232 fun.__name__ = func.__name__
233 fun.__doc__ = func.__doc__
~/anaconda3/envs/stocks/lib/python3.8/site-packages/ffn/utils.py in _memoize(func, *args, **kw)
18 # kw is not always set - check args
19 if refresh_kw in func.__code__.co_varnames:
---> 20 if args[func.__code__.co_varnames.index(refresh_kw)]:
21 refresh = True
22
IndexError: tuple index out of range
`
Using Jupyter Notebook, Python 3.8.9, bt 0.2.9, pandas 1.2.4
Any help would be appreciated.
I bumped into the same issue earlier this week. I was able to solve it by upgrading decorator to version 5.0.7.
I'm not familiar with updating the decorator, so I will look into that. Thanks for the tip. On another note, I tried the same on a different computer with same versions posted above and it worked. So that indicates there's something else on my installation that is causing the error.
Which version of decorator do you have on the other computer? You should be able to upgrade it using pip3 install decorator --upgrade
.
I updated from decorator 4.4.2 to 5.0.7, but unfortunately I'm getting the same error.
I uninstalled anaconda3, reinstalled navigator, and pip install bt. Still getting the same error. Using Ubuntu 20.10. Used navigator installer Anaconda3-2020.11-Linux-x86_64.sh
I did notice my decorator is now 5.0.6 after the reinstall, so I will update that again.
- pip shows decorator is updated to 5.0.7, but navigator shows 5.0.6
This is strange. What version of ffn do you have? bt.get()
should be an alias for ffn.get()
.
I have ffn (0.3.6)
I was having same issue. I solved it updating decorator from 5.0.6 to 5.0.7 using pip3 install decorator --upgrade
I have the same issue after updating everything: bt 0.2.9 ffn 0.3.6 decorator 5.0.9
i upgraded the decorator. Still unable to solve. Appreciate troubleshooting suggestions.
I personally don't have this issue while working on a MacOS, but one of my students working on a Windows OS is having this issue. I recommended upgrading the decorator as is discussed in this thread. His decorator went from 5.0.6 to 5.0.9, but he's still getting the same error:
Has anyone found a solution?
In the mean time, for anyone interested in getting the same data of bt.get(), you can use the yfinance
package like this:
import yfinance as yf
data = yf.download("FB AMZN AAPL NFLX GOOG", start="2019-12-01")
data = data.loc[:,'Adj Close']
data.tail()
Are you sure it's the right version of decorator? What happens when you run the following?
import decorator
print(decorator.__version__)
The reason why I ask is because on the most recent version of decorator, return caller(func, *extras + args), **kw)
is on line 232, but it appears on line 231 in your error message. This suggests that you're still using an older version.
@samuel-poon apologies for the misleading error message. That error was before updating the decorator. He told me he received the same error after updating the decorator.
My student got back to me saying that after he ran condo update -all
and then restarted his kernel, bt.get() started working normally. Can anyone please test this solution and confirm?
The error is gone after upgrading decorator from 5.0.6 to 5.0.9.
thanks everyone got it fix by upgrading decorator from 5.0.6 to 5.1.0
pip3 install decorator --upgrade
That worked for me. Thanks @O1dBoy
pip install decorator --upgrade
that worked for me. thanks
https://github.com/micheles/decorator/blob/master/CHANGES.md#507-2021-04-14 https://github.com/pmorissette/ffn/pull/216