dpguthrie / yahooquery

Python wrapper for an unofficial Yahoo Finance API
https://yahooquery.dpguthrie.com
MIT License
780 stars 137 forks source link

Since about 8pm UTC yesterday, it started only returning 404 Errors #192

Open james-stevens opened 1 year ago

james-stevens commented 1 year ago

Describe the bug Ticker("TSLA").quotes returns HTTP 404 Not Found

To Reproduce

#! /usr/bin/python3

import json
from yahooquery import Ticker

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

OUTPUT: HTTP 404 Not Found

Expected behavior Should return ticker data

Server (please complete the following information):

Additional context Service was working fine for a couple of months until about 8pm UTC 23rd May (yesterday)

chfiii commented 1 year ago

I'm seeing this too. It appears to be random. Runs for a while and then gets the 404 error. My current workaround is to put it in a retry loop but this shouldn't be needed.

Server: Windows 11 Python 3.9.16 yahooquery: 2.2.15 - Anaconda3

james-stevens commented 1 year ago

Interesting, I've had no success, since it started failing

alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"
alpine:~/python/yf$ ./yq.py
"HTTP 404 Not Found"

yq.py is the test script, as above

maread99 commented 1 year ago

Looks the same as #178.

Last time the url can back online around 24hrs later...

james-stevens commented 1 year ago

Looks the same as #178.

Last time the url can back online around 24hrs later...

reading that, the URL changed & the code was updated - I guess wait & see :)

https://github.com/maread99/market_prices/pull/155

chfiii commented 1 year ago

Seems random to me. I’m passing a list of ~140 stock and index symbols and then using the ‘quotes’ entry. I seem to be ok by doing:

ok = False

numRetries = 5

for i in range(numRetries):

    tic = Ticker(val,timeout=5)

    qts = tic.quotes

    if not isinstance(qts,dict):

        print(f'ERROR: qts is not a dict\n{qts=}')

        print('Retrying {i}')

        continue

    else:

        ok = True

        break

Hope this helps!

Charlie

From: James Stevens @.> Sent: Wednesday, May 24, 2023 11:04 AM To: dpguthrie/yahooquery @.> Cc: chfiii @.>; Comment @.> Subject: Re: [dpguthrie/yahooquery] Since about 8pm UTC yesterday, it stopped working (Issue #192)

Interesting, I've had no success, since it started failing

— Reply to this email directly, view it on GitHub https://github.com/dpguthrie/yahooquery/issues/192#issuecomment-1561331128 , or unsubscribe https://github.com/notifications/unsubscribe-auth/ACX2GP5KGW5AOXISASDOT3TXHYPOZANCNFSM6AAAAAAYNHDPGE . You are receiving this because you commented.Message ID: @.***>

james-stevens commented 1 year ago
#! /usr/bin/python3

import json

from yahooquery import Ticker

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

tickers = Ticker(["AAPL","TSLA"])
print(json.dumps(tickers.quotes,indent=3))

I get 404 every time (UK)

chfiii commented 1 year ago

Strange. Your test runs fine for me. I'm only seeing the 404 sporadically and the retry gets it.

james-stevens commented 1 year ago

Last time it happened it did appear to be a regional thing

chfiii commented 1 year ago

FYI I'm in Connecticut, USA

pfuller88 commented 1 year ago

I'm just getting the 404 error as well. From Canada. Also seems random.

james-stevens commented 1 year ago

I'm just getting the 404 error as well. From Canada. Also seems random.

I'm still getting nothing but 404s here in the UK - so looks like its not going to cure itself in 24 hrs

pfuller88 commented 1 year ago

I noticed it seems to just be the "tickers.quotes" request that is returning a 404 error. The other modules I'm using are still working, i.e. ticker.price, history, option chain, etc.

james-stevens commented 1 year ago

I noticed it seems to just be the "tickers.quotes" request that is returning a 404 error. The other modules I'm using are still working, i.e. ticker.price, history, option chain, etc.

Well spotted, nice one! - same for me - gonna need to tweak my code now :)

chfiii commented 1 year ago

Me too!! Thanks for the heads up!

james-stevens commented 1 year ago

Thank you so much - I got my code working again now - price has everything I need.

Super pleased cos I was missing seeing my $NVDA investment taking off !!!

As far as I concerned this can be closed, but quotes still doesn't work for me - so its up to you @dpguthrie

chfiii commented 1 year ago

It seems that the price module is taking a lot longer that the quotes one. I was averaging about 1.2 seconds for 136 quotes and now its taking ~10 seconds. Anyone else seeing this?

chfiii commented 1 year ago

Price works ok for me but missing the day's and 52 week ranges

james-stevens commented 1 year ago

It seems that the price module is taking a lot longer that the quotes one. I was averaging about 1.2 seconds for 136 quotes and now its taking ~10 seconds. Anyone else seeing this?

I only do a small number - about 27, so it works fine for me - I also update the prices in the background 4 times an hour, so 1s or 10s is really neither here nor there to me

chfiii commented 1 year ago

I tend to update around every 90 seconds so I'm still ok but disappointed in the slowdown, especially it seem to be a subset of the quotes output.

