I have been given approximate company names like Mercedes-Benz or Apple (i.e., not exact company names not exact company names like Mercedes-Benz Group AG or Apple Inc.).
Is there a way to retrieve the most likely yahoo finance ticker?
Unfortunately, the following code doesn´t work:
import yfinance as yf
company_name = "Mercedes-Benz"
def find_ticker(company_name):
search_results = yf.Ticker(company_name).info
if search_results:
return search_results['symbol']
else:
return None
You can simulate the Ajax requests the web-page is doing when user types the string to the Yahoo Finance search bar, e.g.:
Prints: