StephanAkkerman / fintwit-bot

FinTwit-Bot is a Discord bot designed to track and analyze financial markets by pulling data from platforms like Twitter, Reddit, and Binance. It features customizable tools for sentiment analysis, market trends, and portfolio tracking to help traders stay informed and make data-driven decisions.
http://akkerman.ai/fintwit-bot/
MIT License
71 stars 15 forks source link

Test ticker validity before making yfinance call #497

Closed StephanAkkerman closed 8 months ago

StephanAkkerman commented 8 months ago

The bot will now throw a warning for all tickers that are not valid:

404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/SOLANA?modules=financialData%2CquoteType%2CdefaultKeyStatistics%2CassetProfile%2CsummaryDetail&corsDomain=finance.yahoo.com&formatted=false&symbol=SOLANA&crumb=uRGGvBHN4yJ

To prevent this from happening we should first check if the ticker is valid at all for instance by using: https://api.nasdaq.com/api/screener/stocks?tableonly=true&limit=25&offset=0&download=true or https://scanner.tradingview.com/america/scan

Maybe there are other APIs for finding all the stock tickers available on yahoo finance

StephanAkkerman commented 8 months ago

Other option: https://github.com/portfolioplus/pytickersymbols (does not seem to be completely up to date)

StephanAkkerman commented 8 months ago

Or we could look for ways to suppress it 🤷

StephanAkkerman commented 8 months ago

Could maybe look into: https://github.com/dpguthrie/yahooquery for getting all tickers

StephanAkkerman commented 8 months ago

Maybe convert yfinance code into yahooquery: tickers = Ticker(sp500, asynchronous=True)

StephanAkkerman commented 8 months ago

Could also add some rules for this: like skipping it when the ticker is longer than 4 letters