bt icon indicating copy to clipboard operation
bt copied to clipboard

bt.get gives IndexError: tuple index out of range

Open cgates30 opened this issue 3 years ago • 17 comments

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.

cgates30 avatar Apr 25 '21 00:04 cgates30

I bumped into the same issue earlier this week. I was able to solve it by upgrading decorator to version 5.0.7.

samuel-poon avatar Apr 25 '21 14:04 samuel-poon

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.

cgates30 avatar Apr 25 '21 15:04 cgates30

Which version of decorator do you have on the other computer? You should be able to upgrade it using pip3 install decorator --upgrade.

samuel-poon avatar Apr 25 '21 15:04 samuel-poon

I updated from decorator 4.4.2 to 5.0.7, but unfortunately I'm getting the same error.

cgates30 avatar Apr 25 '21 16:04 cgates30

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

cgates30 avatar Apr 25 '21 17:04 cgates30

This is strange. What version of ffn do you have? bt.get() should be an alias for ffn.get().

samuel-poon avatar Apr 26 '21 21:04 samuel-poon

I have ffn (0.3.6)

cgates30 avatar Apr 28 '21 01:04 cgates30

I was having same issue. I solved it updating decorator from 5.0.6 to 5.0.7 using pip3 install decorator --upgrade

O1dBoy avatar Apr 28 '21 13:04 O1dBoy

I have the same issue after updating everything: bt 0.2.9 ffn 0.3.6 decorator 5.0.9

ch3st3rt0n avatar May 17 '21 01:05 ch3st3rt0n

i upgraded the decorator. Still unable to solve. Appreciate troubleshooting suggestions.

dhiraj797 avatar May 27 '21 10:05 dhiraj797

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:

image001-46

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()

JackDaoud avatar Jun 02 '21 03:06 JackDaoud

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.

image

samuel-poon avatar Jun 02 '21 03:06 samuel-poon

@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.

JackDaoud avatar Jun 02 '21 03:06 JackDaoud

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?

JackDaoud avatar Jun 02 '21 21:06 JackDaoud

The error is gone after upgrading decorator from 5.0.6 to 5.0.9.

arisliang avatar Jun 16 '21 01:06 arisliang

thanks everyone got it fix by upgrading decorator from 5.0.6 to 5.1.0

CDLim0906 avatar Dec 21 '21 22:12 CDLim0906

pip3 install decorator --upgrade

That worked for me. Thanks @O1dBoy

Georgi-Petkov avatar May 26 '22 07:05 Georgi-Petkov

pip install decorator --upgrade

that worked for me. thanks

soroush-khv avatar Dec 16 '23 05:12 soroush-khv

https://github.com/micheles/decorator/blob/master/CHANGES.md#507-2021-04-14 https://github.com/pmorissette/ffn/pull/216

timkpaine avatar Dec 17 '23 22:12 timkpaine