This code worked fine before, finding the closing price for every ticker.
Now all tickers return "No price data found, symbol may be delisted (1d 2024-02-01 -> 2024-02-01)"
Has anyone had this issue?
No bug is present, I ran it exactly like this on the 29th and no issue
The xlsx file is just a column with brazilian tickers, nothing more.
import openpyxl
import yfinance as yf
file_path ="C:\\Users\\carol\\PycharmProjects\\EXTRATOS\\DOCS\\Fechamento_02_02.xlsx"
workbook = openpyxl.load_workbook(file_path)
sheet = workbook.active
data = '2024-01-29'
for row in range(2, sheet.max_row + 1):
ticker = sheet.cell(row=row, column=1).value
if ticker:
ticker_completo = f"{ticker}.SA"
print(ticker_completo)
ativo = yf.Ticker(ticker_completo)
historico = ativo.history(start=data, end=data)
preco_fechamento = historico['Close'].iloc[0] if not
historico.empty else 'N/A'
sheet.cell(row=row, column=2).value = preco_fechamento
workbook.save(file_path)
I simplified your code a bit and used a ticker as example:
If you use a later end date, e.g. '2024-02-01', it works and the data for the 29th January are also contained. However, I get the same error as you do if I use '2024-01-29'. I guess it might be a problem of yahoo finance. But maybe someone has another idea.