Exploring the lemon.markets instruments endpoint


13. Januar 2022
Trading


At lemon.markets, we’re empowering developers to take brokerage into their own hands by building Europe’s first trading API. In today’s article, we want to showcase one of the useful endpoints we provide: /instruments. It can be used to identify the various financial instruments that can be traded on lemon.markets, such as stocks and ETFs. 

Title Card for "Exploring the lemon.markets instruments endpoint"

The lemon.markets API currently offers 8250+ popular stocks and ETFs — we’ve got (most 😉) big-name instruments. Not sure if we carry a particular listing? You can easily use the /instruments endpoint to search for specific financial instruments. Want to see how it’s done? Let’s jump right in.

Why search for my financial instrument? 🔎

If you already know the name of the financial instrument you wish to trade, why should you use the /instruments endpoint? Our API identifies financial instruments through an ISIN (International Securities Identification Number). If you know the ISIN of the instrument you wish to trade, you’re ready to place your order! But, if you don’t, you can use this endpoint to find the ISIN associated with that instrument.

Besides the ISIN, the /instruments endpoint also provides information about:

  • the exchange the instrument is listed on,
  • the symbol, WKN and title associated with the instrument, 
  • the type of instrument you’re dealing with (stock/ETF/etc.),
  • in which currency the instrument is traded and
  • whether it’s currently tradable.

This information allows you to double-check that you’re referring to the correct instrument, on the correct exchange, in the correct currency. Additionally, only placing orders if the instrument is currently tradable (and the exchange on which it’s traded is open), will ensure that you have no surprise unexecuted orders. 

Getting started

The easiest way to communicate with the lemon.markets API is to make use of the lemon.markets Python SDK, which can easily be installed through:

1pip install lemon

The initial step for using the SDK (and subsequently making requests to the API) is to instantiate a client, like this:

1def __init__(self):
2        self.client = api.create(
3            market_data_api_token=os.getenv("DATA_API_KEY"),
4            trading_api_token=os.getenv("TRADING_API_KEY"),
5            env="paper"
6    )

Note that in line 3 and 4 we are accessing environment variables, which you need to create and define before that step, typically in a .env file. Here, we are using separate API Keys for market data and trading, as required by the lemon.markets API. You can create your Trading and Market Data API Keys in theDashboard.

The /instruments endpoint🎺

To access the /instruments endpoint, you’ll need to use the following URL:

1https://data.lemon.markets/v1/instruments/

In Python, a GET request using the lemon.markets Python SDK looks as follows (note: we have sample code snippets in JavaScript in our docs):

1response = client.market_data.instruments.get()

Without any search specifications, this endpoint will return all of the instruments that can be traded with the lemon.markets API (only a very short portion of the response is listed). Perhaps this is useful if you’re simply browsing what we have on offer. But, what if you’re looking for something specific?

Specifying your search ➡️

Imagine you’re looking for the ISIN that belongs to Coinbase. How do we alter the search? There’s a number of query parameters that can be added to the end of the URL. These are:

  • search, search query for a name, title, ISIN, WKN or symbol (note: your query must be longer than 4 characters),
  • isin, if you know the ISIN of the instrument you’re looking for (you can specify up to 10 different ISINs if you’re looking for more than one),
  • mic, the Market Identifier Code of the exchange you wish to trade on, 
  • currency, ISO currency code for the currency in which you’d like to trade and
  • tradable, a boolean value to filter for tradable and non-tradable instruments.

Besides that, if your API result contains several entries, you can paginate through the response using the pagination parameters limit and page. If you’d like to learn more, you can find the details here

In our case, we’re interested in specifying search because we know the title of the instrument we’re looking for. And let’s specify tradable because we only wish to return instruments that can be traded. This means the request looks as follows:

1response = client.market_data.instruments.get(
2    search='tesla',
3    tradable=True,
4)

The API outputs the following response:

1{
2    "results": [
3        {
4            "isin": "US19260Q1076",
5            "wkn": "A2QP7J",
6            "name": "COINBASE GLB.CL.A -,00001",
7            "title": "COINBASE GLOBAL INC.",
8            "symbol": "1QZ",
9            "type": "stock",
10            "venues": [
11                {
12                    "name": "Börse München - Gettex",
13                    "title": "Gettex",
14                    "mic": "XMUN",
15                    "is_open": true,
16                    "tradable": true,
17                    "currency": "EUR"
18                }
19            ]
20        }
21    ],
22    "previous": null,
23    "next": null,
24    "total": 1,
25    "page": 1,
26    "pages": 1
27}

Note that the results list now only contains one instrument because we specified our query with enough detail to narrow down the search. We can now use this ISIN to place trades with the Trading API

That’s all there is to know about the /instruments endpoint! We hope it was helpful in exploring what can be done with lemon.markets. If you’re not yet signed-up, join us today! 

Joanne from 🍋.markets

Das könnte Dich auch interessieren

blog photo

Using Time Series Forecasting to predict stock prices 🔮

In this article you will learn what time series forecasting is and how its application in finance looks like. Then you'll also dive into Facebook's Prophet Model for Time Series Forecasting and use it together with the lemon.markets Market Data API to forecast the development of the Tesla Stock.

blog photo

Dummies Guide to Trading with Machine Learning

Ever wonder how a trader with decades of experience on thousands of stocks and lightning fast reaction times might perform in the market? With some machine learning knowledge, you might be able to automate such a trader yourself! 💻 📈

blog photo

4 reasons why YOU should automate your trading strategy

In the current volatile market conditions, everyone is trying to find ways to minimise portfolio loss. In that context, have you ever thought about automating your trading strategy? In this article, we will dive into 4 reasons for doing so. Expect to learn how it can save you time, make your trading more efficient and lead to data-based decisions.

Tiefer eintauchen

Finde weitere Ressourcen für einen einfachen Einstieg

In unserer Dokumentation erfahrt Ihr mehr über unsere API-Struktur, die verschiedenen Endpunkte und spezifische Anwendungsfälle.

Austauschen

Tritt der lemon.markets Community bei

Tritt unserem Slack-Channel bei, um Dich aktiv an unserer Community zu beteiligen, Fragen an andere Nutzer:innen zu stellen und immer auf dem Laufenden zu bleiben.

Team unterstützen

Lust lemon.markets mit uns zu bauen?

Wir sind immer auf der Suche nach großartigen Ergänzungen für unser Team, die uns beim Aufbau einer Brokerage Infrastruktur für das 21. Jahrhundert helfen.

Brauchst Du Hilfe?
Stell Deine Fragen in unserer CommunityStell Deine Fragen in unserer CommunityLeg mit unserer API Dokumentation losLeg mit unserer API Dokumentation losLass Dich von unserem Blog inspirierenLass Dich von unserem Blog inspirieren
© lemon.markets 2022DatenschutzImpressum
Systems are down

Als vertraglich gebundener Vermittler gemäß § 3 Abs. 2 WpIG für Rechnung und unter der Haftung der DonauCapital Wertpapier GmbH, Passauer Str. 5, 94161 Ruderting (kurz: DonauCapital), bietet Dir die lemon.markets GmbH, die Anlagevermittlung (§ 2 Abs. 2 Nr. 3 WpIG) von Finanzinstrumenten im Sinne des § 3 Abs. 5 WpIG sowie die Vermittlung von Konten an.