Coder Social home page Coder Social logo

Comments (16)

JECSand avatar JECSand commented on June 3, 2024

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

zachpaul38 avatar zachpaul38 commented on June 3, 2024

from yahoofinancials.

JECSand avatar JECSand commented on June 3, 2024

@zachpaul38 I can try running this from anaconda as well. Are you getting this error when using 1.7 outside of anaconda?

from yahoofinancials.

ivojfabris avatar ivojfabris commented on June 3, 2024

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.

zachpaul38 avatar zachpaul38 commented on June 3, 2024

from yahoofinancials.

ivojfabris avatar ivojfabris commented on June 3, 2024

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.

zachpaul38 avatar zachpaul38 commented on June 3, 2024

from yahoofinancials.

ivojfabris avatar ivojfabris commented on June 3, 2024

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.

JECSand avatar JECSand commented on June 3, 2024

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

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

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

JECSand avatar JECSand commented on June 3, 2024

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

ivojfabris avatar ivojfabris commented on June 3, 2024

@JECSand

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.

ivojfabris avatar ivojfabris commented on June 3, 2024

@JECSand

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.

JECSand avatar JECSand commented on June 3, 2024

@ivojfabris Its publicly available. Going to push v1.8 tonight with the changes, hopefully this resolves your issue.

from yahoofinancials.

JECSand avatar JECSand commented on June 3, 2024

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

ivojfabris avatar ivojfabris commented on June 3, 2024

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

JECSand avatar JECSand commented on June 3, 2024

@ivojfabris Perfect and no problem at all, going to close this issue then.

from yahoofinancials.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.