You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
have an excel list of tickers which I'm running through yfinance to get fundamental analysis data. I get 2 errors:
"keyError" exception because some data like 'forwardPE' is not available for a given symbol
"404 Client Error: Not Found for url:" when opening the URL I get "Invalid Crumb"
I tried to catch the 404 in the first loop and keyError in the 2nd loop... the 404 catch isn't working.
Simple code that reproduces your problem
import requests
import time
import yfinance as yf
import pandas as pd
the_list_include = []
################################################### OPEN THE EXCEL FILE AND COLLECT THE SYMBOLS
df = pd.read_excel('company_list_404.xlsx')
symbols = df['Symbol'].values.tolist()
for count, symbol in enumerate(symbols):
try:
stock = yf.Ticker(symbol)
the_list_include.append(symbol)
except requests.exceptions.HTTPError:
continue
for i in the_list_include:
try:
stock = yf.Ticker(i)
PE = stock.info['forwardPE']
except KeyError:
print("\n")
continue
Describe bug
have an excel list of tickers which I'm running through yfinance to get fundamental analysis data. I get 2 errors:
"keyError" exception because some data like 'forwardPE' is not available for a given symbol
"404 Client Error: Not Found for url:" when opening the URL I get "Invalid Crumb"
I tried to catch the 404 in the first loop and keyError in the 2nd loop... the 404 catch isn't working.
Simple code that reproduces your problem
import requests
import time
import yfinance as yf
import pandas as pd
the_list_include = []
################################################### OPEN THE EXCEL FILE AND COLLECT THE SYMBOLS
df = pd.read_excel('company_list_404.xlsx')
symbols = df['Symbol'].values.tolist()
for count, symbol in enumerate(symbols):
try:
stock = yf.Ticker(symbol)
the_list_include.append(symbol)
except requests.exceptions.HTTPError:
continue
for i in the_list_include:
try:
stock = yf.Ticker(i)
PE = stock.info['forwardPE']
except KeyError:
print("\n")
continue
Debug log
404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/ABC?modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&corsDomain=finance.yahoo.com&formatted=false&symbol=ABC&crumb=74gwrZgqcIA
Bad data proof
No response
yfinance
versionyfinance 0.2.38
Python version
Python 3.11.9
Operating system
Windows 11 Home
The text was updated successfully, but these errors were encountered: