I am trying to make an trading algorithm, and was trying to obtain tickers from stock_info from yahoo_fin.
On pandas 1.5.3, it works but on pandas 2.1.0 it gives me only dashes ['----', '-----', '-----', '-----'... so on]
# Imports
from pandas_datareader import data as pdr
from yahoo_fin import stock_info as si
from pandas import ExcelWriter
import yfinance as yf
import pandas as pd
import datetime
import time
import matplotlib.pyplot as plt
import numpy as np
import mplfinance as mpf
yf.pdr_override()
# Variables
tickers = si.tickers_sp500()
tickers = [item.replace(".", "-") for item in tickers] # Yahoo Finance uses dashes instead of dots
index_name = '^GSPC' # S&P 500
start_date = datetime.datetime.now() - datetime.timedelta(days=365)
end_date = datetime.date.today()
exportList = pd.DataFrame(columns=['Stock', "RS_Rating", "50 Day MA", "150 Day Ma", "200 Day MA", "52 Week Low", "52 week High"])
returns_multiples = []
expected: the tickers from S&P 500
what I got: just dashes
versions: yahoo-fin 0.8.9.1, pandas 2.1.0
Yahoo finance now requires an api key and this is why you get the dashes. "Yahoo will only let you make a few hundred requests per day before they catch on and realize you are using the API programmatically and not in conjunction with their web page. Yahoo will block your access you if you query the API excessively.
Yfinance as yf is a workaround but tickers_sp500() doesn't work. I'm currently trying to figure out a workaround