Subbsos
Subbsos

Reputation: 1

is there a way to list all the the tickers that Yahoo Finance supports?

I am currently building a stock trader and I am making the part where you have to enter a ticker to trade. The Database that I am using is from Yahoo Finance but I need to see if the user's input is valid. I tried putting NYSE, NASDAQ, and S&P500 all in one list but there were some that weren't there and some that weren't supported. I saw a similar post to this, but it was pretty outdated and none of the answers were helping me. I want to make a list that has all of the Yahoo Finance Tickers.

from tkinter import Tk, Label, Entry, Button
import sys
root = Tk()
root.title("Enter Ticker Symbol")
root.geometry("500x400")

message_label = Label(root, text="Enter NASDAQ ticker symbol:")
message_label.pack()
ticker_input = Entry(root)
ticker_input.pack()
ticker = None
names = open('ticker.names')
read = names.read()

def set_ticker(input):
    global ticker
    print(f"Setting ticker to {input}")
    ticker = input
    
def validate_ticker(input):
    if input in read:
        print(input)
        set_ticker(input)
        print(f"{input} is set to the ticker.")
        root.destroy()
    else:   
        set_ticker(input)     
        print(f"Error: {ticker} is not vaild in YAHOO database.")
        sys.exit(1)
    


ok_button = Button(root, text="OK", command=lambda: validate_ticker(ticker_input.get()))
ok_button.pack()

root.mainloop()

I tried using yahooquery but it only returned a few of them. I also used pandas to find S&P 500 tickers from Wikipedia.

Upvotes: 0

Views: 71

Answers (0)

Related Questions