Closed githubkingchamp closed 1 year ago
I have the same problems "TypeError: string indices must be integers"
54.70.249.11 - IP Info - Yahoo Finance on Amazon AWS. is not responding
same issue with getting last value, however the website appears up and running, @chingybrooks what do you mean with your comment?
+1
same issue with getting last value, however the website appears up and running, @chingybrooks what do you mean with your comment?
I thought the reason is that the API is not available
I think the data is coming back encoded and or encrypted. Beyond my capabilities to fix, but looks that way.
I have created a pull request with the fix hopefully it will be accepted too. I found the fix on a separate package: https://github.com/ranaroussi/yfinance/pull/1253/commits/8e5f0984af347afda6be74b27a989422e49a975b
Yes, same issue on my side.
I also get the same issue using yahoo_financials.get_current_price() method. Any update on this issue?
I also get the same issue using yahoo_financials.get_current_price() method. Any update on this issue?
check the answer from sedwards2000 updating the file worked for me. But make sure you also have crypto module installed
pip3 install pycryptodome
Hey, I am new to GitHub and I faced the same issue and now here is the fix but I don't know what to do with the code given, like should I execute it or what am I suppose to do
Hey, I am new to GitHub and I faced the same issue and now here is the fix but I don't know what to do with the code given, like should I execute it or what am I suppose to do
Hi!
You have to change the source code yourself applying the changes highlighted in the pull request. https://github.com/JECSand/yahoofinancials/commit/62119be23fe81f89fd5fb1bd450fc2088667c8df
You have to modify yahoofinancials module’s __init__.py
file; there are two ways to find it:
__init__.py
Apply the changes and that's it! Just make sure you have "pycryptodome" module installed
One easy way to install working yahoo financials
library is to install library from merge request 62119be, until @JECSand Accept this merge request to master repository fixed encryption of incoming stock data #106.
Thanks @sedwards2000
Code:
!pip install -U git+https://github.com/sedwards2000/yahoofinancials@encryptionDataFix
!pip install pycryptodome
from yahoofinancials import YahooFinancials
yahoo_financials = YahooFinancials('AAPL')
print("Apple current price in $",yahoo_financials.get_current_price())
OUTPUT:
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Collecting git+https://github.com/sedwards2000/yahoofinancials@encryptionDataFix
Cloning https://github.com/sedwards2000/yahoofinancials (to revision encryptionDataFix) to /tmp/pip-req-build-6g1jpfqp
Running command git clone -q https://github.com/sedwards2000/yahoofinancials /tmp/pip-req-build-6g1jpfqp
Running command git checkout -b encryptionDataFix --track origin/encryptionDataFix
Switched to a new branch 'encryptionDataFix'
Branch 'encryptionDataFix' set up to track remote branch 'encryptionDataFix' from 'origin'.
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.8/dist-packages (from yahoofinancials==1.6) (4.11.1)
Requirement already satisfied: pytz in /usr/local/lib/python3.8/dist-packages (from yahoofinancials==1.6) (2022.6)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.8/dist-packages (from beautifulsoup4->yahoofinancials==1.6) (2.3.2.post1)
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: pycryptodome in /usr/local/lib/python3.8/dist-packages (3.16.0)
Apple current price in $ 131.86
Hey, I am new to GitHub and I faced the same issue and now here is the fix but I don't know what to do with the code given, like should I execute it or what am I suppose to do
Hi!
You have to change the source code yourself applying the changes highlighted in the pull request. 62119be
You have to modify yahoofinancials module’s
__init__.py
file; there are two ways to find it:
- use your IDE "Find in Files / Scope" (or smth like that) function searching for the original code, for example "track the last get timestamp to add a minimum delay between gets - be nice!"
- or go to the virtual environment folder and follow the path like: lib > site-packages > yahoofinancials >
__init__.py
Apply the changes and that's it! Just make sure you have "pycryptodome" module installed
It worked thanks a lot
Looking at the MR now @divyankm
yahoo_financials.get_key_statistics_data(), Suddenly started throwing error: TypeError: string indices must be integers. Not sure anybody using this python module experiencing the error.
`from yahoofinancials import YahooFinancials
ticker = 'AAPL' yahoo_financials = YahooFinancials(ticker)
conentKeys = yahoo_financials.get_key_statistics_data()
File "/Users/raj/opt/miniconda3/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/Users/raj/opt/miniconda3/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Users/raj/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/main.py", line 39, in
cli.main()
File "/Users/raj/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
run()
File "/Users/raj/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
runpy.run_path(target, run_name="main")
File "/Users/raj/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
return _run_module_code(code, init_globals, run_name,
File "/Users/raj/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/raj/.vscode/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
exec(code, run_globals)
File "/Users/raj/Code/Machine_Learning/wb-starter/scrap_yahoo_finance3.py", line 7, in
conentKeys = yahoo_financials.get_key_statistics_data()
File "/Users/raj/opt/miniconda3/lib/python3.8/site-packages/yahoofinancials/init.py", line 613, in get_key_statistics_data
return self.get_clean_data(self.get_stock_tech_data('defaultKeyStatistics'), 'defaultKeyStatistics')
File "/Users/raj/opt/miniconda3/lib/python3.8/site-packages/yahoofinancials/init.py", line 492, in get_stock_tech_data
return self.get_stock_data(statement_type='keystats', tech_type=tech_type)
File "/Users/raj/opt/miniconda3/lib/python3.8/site-packages/yahoofinancials/init.py", line 476, in get_stock_data
dict_ent = self._create_dict_ent(self.ticker, statement_type, tech_type, report_name, hist_obj)
File "/Users/raj/opt/miniconda3/lib/python3.8/site-packages/yahoofinancials/init.py", line 409, in _create_dict_ent
re_data = self._scrape_data(YAHOO_URL, tech_type, statement_type)
File "/Users/raj/opt/miniconda3/lib/python3.8/site-packages/yahoofinancials/init.py", line 169, in _scrape_data
stores = data["context"]["dispatcher"]["stores"]["QuoteSummaryStore"][tech_type]
TypeError: string indices must be integers
`