Comments (16)
@zachpaul38
Could you post a code sample (with tickers you are trying) and full traceback?
Also what version of python are you using? Please note that support for older versions of Python, notably 2.7, was dropped in v1.7.
From my end using Python 3.10 I'm unable to recreate the error:
from yahoofinancials import YahooFinancials
tech_stocks = ['AAPL', 'MSFT', 'INTC']
yahoo_financials_tech = YahooFinancials(tech_stocks)
mc = yahoo_financials_tech.get_market_cap()
print(mc)
returns:
{'AAPL': 1981512941568, 'MSFT': 1785047416832, 'INTC': 110706778112}
from yahoofinancials.
from yahoofinancials.
@zachpaul38 I can try running this from anaconda as well. Are you getting this error when using 1.7 outside of anaconda?
from yahoofinancials.
I am getting the same errors when I use this function. It has working for me for over a year and it stopped working.
part of the traceback using the posted above.
File "C:\Users\User\AppData\Roaming\Python\Python37\site-packages\yahoofinancials_init_.py", line 409, in _create_dict_ent
re_data = self.scrape_data(YAHOO_URL, tech_type, statement_type)
File "C:\Users\User\AppData\Roaming\Python\Python37\site-packages\yahoofinancials_init.py", line 169, in _scrape_data
stores = data["context"]["dispatcher"]["stores"]["QuoteSummaryStore"][tech_type]
TypeError: string indices must be integers
I would like to note that other functions have stopped working, making me think that there is something wrong with parsing.
from yahoofinancials.
from yahoofinancials.
I am not using anaconda myself. I am using native python. The error happened in a python virtual environment but I did not update another library. This stopped working for me in my other desktop but it seems consistent. I am surprised that other people are not getting this error. Do you know what you changed? I am convinced that there was something wrong with the parsing.
from yahoofinancials.
from yahoofinancials.
So I been looking how the code works and it seems the error in my end is on the parser. The parsers builds the json with respect to "context" all the way down to "stores". However, the stores contains a string that seem to be base64 code. Once the python object looks for dictionary key it gets an error.
@JECSand do you happen to know how regex works in this case? Trying to decode base64 seems to fail, perhaps I am regex is not capturing the entire string? I did install jinja2 recently.
from yahoofinancials.
@ivojfabris The only change that has occurred is Yahoo Finance seems to have encrypted their API response data. To solve this issue we had to add "_decryptData" on line 180. I just ran a test just now and it still works for me.
Some possibilities to look into:
-
What version of "pycryptodome" is being installed on your machine for this? I am using pycryptodome==3.16.0. I may need to specify a hard version of that package to get this working universally.
-
What OS are you running this on? Seems like it maybe from a windows machine. I've tested this on Linux and Mac. I can test from a Windows VM after I get off work this evening.
I can also research better ways to decrypt the data.
from yahoofinancials.
@ivojfabris and @zachpaul38
I made some quick updates to the development branch, mainly swapped out pycryptodome with cryptography. Would you mind git cloning that branch and testing these changes out?
from yahoofinancials.
I get the error in two platform. My server is running Ubuntu 20. My desktop is running Windows10. I used one of my laptops using Windows 11 and installed the package and it worked. However, if I run the code independently I do get the same error.
I do not have pycryptodome nor cryptography installed , I am not sure if it was one of the dependencies. However, let me install it and I'll test out. Thanks for the quick response and the help!
from yahoofinancials.
I uploaded the development version to both my desktop and server and I no longer get any issues.
Yahoo Finance encrypted the data with EAS? Are you guys hosting the keys or are they publicly available?
Thanks again for the help.
from yahoofinancials.
@ivojfabris Its publicly available. Going to push v1.8 tonight with the changes, hopefully this resolves your issue.
from yahoofinancials.
@ivojfabris @zachpaul38 I just released v1.8, can you both confirm that this resolved the issue? I'll keep this issue open just in case.
from yahoofinancials.
@JECSand I been testing the code from development branch. All my issues have been resolved. Looking at the changes you made it made sense why the old code would break, So I believe you can close the issue, but @zachpaul38 might feel differently.
Thanks again for resolving this issue so quickly.
from yahoofinancials.
@ivojfabris Perfect and no problem at all, going to close this issue then.
from yahoofinancials.
Related Issues (20)
- KeyError: 'incomeBeforeTax
- Get the last trading hour
- get_stock_earnings_data always fails HOT 8
- .get_key_statistics_data() results in a HTTP 401 code HOT 9
- Error when running test script HOT 4
- .get_key_statistics_data() http 401 yahoofinancials version 1.19 HOT 2
- get_key_statistic_data: 401 error HOT 2
- Problem with Demo.py HOT 4
- TypeError: can only concatenate str (not "NoneType") to str HOT 2
- get_net_income() provides the Net Income of 9/29/2020 (for AAPL) HOT 1
- get_historical_price_data() end_date HOT 4
- Can't fetch anything HOT 1
- unsupported operand type(s) for -: 'datetime.datetime' and 'str' HOT 5
- sessions.py _get_crumb does not get the crumb, it's empty HOT 6
- not working - get_financial_data() HOT 4
- TypeError: 'NoneType' object is not subscriptable
- Sleeping and retrying for a long time HOT 1
- get_historical_price_data() error HOT 1
- get_summary_data() freezes the application with a delisted stock symbol
- Unable to get any examples working.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yahoofinancials.