pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
1.9k stars 284 forks source link

TypeError: string indices must be integers #187

Closed pupuyoyo closed 1 year ago

pupuyoyo commented 1 year ago

First, thanks for writing this great financial functions for python. However, when I run the library, the following error message appeared.

import ffn prices = ffn.get('aapl,msft', start='2010-01-01')

TypeError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_30212/2674933125.py in ----> 1 prices = ffn.get('aapl,msft', start='2010-01-01')

~\anaconda3\envs\invest\lib\site-packages\decorator.py in fun(*args, *kw) 230 if not kwsyntax: 231 args, kw = fix(args, kw, sig) --> 232 return caller(func, (extras + args), **kw) 233 fun.name = func.name 234 fun.doc = func.doc

~\anaconda3\envs\invest\lib\site-packages\ffn\utils.py in _memoize(func, *args, *kw) 32 return cache[key] 33 else: ---> 34 cache[key] = result = func(args, **kw) 35 return result 36

~\anaconda3\envs\invest\lib\site-packages\ffn\data.py in get(tickers, provider, common_dates, forward_fill, clean_tickers, column_names, ticker_field_sep, mrefresh, existing, kwargs) 74 # call provider - check if supports memoization 75 if hasattr(provider, "mcache"): ---> 76 data[ticker] = provider(ticker=t, field=f, mrefresh=mrefresh, kwargs) 77 else: 78 data[ticker] = provider(ticker=t, field=f, **kwargs)

~\anaconda3\envs\invest\lib\site-packages\decorator.py in fun(*args, *kw) 230 if not kwsyntax: 231 args, kw = fix(args, kw, sig) --> 232 return caller(func, (extras + args), **kw) 233 fun.name = func.name 234 fun.doc = func.doc

~\anaconda3\envs\invest\lib\site-packages\ffn\utils.py in _memoize(func, *args, *kw) 32 return cache[key] 33 else: ---> 34 cache[key] = result = func(args, **kw) 35 return result 36

~\anaconda3\envs\invest\lib\site-packages\ffn\data.py in yf(ticker, field, start, end, mrefresh) 138 field = "Adj Close" 139 --> 140 tmp = pdata.get_data_yahoo(ticker, start=start, end=end) 141 142 if tmp is None:

~\anaconda3\envs\invest\lib\site-packages\pandas_datareader\data.py in get_data_yahoo(*args, kwargs) 78 79 def get_data_yahoo(*args, *kwargs): ---> 80 return YahooDailyReader(args, kwargs).read() 81 82

~\anaconda3\envs\invest\lib\site-packages\pandas_datareader\base.py in read(self) 251 # If a single symbol, (e.g., 'GOOG') 252 if isinstance(self.symbols, (string_types, int)): --> 253 df = self._read_one_data(self.url, params=self._get_params(self.symbols)) 254 # Or multiple symbols, (e.g., ['GOOG', 'AAPL', 'MSFT']) 255 elif isinstance(self.symbols, DataFrame):

~\anaconda3\envs\invest\lib\site-packages\pandas_datareader\yahoo\daily.py in _read_one_data(self, url, params) 151 try: 152 j = json.loads(re.search(ptrn, resp.text, re.DOTALL).group(1)) --> 153 data = j["context"]["dispatcher"]["stores"]["HistoricalPriceStore"] 154 except KeyError: 155 msg = "No data fetched for symbol {} using {}"

TypeError: string indices must be integers

Hope you can help to fix it. Thanks again!

timkpaine commented 1 year ago

https://stackoverflow.com/help/how-to-ask

Before posting a question, we strongly recommend that you spend a reasonable amount of time researching the problem and searching for existing questions on this site that may provide an answer.

The title is the first thing that potential answerers will see. If your title isn't interesting, they won't read the rest. Also, without a good title, people may not even be able to find your question. So, make the title count: