JECSand / yahoofinancials

A powerful financial data module used for pulling data from Yahoo Finance. This module can pull fundamental and technical data for stocks, indexes, currencies, cryptos, ETFs, Mutual Funds, U.S. Treasuries, and commodity futures.
https://pypi.python.org/pypi/yahoofinancials
MIT License
911 stars 215 forks source link

get_current_price() returning none for everything #57

Closed agastya29 closed 3 years ago

agastya29 commented 4 years ago

stock = YahooFInancials('ABB.BO') cmp = stock.get_current_price() cmp

returns None

Also happening with atleast volumes and market cap fields as well.

thelawlaw commented 4 years ago

Same here... API is returning None...

Can the creator please solve?

andres0820m commented 4 years ago

same over here

georgk10 commented 4 years ago

Same problem here. The way yahoo formats their data seems to have changed. I'm getting None for every request I make. A few days ago everything worked like a charm.

agastya29 commented 4 years ago

hi,

So I found some time to go through the source code and how Yahoo Finance pages show the data. When I wrote my own version of YahooFinanceETL, I could get the data from Yahoo Finance like before. On comparing with YahooFInanceETL code, I can clearly see the same approach- using requests & bs4 using the same markers and regex statements, broadly speaking. The change required is minor which I am so far unable to pin point, mainly due to lack of time. For the original author, it should be 5-10min job max. Hope it helps. As a temporary fix, especially if you are looking for a limited number of fields, my suggestion is to write down a simple alternate to YahooFInanceETL and let YahooFinancials class inherit from that class. It works pretty much like the original. In case someone is lost, please go through the source code of YahooFinancials and YahooFinanceETL using the module 'inspect'. Hope it helps till the problem is fixed. Good Luck.

almalh commented 4 years ago

Same problem here, hopefully it will be resolved soon

sucubitos commented 4 years ago

I have also the same problem. I can get historical data for any stock till 6th of March, since then all I get is None. Hope the info helps to solve the problem.

agastya29 commented 4 years ago

I have also the same problem. I can get historical data for any stock till 6th of March, since then all I get is None. Hope the info helps to solve the problem.

Please check again. Historical prices are working for me even now.

bohm66 commented 4 years ago

For me it is still None. When the problem started I ran my program several times and sometimes I got "None" and some times I got the stock price. Now it is only "None".

bohm66 commented 4 years ago

I have also the same problem. I can get historical data for any stock till 6th of March, since then all I get is None. Hope the info helps to solve the problem.

Please check again. Historical prices are working for me even now.

Hi, did the original start working again? For me it is still "None" in the response

georgk10 commented 4 years ago

Since this issue seems not to be solved anytime soon I migrated to using this library . It works pretty well, although it had a small bug - but this one has a solution already (which can really be fixed in less than a minute be anyone).

hrodv commented 4 years ago

All key statistics still gives None. Do the developer plan to fix this issue?

sylvandb commented 4 years ago

The issue is likely due to the client version. Fixed in my version, but there is also a slight change in API compared to this version -- mine always returns a dict as if you had requested multiple tickers.

https://github.com/sylvandb/yahoofinancials/

scorpion-inc commented 4 years ago

The issue is likely due to the client version. Fixed in my version, but there is also a slight change in API compared to this version -- mine always returns a dict as if you had requested multiple tickers.

https://github.com/sylvandb/yahoofinancials/

This worked for me. However for me the comment "yahoo issue was the client version" wasn't completely clear as to how to fix. So I thought I'd add a comment if others were in the same boat.

Line 71 needs to change from: version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'

to this: version = 'w3m/0.5.3+git20180125'

Thanks sylvandb.

bohm66 commented 4 years ago

The issue is likely due to the client version. Fixed in my version, but there is also a slight change in API compared to this version -- mine always returns a dict as if you had requested multiple tickers. https://github.com/sylvandb/yahoofinancials/

This worked for me. However for me the comment "yahoo issue was the client version" wasn't completely clear as to how to fix. So I thought I'd add a comment if others were in the same boat.

Line 71 needs to change from: version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'

to this: version = 'w3m/0.5.3+git20180125'

Thanks sylvandb.

Hi, I do not understand. Is there a need to change the library or do I need to do something with the version in my code?

Thanks, Christer

scorpion-inc commented 4 years ago

You fix one line in your code.

Find the yahoofinancials package on your system, (mine is in the site-packages area of my python installation) then make the change in the file named init.py, which should be the only file in the yahoofinancials directory.

Alternatively you could install sylvandb's fork of this codebase (follow his link above). For me, it was easier to fix the one line.

scorpion-inc commented 4 years ago

Sorry, the comment system took off the underscores in the filename, I guess they are special characters. The file you modify is named __init__.py

bohm66 commented 4 years ago

Sorry, the comment system took off the underscores in the filename, I guess they are special characters. The file you modify is named __init__.py

.. and just by magic it starts to work!

Thanks, Christer

opbankolia-TA commented 4 years ago

The issue is likely due to the client version. Fixed in my version, but there is also a slight change in API compared to this version -- mine always returns a dict as if you had requested multiple tickers. https://github.com/sylvandb/yahoofinancials/

This worked for me. However for me the comment "yahoo issue was the client version" wasn't completely clear as to how to fix. So I thought I'd add a comment if others were in the same boat.

Line 71 needs to change from: version = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; it; rv:1.8.1.11) Gecko/20071127 Firefox/2.0.0.11'

to this: version = 'w3m/0.5.3+git20180125'

Thanks sylvandb.

worked for me. thanks.