Mapping a Ticker Symbol to ISIN using OpenFIGI & lemon.markets


blog photo
Published by Joanne Snel on October 20, 2021
Insights


When you start trading on different exchanges, you’ll notice that sometimes they have unique ways of identifying financial instruments. For example, US exchanges often use tickers, whereas German exchanges reference an ISIN. And sometimes, moving between these symbologies isn’t as smooth as you’d expect. 

Using more than one source of information for trading a stock might mean that you need to build your own mapping system to line up incompatible instrument identifiers. Of course, a quick Google search can easily lead you to the appropriate identifier. But this needs to be performed manually. Instead, automate the process by writing (less than 10 lines of) code to make this ‘translation’ for you. Keep reading to learn how you can use the OpenFIGI and lemon.markets APIs to map tickers to ISINs.

What’s a ticker?

A ticker, or stock symbol, is a series of one to five alphanumeric characters (in other words, letters & numbers) that uniquely represents a financial instrument listed on an exchange. For example, you might have seen someone tweeting about ‘$TSLA‘ (also referred to as a ‘cashtag’) or read a headline referencing ‘AAPL’ — both are stock symbols (for Tesla and Apple, respectively). Very often, they’re used as a way to refer to a particular security without having to reference the name in full (that would be Tesla, Inc. and Apple Inc.) However, a different exchange might list a security under a different stock symbol, for example, the Munich Stock Exchange lists Apple as ‘APC’. 

If you are building an automated trading strategy, this might cause problems if you are collecting market data from international sources. Your trading decisions/rules might not refer to the correct instrument or, even worse, no instrument at all (if your provider does not recognise the symbol you feed it). 

Ticker to ISIN

Most European brokerage providers use the ISIN (International Securities Identification Number) as a means to uniquely identify financial instruments. lemon.markets, a start-up powering automated trading, is much the same: trades are placed by referencing an instrument’s ISIN. However, if you attempt to query for Apple Inc. by searching ‘AAPL’, the endpoint will not return the instrument you are looking for (because it’s listed as ‘APC’). To arrive at the correct ISIN, you’d need to search for the latter. So, how do we go from ‘AAPL’ to ‘APC’? And how do we find out under what ticker Tesla is listed on the Munich Stock Exchange? 

Using the OpenFIGI API to find a ticker

The OpenFIGI API can be used to map any kind of securities identification, or ‘symbology’, to a FIGI (or a Financial Instrument Global Identifier). The FIGI of a particular financial instrument is consistent across providers, making research, trading and mapping more seamless. The platform can also be used to obtain other characteristics, such as the exchange code, market sector or ticker. 

In this article, we’re interested in going from a US ticker to a German ticker. For that, we access the search endpoint, which allows us to search for FIGIs (and their corresponding tickers) using keywords and other filters. To ensure that we obtain the ticker as listed on the desired German exchange, we specify our search query, ‘TSLA’ and filter using the exchange code ‘GM’, which stands for the Munich Stock Exchange. The POST request looks as follows:

1import requests
2response = requests.post(url='https://api.openfigi.com/v3/search/',
3                        headers={'Content-Type': 'text/json'},
4                        json={
5                            'query': 'TSLA',
6                            'exchCode': 'GM'
7                        })
8print(response.json())

Note: you can only make place 5 requests per minute without an API key, signing up to OpenFIGI will increase this number to 20 requests per minute

This piece of code will return several entries, but for demonstration purposes I’ve listed only the first one, which is also the entry that we’re interested in.

1{'data': [{'compositeFIGI': 'BBG000WGWT81',
2           'exchCode': 'GM',
3           'figi': 'BBG000WGWVP7',
4           'marketSector': 'Equity',
5           'name': 'TESLA INC',
6           'securityDescription': 'TL0',
7           'securityType': 'Common Stock',
8           'securityType2': 'Common Stock',
9           'shareClassFIGI': 'BBG001SQKGD7',
10           'ticker': 'TL0'}]
11}

