Market Data / Historical Market Data

Historical Market Data

We are in open beta

Everything related to lemon.markets is still very much work in progress. Please bear with us that some things are still a bit buggy or functionality is missing. We are really grateful if you share your feedback on Slack as this helps make lemon.markets a product we all want to use. Thank you :)

Using our Market Data API, we allow you to conveniently retrieve Quotes, Open-High-Low-Close (OHLC) data (M1/H1/D1) as well as Trades for a specific instrument. Below, find an overview of different Market Data API use cases.

The base URL for the Market Data API is:

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

You might be interested in accessing historic market data to use it for your trading strategy or application. We offer you different endpoints that let you access the data in various formats and hopefully serve every use case.

Quotes are an important indicator for instruments of all kinds. A quote gives you information about the price and trading volume of a specific instrument (how it is "quoted" on the stock exchange) and can therefore be a helpful tool, when it comes to designing your trading strategy. While dealing with quotes and how to use them for your trading strategy, you will inevitably stumble upon the following terms, so we thought we'd give you a little bit of background information to make sure that you as a 🍋.markets user are always one step ahead.

TermExplanation
Bid PriceThe maximum price the buyer is willing to pay for a specific instrument.
Ask PriceThe minimum price the seller is willing to sell the specific instrument for.
Bid VolumeNumber of instruments sold at bid price.
Ask VolumeNumber of instruments sold at ask price.

We offer you one endpoint to retrieve quotes, which can be accessed by using the following request URL:

https://data.lemon.markets/v1/quotes/

to your request base URL.

Request

Specify your request as follows:

Header Parameters

Authorization
string
required

Set your Authorization header in the format "Authorization: Bearer YOUR-API-KEY"

Working with 'from' and 'to' in the Quotes endpoint

We are currently working hard on making the possibility to specifiy the time range you want to get the Quotes for possible. However, there are still some inconsistencies with using from and to to define your desired time range. Using these query parameters to specify your time range in most cases results in a 500 Server Error, so please try not to use it/rely on it at this stage. We are working on it :)

In general, you can specify "from" and "to" in two different ways:

  • by setting an epoch timestamp in milliseconds
  • by specifying the date in the ISO date format


Understanding the 'ISIN' and 'MIC' query parameter

Using the isin and mic query parameter, you have the option to request quotes for multiple instruments and/or from multiple Trading Venues. Depending on the client you are using, you could do so by definining multiple ISINs/MICs in the Query Parameters, like ?isin=US88160R1014&isin=US19260Q1076 or by simply using commas, like isin=US88160R1014,US19260Q1076.


Query Parameters

isin
string
required

The International Securities Identification Number of the instrument you want to get the quotes for. You can also specify multiple ISINs in the Query Parameters, like ?isin=US88160R1014&isin=US19260Q1076 or by simply using commas, like isin=US88160R1014,US19260Q1076. Maximum 10 ISINs per request.

mic
string
optional

Market Identifier Code of Trading Venue. Currently, only XMUN is supported.

from
int/string
optional

Start of Time Range for which you want to get the quotes. Use int/date-iso-string to define your timestamp range. Use from=latest to receive the latest quotes.

to
int/string
optional

End of Time Range for which you want to get the quotes. Use int/date-iso-string to define your timestamp range.

decimals
boolean
optional

The numbers format you want to get your response in, either decimals or int. Default is true.

epoch
boolean
optional

The date format you want to get your response in. Default is false. By default, the API will return ISO string dates.

sorting
string
optional

Sort your API response, either ascending (asc) or descending (desc)

limit
int
optional

Required for Pagination. Limit of displayed results on one page

page
int
optional

Required for Pagination. Results page you wish to display

Response

Response Parameters

isin
string

The International Securities Identification Number of the instrument you requested the quotes for.

b_v
int/decimal

Bid Volume for Quote

a_v
int/decimal

Ask Volume for Quote

b
int/decimal

Bid price of Quote

a
int/decimal

Ask price of Quote

t
string

Timestamp of point in time the Quote occured at

mic
string

Market Identifier Code of Trading Venue the Quote occured at

previous
string

Pagination: previous page

next
string

Pagination: next page

total
int

Pagination: total number of results

page
int

Pagination: current page

pages
int

Pagination: total number of pages

Check our Error Handling Page for specific information on error types.

Request

1import requests
2import json
3
4request = requests.get("https://data.lemon.markets/v1/quotes/?isin=isin&mic=mic&from=2021-11-01", headers={"Authorization": "Bearer YOUR-API-KEY"})
5print(request.json())
6      

Response

