# Using ISIN to identify stock at yahoo finance

I'm collecting stock data for private analysis. I found a very excessive list of stock at https://www.xetra.com/xetra-de/instrumente/alle-handelbaren-instrumente/boersefrankfurt

but the problem is that they are uniquely identified by their ISIN, as it's at my location, Germany, rather common. But when requesting the data from yahoo finance their ticker symbol is needed to build the URL, however when you enter the ISIN in their search field you get the correct output without any struggle.

As of right now im using the url to request the site by html and parse it to get the information.

## I'm looking for suggestions to either

• build a url with an ISIN for yahoofinance(or an equally fast provider)
• map the ISIN to the relevant ticker symbol
• any other method to retrieve data from yahoofinance e.g. open-source libs
• other sources of live trading information, most importantly present prices

Thanks

Using their search endpoint seams to work ok.

def get_symbol_for_isin(isin):
url = 'https://query1.finance.yahoo.com/v1/finance/search'

'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.109 Safari/537.36',
}

params = dict(
q=isin,
quotesCount=1,
newsCount=0,
listsCount=0,
quotesQueryId='tss_match_phrase_query'
)

data = resp.json()
if 'quotes' in data and len(data['quotes']) > 0:
return data['quotes'][0]['symbol']
else:
return None
$$$$


Just use the symbol (in the CSV files, this is in the "Mnemonic" column) and attach an .F suffix for Frankfurt Boerse.

Note: Since scraping the API is expensive (although quotes can be retrieved in large batches of up to 500 symbols), you typically want to restrict the lookups to the symbols which you can trade with your broker, thereby making sure you only fetch data for the symbols you can actually trade. (In my original scraper I neglected that and later realized I'm fetching loads of symbols I cannot trade.)

let's work through an example.

Daimler equity has isin DE0007100000

Going to https://bsym.bloomberg.com/ , we find German ticker symbol DAI. (there is also an API, I believe free)

We can find on Yahoo Finance https://finance.yahoo.com/quote/DAI.DE

In Python, assuming you are interested in common stock, I'd do the following:

A) Create a data frame from the CSV:

xetra_df = pd.read_csv("t7-xfra-BF-allTradableInstruments.csv", sep=";", skiprows=2, low_memory=False)


B) Parse all common stock symbols useable for Yahoo Finance (alternatively, append .F instead of .DE):

xetra_symbols = [str(x) + '.DE' for x in list(xetra_df.loc[xetra_df['Instrument Type'] == 'CS']['Mnemonic'])]
`