Despite searching for the US ticker (the ‘query’ in line 6), the OpenFIGI response returns the German ticker. That’s because we specified that we want results only corresponding to the exchange code GM. We see that the GM ticker isindeeddifferent from the US ticker as Tesla is listed as ‘TL0’ rather than ‘TSLA’. You can change this code to whichever exchange is relevant for your use-case, see a list of all exchange codes here.

Using the lemon.markets API to find an ISIN

Now, we can use the lemon.markets Instrument endpoint to obtain the ISIN that corresponds to this ticker. We do that as follows:

1request = requests.get(f"https://data.lemon.markets/v1/instruments/?search=
2                       {response.json().get('data')[0].get('ticker')}",
3                       headers={"Authorization": "Bearer YOUR-API-KEY})
4print(request.json())

Note that you need to fill in your own API key to run this code snippet.

As you can see, we are using ‘TL0’ as our search query. This returns the following JSON output:

1{'results': [{'isin': 'US88160R1014',
2              'name': 'TESLA INC. DL -,001',
3              'symbol': 'TL0',
4              'title': 'TESLA INC.',
5              'type': 'stock',
6              'venues': [{'currency': 'EUR',
7                          'is_open': False,
8                          'mic': 'XMUN',
9                          'name': 'Börse München - Gettex',
10                          'title': 'Gettex',
11                          'tradable': True}],
12              'wkn': 'A1CX3T'}]}

We can now access this ISIN (by the way, this is done like this: request.json().get('results')[0].get('isin')) to place any subsequent trades. If you’d like to place trades on lemon.markets too, join our waitlist to get experience the trading API you’ve been waiting for.

And there we have it, we have successfully mapped a US ticker to an ISIN (by means of the GM ticker). From here on out, the possibilities are endless. For example, you might want to create a trading strategy based on the sentiment expressed in tweets. Cashtags are usually US tickers, but to trade on lemon.markets, you need the ISIN or GM ticker. OpenFIGI to the rescue! Read our article on beginner-friendly trading strategies to learn how you can use lemon.markets to trade based on sentiment analysis. Or, you might quickly want to determine whether a certain Australian stock is also traded on the Munich Stock Exchange: a simple POST request to the OpenFIGI API will answer this query. Thus, when your mean reversion strategy suggests purchasing shares of WOW, you’ll know that it’s tradable on lemon.markets, albeit under the ticker symbol WWR.

What if I need something else?

In this article, we used the Munich Stock Exchange and the ISIN as the desired exchange and instrument identification form. But, using OpenFIGI (and especially accessing the FIGI) opens many possibilities. Check out the documentation to learn more.

For more articles on helpful tips surrounding automated trading, check out our blog. Send us an email at [email protected] if you have any questions or requests about what you would like to read next!

Until then,

Joanne 🍋

You might also be interested in

Understanding the lemon.markets Trading API

blog photo

lemon.markets was born out of the lack of European brokerages with a stable, reliable API. We designed our Trading API with the developer in mind, which means that its infrastructure is optimised such that you can use it to build almost any brokerage product you can imagine. Keep reading to learn more about its endpoints.

Trading terminology you need to know as a beginner

blog photo

The trading world is one known for its jargon - what’s the difference between a ‘bear’ and a ‘bull’ market, anyways? And why are financial instruments listed with two prices? If your trading journey is just getting started or you need a quick recap, keep reading to brush up on beginner trading terms. You’ll be an expert in no time!

10+ online resources for high-quality stock market news

blog photo

Staying informed of market development is crucial when it comes to making informed investment decisions. Whether you like listening to podcasts, reading news articles or interacting with like-minded individuals in an investing community, we’ve got a recommendation for you. Keep reading to find your match.

Dive Deeper

Find more resources to get started easily

Check out our documentation to find out more about our API structure, different endpoints and specific use cases.

Engage

Join lemon.markets community

Join our Slack channel to actively participate in our community, ask questions to other users and stay up to date at all times.

Contribute

Interested in building lemon.markets with us?

We are always looking for great additions to our team that help us build a brokerage infrastructure for the 21st century.

Products
Pricing
For Developers
SlackGithubBlog
© lemon.markets 2021Privacy PolicyImprint
All systems normal