1{
2  'results':
3  [
4    {
5      'isin': 'US88160R1014',
6      'b_v': 87,
7      'a_v': 87,
8      'b': 921.1,
9      'a': 921.1,
10      't': '2021-10-28T08:51:03.669+00:00',
11      'mic': 'XMUN'
12    },
13    {
14      ...
15    }
16  ]
17  'previous': 'https://data.lemon.markets/v1/quotes/?isin=US88160R1014&from=2021-11-01&limit=10&page=1', 
18  'next': 'https://data.lemon.markets/v1/quotes/?isin=US88160R1014&from=2021-11-01&limit=10&page=3', 
19  'total': 999, 
20  'page': 2, 
21  'pages': 10
22}
23

We also offer an endpoint that returns historic market data in the Open High Low Close (OHLC) format - the typical candlestick charts. Even though the names are almost self-explanatory, we still want to give you some additionall information regarding OHLC data.

TypeExplanation
OpenPrice of instrument at the beginning of the respective time period.
HighHighest instrument price within the respective time period.
LowLowest instrument price within the respective time period.
ClosePrice of instrument at the end of the respective time period.

Using OHLC data for your trading strategy

OHLC data can be potentially useful for your trading strategy. For example, when the open and close prices are far apart, it shows that there is a strong volatility in the market, while open and close prices that are very close to each other indicate indecision or a weak volatility. For more information, click here.

Note that this is not investing advice, we are just presenting some common knowledge and you are still responsible for your own trading strategy ;)


Depending on what exactly you are building, there might be different needs for data granularity. For example, if you are interested in analysing price developments far back into the past, it might be sufficient for you if you get aggregated price data per day. However, if you are interested in short-time price developments, you might want to go as granular as possible.

Therefore, we offer historic OHLC data in the three following levels:

TypeDescription
m1The data is aggregated on a per-minute basis.
h1The data is aggregated on an hourly basis.
d1The data is aggregated on a daily basis.

The data is only available for timeframes in which trades have been passed

This means that if no trades were made in a specific timeframe, there may be gaps in the data returned. This is probably more relevant for M1 data, but might also occur for H1 and D1 data if you request less frequently traded instruments.


For the historic OHLC data, we offer three endpoints whose logic works in an (almost) identical way. Depending on the type of OHLC data you wish to retrieve, use the following request URLs:

https://data.lemon.markets/v1/ohlc/m1/

https://data.lemon.markets/v1/ohlc/h1/

https://data.lemon.markets/v1/ohlc/d1/

The API will then return historic M1, H1 or D1 market data.

Request

Specify your request as follows:

Path Parameters

x1
string
required

Specify the type of data you wish to retrieve: m1 (per minute), h1 (per hour), or d1 (per day).

Header Parameters

Authorization
string
required

Set your Authorization header in the format "Authorization: Bearer YOUR-API-KEY"

Working with 'from' and 'to' in the OHLC endpoint

In general, you can specify "from" and "to" in two different ways:

  • by setting an epoch timestamp in milliseconds
  • by specifying the date in the ISO date format

Understanding the 'ISIN' and 'MIC' query parameter

Using the isin and mic query parameter, you have the option to request OHLC data for multiple instruments and/or from multiple Trading Venues. Depending on the client you are using, you could do so by definining multiple ISINs/MICs in the Query Parameters, like ?isin=US88160R1014&isin=US19260Q1076 or by simply using commas, like isin=US88160R1014,US19260Q1076.

Query Parameters

isin
string
required

The International Securities Identification Number of the instrument you want to get the OHLC data for. You can also specify multiple ISINs in the Query Parameters, like ?isin=US88160R1014&isin=US19260Q1076 or by simply using commas, like isin=US88160R1014,US19260Q1076. Maximum 10 ISINs per request.

mic
string
optional

Market Identifier Code of Trading Venue. Currently, only XMUN is supported.

from
int/string
optional

Start of Time Range for which you want to get the OHLC data. Use int/date-iso-string to define your timestamp range. Use from=latest to receive the latest quote.

to
int/string
optional

End of Time Range for which you want to get the OHLC data. Use int/date-iso-string to define your timestamp range.

decimals
boolean
optional

The numbers format you want to get your response in, either decimals or int. Default is true.

epoch
boolean
optional

The date format you want to get your response in. Default is false. By default, the API will return ISO string dates.

sorting
string
optional

Sort your API response, either ascending (asc) or descending (desc)

limit
int
optional

Required for Pagination. Limit of displayed results on one page

page
int
optional

Required for Pagination. Results page you wish to display

Response

Response Parameters

isin
string

The International Securities Identification Number of the instrument you requested the OHLC data for.

o
int/decimal

Open Price in specific time period

h
int/decimal

Highest Price in specific time period

l
int/decimal

Lowest Price in specific time period

c
int/decimal

Close Price in specific time period

t
string

Timestamp of time period the OHLC data is based on

mic
string

Market Identifier Code of Trading Venue the OHLC data occured at

previous
string

Pagination: previous page

next
string

Pagination: next page

total
int

Pagination: total number of results

page
int

Pagination: current page

pages
int

Pagination: total number of pages

Check our Error Handling Page for specific information on error types.

Request