CraigerBrau commented 1 year ago

quotes is not working for me in Arizona, either. I concur with every comment except there's no randomness. It fails 100% of the time. I don't find price to be a suitable replacement because of missing values and slowness.

chfiii commented 1 year ago

Agree that the randomness has gone away. It’s dead all the time now. Missing the 52 week high/low, just returning a ‘N/A’ for now. And the price module is 7-10 times slower

caliskanuzay commented 1 year ago

Hi everyone, I also get 404 error from "tickers.quotes" request since 25 May from Turkey. There are important KPIs in quotes that are not available elsewhere, like "bookValue" and "priceToBook". Since I am a beginner, do you have any idea if and when this would be fixed? Thanks!

james-stevens commented 1 year ago

For me, I get a list of 27 via price in about 0.85s - I can't recall how long it took under quotes, but seems about the same to me

I pull the list of tickers from a database & pass the entire list to Ticker in one go.

def get_prices(ticker):
    try:
        tickers = Ticker(ticker)
        return tickers.price
    except Exception as exc:
        print(f"ERROR: {exc}")
    return None

cnx.query("select ticker from tickers")
res = cnx.store_result()
ret = res.fetch_row(maxrows=0, how=1)

tick_list = [ t["ticker"].upper() for t in ret ]
tickers = get_prices(tick_list)

(this is not posted for you to critique my Python :rofl: )

chfiii commented 1 year ago

FYI: One thing I noticed when I switched from quotes to price is that the change% needs to be multiplied by 100 to get the true change percentage.

pfuller88 commented 1 year ago

For those looking for other variabale, the data.summary_detail and the data.key_stats are also still working. Here is a sample of the output fields for each..... Summary Detail... fields: algorithm,ask,askSize,averageDailyVolume10Day,averageVolume,averageVolume10days,beta,bid,bidSize,coinMarketCapLink,currency,dayHigh,dayLow,dividendRate,dividendYield,exDividendDate,fiftyDayAverage,fiftyTwoWeekHigh,fiftyTwoWeekLow,fiveYearAvgDividendYield,forwardPE,fromCurrency,lastMarket,marketCap,maxAge,open,payoutRatio,previousClose,priceHint,priceToSalesTrailing12Months,regularMarketDayHigh,regularMarketDayLow,regularMarketOpen,regularMarketPreviousClose,regularMarketVolume,toCurrency,tradeable,trailingAnnualDividendRate,trailingAnnualDividendYield,trailingPE,twoHundredDayAverage,volume Key Stats: Fields: 52WeekChange,beta,bookValue,category,dateShortInterest,earningsQuarterlyGrowth,enterpriseToRevenue,enterpriseValue,floatShares,forwardEps,forwardPE,fundFamily,heldPercentInsiders,heldPercentInstitutions,impliedSharesOutstanding,lastDividendDate,lastDividendValue,lastFiscalYearEnd,lastSplitDate,lastSplitFactor,legalType,maxAge,mostRecentQuarter,netIncomeToCommon,nextFiscalYearEnd,pegRatio,priceHint,priceToBook,profitMargins,SandP52WeekChange,sharesOutstanding,sharesPercentSharesOut,sharesShort,sharesShortPreviousMonthDate,sharesShortPriorMonth,shortPercentOfFloat,shortRatio,trailingEps

chfiii commented 1 year ago

Thanks. This does help as I wanted fiftyTwoWeekHigh./Low. Didn't want to use the history,'1y'' as way too much data

caliskanuzay commented 1 year ago

Dear @pfuller88,thank you very much!!!! This helps a lot because I did not know about .keystats:)) You saved me hours and hours as some of the kPIs like priceToBook, sharesOutstanding and many useful stuff disappeared in .quotes.

charlie-delta-003 commented 1 year ago

In my case, accessed from Qatar. all_financial_data(frequency='a') still working fine, but all_financial_data(frequency='q') got 'HTTP 404 Not Found.' error.

kajdo commented 1 year ago

I noticed it seems to just be the "tickers.quotes" request that is returning a 404 error. The other modules I'm using are still working, i.e. ticker.price, history, option chain, etc.

thx for that .... still unfortunate that quotes isn't reliable, but prize will do the trick for me

Marcel2059 commented 1 year ago

While the link blow is not the exact link use in the code but from the comments it seem yahoo quotes api has been disabled. See sub link. https://query2.finance.yahoo.com/v7/finance/quote .

benhowell commented 1 year ago

Looks the same as #178.

Last time the url can back online around 24hrs later...

This is indeed the same issue. I've been able to find everything via ticker.summary_detail, ticker.asset_profile and options: https://query1.finance.yahoo.com/v7/finance/options/{symbol} e.g. https://query1.finance.yahoo.com/v7/finance/options/NHC.AX

dpguthrie commented 1 year ago

There's a potential fix to this issue here.

charlie-delta-003 commented 8 months ago

Any solution for this issue? I still receive error: {'error': 'HTTP 404 Not Found. Please try again'} for single modules: summary_detail, summary_profile, earning etc