Error Handling

Error Handling

This page is concerned with providing you with specific information on error handling. In general, an error will be returned in the following format:

{
   'time': '2001-02-03T04:05:06.789+00:00', 
   'mode': 'paper', 
   'status': 'error', 
   'error_code': 'order_total_price_limit_exceeded', 
   'error_message': 'cannot place/activate buy order if estimated total price is greater than 25k Euro'
}

Global Errors

These are global errors that can occur on both the Trading and the Market Data API

Error CodeDescription
unauthorizedThe API key is not provided in the HTTP header, cannot be decoded by the backend, or the API Key does not exist.
token_invalidThe API key is revoked or user is deleted/suspended.
rate_limit_exceededThe API key has exceeded its rate limit. Please respect the value of the Retry-After header before performing another request.
[xxx]_not_foundThe required entity does not exist.
internal_errorAn error occurred in the backend. This is not your fault. We will investigate this.

Trading API

These are all error codes that can occur while using the Trading API

Idempotency

When specifying an idempotency key in the request body, the following error code can be thrown (when the same idempotency key is used twice within a 7 day period)

Error CodeDescription
order_idempotency_violationSame idempotency has been used within current 7 day period

Account Endpoint

Error Handling for the request URLs:

https://paper-trading.lemon.markets/v1/account

https://trading.lemon.markets/v1/account

Error CodeDescription
pin_missingCannot withdraw money because the PIN is not provided in the request (money only)
pin_not_setCannot withdraw money because the PIN is not set (money only)
pin_invalidCannot withdraw money because the pin verification failed
withdraw_insufficient_fundsCannot withdraw money because there are insufficient funds on the account
withdraw_limit_exceededCannot withdraw money because the daily payout limit is exceeded
withdraw_request_limit_exceededCannot withdraw money because the maximal daily request limit is exceeded
forbidden_in_current_stateCannot update address_country when trading is enabled or user is onboarded
plan_not_allowedCannot update trading plan to basic/pro

Order Endpoint

Error Handling for the request URLs:

https://paper-trading.lemon.markets/v1/orders

https://trading.lemon.markets/v1/orders

Error CodeDescription
insufficient_holdingsinsufficient instrument holdings [on order sell]
order_expiration_date_invalidcannot place order if one expires before market opens again
order_total_price_limit_exceededcannot place/activate buy order if estimated total price is greater than 25k Euro
forbidden_for_venuecannot place order in ALLDAY for MONEY env
trading_disabledcannot place order if trading is not enabled
order_limit_exceededmaximum daily amount of orders reached
instrument_not_tradablefailed to place order if instrument is not tradable
account_insufficient_fundscannot place/activate buy order because of insufficient account funds
trading_blockedcannot place/activate order because trading is blocked globally
pin_invalidcannot activate order because pin validation failed
order_not_inactivecannot activate order if its status != inactive
order_not_terminatedcannot delete order if its not in cancelling/cancelled/expired/executed/rejected state

Market Data API

Trading Venues Endpoint

Error handling for the request URL:

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

Error CodeDescription
invalid_queryInvalid MIC, max 5 char.

Instruments Endpoint

Error handling for the request URL:

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

Error CodeDescription
invalid_queryInvalid mic, max 5 char.
invalid_queryInvalid ISIN value
invalid_queryExceeded number of ISINs (more than 10)
invalid_queryInvalid type value (not stock, bond, warrant, fund or etf).
invalid_querySearch string too long, max 25char.

Quotes, OHLC, and Trades Endpoints

Error handling for the request URLs:

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

https://data.lemon.markets/v1/ohlc/{x1}

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

Error CodeDescription
invalid_queryInvalid MIC, max 5 char.
invalid_queryInvalid ISIN value
invalid_queryExceeded number of ISINs (more than 10)
invalid_queryInvalid from: not a valid date.
invalid_queryInvalid to: not a valid date.
invalid_queryInvalid from: the date is later than to.
invalid_queryInvalid from/to: specified dates are not valid. Maximun 7 days..