Numbers & Dates
When using the lemon.markets Trading and Market Data API, you will need to specify numbers and dates at a variety of different endpoints. This page gives you a concise overview of all things to consider when working with numbers and dates.
Trading API
In the Trading API, we offer all numbers in the Integer format only. However, we still need to distinguish between two different cases.
Integer format to specify a quantity
If you want to enter a quantity (e.g. when you place an order and want to specify how many stocks you want to buy), you can simply enter the "normal" quantity you want to buy or sell --> "quantity" = 1 will result in you buying 1 stock.
Integer format for currencies
The Integer format for all places where an amount of currency is specified works differently. In general, you need to specify the price as a hundreths of a cent.
Some Examples:
Amount | Integer Specification |
---|---|
10€ | 100000 |
100€ | 1000000 |
1,000€ | 10000000 |
10,000€ | 100000000 |
[...] | [...] |
These are the Endpoint parameters for which this format is relevant:
Endpoint | Endpoint Parameters with Integer Specification |
---|---|
Account | - balance - cash_to_invest - cash_to_withdraw - tax_allowance - amount - amount_bought_intraday - amount_sold_intraday - amount_open_orders - amount_open_withdrawals - amount_estimate_taxes |
Orders | - stop_price - limit_price - regulatory_information - estimated_price |
Positions | - buy_price_avg - estimated_price_total - estimated_price |
Market Data API
Working with Dates in the Market Data API
Setting a Date
If you use our Market Data API, you will eventually need to define a specific date or a specific time range, e.g. to get the OHLC data for your favourite stock . You can do so by specifying the from and to query parameters in the Quotes, OHLC, Prices, and Trades endpoint (see a more detailed description below at the Market Data API section.
In general, you have two options to do so.
- By specifying an epoch timestamp
- By specifying an ISO Date
Please note that you need to specify the epoch timestamp in milliseconds. So, if you wanted to define the epoch timestamp for January 1st 2022, 10:00 am, you would do that through:
from=1641027600000
If you prefer to use the ISO date format, you could specify your desired date in the format "YYYY-MM-DD", like so:
from=2022-01-01.
Additionally, you can also specifiy the ISO date format in milliseconds:
from=2021-01-01T00:01:00.000
Retrieving a Date in a specific format
You can also define the date format you want the API to return using the query parameter ?epoch, which is a Boolean value. By default, the API returns a timestamp in the ISO format (?epoch=false). To receive the timestamp in epoch format, set ?epoch=true
Working with Numbers in the Market Data API
Similarly as with the date format, you can easily specify the numbers format you want the API to return.
For that, use the Query Parameter decimals and set true if you want the API to return everything in decimals or false if you want it to return Integers. See an example for using the query parameter below.