El siguiente script, me devuelve el error que menciono en el título.
import pandas as pd
import yfinance as yf
from datetime import date
def get_quotes(ticker, start_day, end_day):
yfObj = yf.Ticker(ticker)
value_name = yfObj.info['shortName']
df_val = yf.download(ticker, start= start_day, end = end_day, progress=False)
df_val.rename(columns={'Adj Close': value_name }, inplace=True)
df_value = df_val.copy(deep=True)
df_value.drop(['Open', 'High', 'Low', 'Close', 'Volume'], axis=1 , inplace=True)
return df_val, df_value, value_name
ticker_val = 'AAPL'
start_date = "2010-01-04"
end_date = "2021-03-05"
#end_day = date.today()
# Market quotes
df_val, df_value, value_name = get_quotes(ticker_val, start_date, end_date)
df_val
Me devuelve.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/tmp/ipykernel_20690/2061734020.py in <module>
19
20 # Market quotes
---> 21 df_val, df_value, value_name = get_quotes(ticker_val, start_date, end_date)
22 df_val
/tmp/ipykernel_20690/2061734020.py in get_quotes(ticker, start_day, end_day)
5 def get_quotes(ticker, start_day, end_day):
6 yfObj = yf.Ticker(ticker)
----> 7 value_name = yfObj.info['shortName']
8 df_val = yf.download(ticker, start= start_day, end = end_day, progress=False)
9 df_val.rename(columns={'Adj Close': value_name }, inplace=True)
~/anaconda3/envs/enri/lib/python3.9/site-packages/yfinance/ticker.py in info(self)
136 @property
137 def info(self) -> dict:
--> 138 return self.get_info()
139
140 @property
~/anaconda3/envs/enri/lib/python3.9/site-packages/yfinance/base.py in get_info(self, proxy)
892 def get_info(self, proxy=None) -> dict:
893 self._quote.proxy = proxy
--> 894 data = self._quote.info
895 return data
896
~/anaconda3/envs/enri/lib/python3.9/site-packages/yfinance/scrapers/quote.py in info(self)
25 def info(self) -> dict:
26 if self._info is None:
---> 27 self._scrape(self.proxy)
28 self._scrape_complementary(self.proxy)
29
~/anaconda3/envs/enri/lib/python3.9/site-packages/yfinance/scrapers/quote.py in _scrape(self, proxy)
56 json_data = self._data.get_json_data_stores(proxy=proxy)
57 try:
---> 58 quote_summary_store = json_data['QuoteSummaryStore']
59 except KeyError:
60 err_msg = "No summary info found, symbol may be delisted"
TypeError: string indices must be integers
¿Cuál puede ser la causa?. Agradeceré ayuda.