I am trying to download a series of yesterday's Yahoo OHLC quotes for a portfolio of around 50 shares, trackers and ETFs. The share tickers work fine using the example code below, but the trackers and ETFs seem unobtainable by this method, even though I can find them manually using their Yahoo codes on the site.
import yfinance as yf
import pandas as pd
from datetime import datetime, timedelta
current_date = datetime.now()
start_date = (current_date - timedelta(1)).strftime('%Y-%m-%d')
end_date = current_date
ticker_list = ["SHEL.L","BP.L" ]
df = pd.DataFrame()
for ticker in ticker_list:
item = yf.download(ticker, start_date, end_date)
df = pd.concat([df, item])
print(df.tail())
So far, so good, but when I try to use Yahoo's own code for an index fund, such as "0P0000TKZK.L" in place of the ticker list, I get an output as below:
1 Failed download:
- 0P0000TKZK.L: No data found for this date range, symbol may be delisted Empty DataFrame Columns: [Open, High, Low, Close, Adj Close, Volume] Index: []
I am not wedded to using yfinance; any other method which works for an automatic download of both tickers and the fund codes would be ideal. Any suggestions gratefully received.