1import requests
2import json
3
4request = requests.get("https://data.lemon.markets/v1/ohlc/h1/?isin=isin&mic=mic&from=2021-11-01", headers={"Authorization": "Bearer YOUR-API-KEY"})
5print(request.json())
6      

Response

1{
2  'results':
3  [
4    {
5      'isin': 'US88160R1014',
6      'o': 619.6,
7      'h': 624.1,
8      'l': 612.6,
9      'c': 616.1,
10      't': '2021-09-02T00:00:00.000+00:00',
11      'mic': 'XMUN'
12      },
13      {
14      'isin': 'US88160R1014',
15      'o': 616.4,
16      'h': 622.6,
17      'l': 609.5,
18      'c': 617.0,
19      't': '2021-09-03T00:00:00.000+00:00',
20      'mic': 'XMUN'
21      },
22      {
23        ...
24      }
25  ]
26  'previous': 'https://data.lemon.markets/v1/ohlc/d1/?isin=US88160R1014&from=2021-11-01&limit=10&page=1', 
27  'next': 'https://data.lemon.markets/v1/ohlc/d1/?isin=US88160R1014&from=2021-11-01&limit=10&page=3', 
28  'total': 999, 
29  'page': 2, 
30  'pages': 10
31}
32

We offer an endpoint that returns trades for instruments of your choice. Use the following request URL:

https://data.lemon.markets/v1/trades/

Request

Specify your request as follows:

Header Parameters

Authorization
string
required

Set your Authorization header in the format "Authorization: Bearer YOUR-API-KEY"

Working with 'from' and 'to' in the Trades endpoint

We are currently working hard on adding the possibility to specifiy the time range you want to get the Trades for. However, there are still some inconsistencies with using from and to to define your desired time range. Using these query parameters to specify your time range in most cases results in a 500 Server Error, so please try not to use it/rely on it at this stage. We are working on it :)

In general, you can specify "from" and "to" in two different ways:

  • by setting an epoch timestamp in milliseconds
  • by specifying the date in the ISO date format

Understanding the 'ISIN' and 'MIC' query parameter

Using the isin and mic query parameter, you have the option to request quotes for multiple instruments and/or from multiple Trading Venues. Depending on the client you are using, you could do so by definining multiple ISINs/MICs in the Query Parameters, like ?isin=US88160R1014&isin=US19260Q1076 or by simply using commas, like isin=US88160R1014,US19260Q1076.

Query Parameters

isin
string
required

The International Securities Identification Number of the instrument you want to get the trades for. You can also specify multiple ISINs in the Query Parameters, like ?isin=US88160R1014&isin=US19260Q1076 or by simply using commas, like isin=US88160R1014,US19260Q1076. Maximum 10 ISINs per request.

mic
string
optional

Market Identifier Code of Trading Venue. Currently, only XMUN is supported.

from
int/string
optional

Start of Time Range for which you want to get the Trades. Use int/date-iso-string to define your timestamp range. Use from=latest to receive the latest quotes.

to
int/string
optional

End of Time Range for which you want to get the Trades. Use int/date-iso-string to define your timestamp range.

decimals
boolean
optional

The numbers format you want to get your response in, either decimals or int. Default is true.

epoch
boolean
optional

The date format you want to get your response in. Default is false. By default, the API will return ISO string dates.

sorting
string
optional

Sort your API response, either ascending (asc) or descending (desc)

limit
int
optional

Required for Pagination. Limit of displayed results on one page

page
int
optional

Required for Pagination. Results page you wish to display

Response

Response Parameters

isin
string

The International Securities Identification Number of the instrument you requested the trades for.

p
int/decimal

Price the trade happened at

v
int/decimal

Volume during trade

t
string

Timestamp of time period the trade occured at

mic
string

Market Identifier Code of Trading Venue the trade occured at

previous
string

Pagination: previous page

next
string

Pagination: next page

total
int

Pagination: total number of results

page
int

Pagination: current page

pages
int

Pagination: total number of pages

Check our Error Handling Page for specific information on error types.

Request

1import requests
2import json
3
4request = requests.get("https://data.lemon.markets/v1/trades/?isin=isin&mic=mic&from=2021-11-01", headers={"Authorization": "Bearer YOUR-API-KEY"})
5print(request.json())
6      

Response

1{
2  'results':
3  [
4    {
5      'isin': 'US19260Q1076',
6      'p': 274.0,
7      'v': 2,
8      't': '2021-10-28T09:05:14.474+00:00',
9      'mic': 'XMUN'
10      }
11  ]
12  'previous': 'https://data.lemon.markets/v1/ohlc/h1/?isin=US88160R1014&from=2021-11-01&limit=10&page=1', 
13  'next': 'https://data.lemon.markets/v1/ohlc/h1/?isin=US88160R1014&from=2021-11-01&limit=10&page=3', 
14  'total': 999, 
15  'page': 2, 
16  'pages': 10
17}
18