Trading / Spaces

Spaces

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 :)

Spaces are an important concept for using lemon.markets. It is crucial to understand what a space is and how it relates to your overall account. If you have not quite grasped the concept of spaces yet, check out the Spaces page for an in-depth overview.

Once you've worked with the lemon.markets API for a little bit, you might have created a decent amount of spaces, as there are so many things you want to try out. To keep an overview, there are a number of endpoints with which you can get information about your spaces conveniently.

If you want to get a list of all your spaces, use the following request URLs:

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

to get your Paper Money Spaces, and

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

to get your Real Money Spaces.

Request

Specify your request as follows:

Header Parameters

Authorization
string
required

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

Query Parameters

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

time
string

Timestamp of your API request

status
string

API returns "ok" when spaces were successfully retrieved

mode
string

Environment the request was placed in: "paper" or "money"

name
string

Name of the Space

description
string

Description of the Space

risk_limit
int

Risk Limit assigned to the Space. The Risk Limit defines the maximum amount of money you can spend for trades executed in that space.

linked
string

potential linked Paper or Real Money Space

id
string

Identification Number to uniquely identify your Space

buying_power
int

The Buying Power is the amount of money in that Space that you have available to place new Orders. It is calculated through Risk Limit - Backfire - pending Orders

earnings
int

The Earnings tell you how much your current profit in that Space is

backfire
int

Backfire is an aggregated number that tells you about your combined Expenses and Losses

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

Request

1import requests
2import json
3
4request = requests.get("https://paper-trading.lemon.markets/v1/spaces/?type=manual", headers={"Authorization": "Bearer YOUR-API-KEY"})
5print(request.json())
6      

Response

1{
2  "time": "2021-11-22T15:43:35.084+00:00",
3  "status": "ok",
4  "mode":"paper",
5  "results": [
6    {
7      "name": "MyPersonalSpace",
8      "description": "In this Space, I only trade stocks",
9      "risk_limit": 100000000,
10      "linked": "string",
11      "created_at": "2021-11-15T13:24:05.201+00:00",
12      "id": "sp_pyJHBffGGDyV4m8rxtJ7BnfGwKLNk3bnBy",
13      "buying_power": 97035000,
14      "earnings": 0,
15      "backfire": 2965000
16    }, 
17    {
18      ...
19    }
20  ]
21  'previous': 'https://data.lemon.markets/v1/spaces/?limit=1&page=2',
22  'next': 'https://data.lemon.markets/v1/spaces/?limit=1&page=4',
23  'total': 9, 
24  'page': 3, 
25  'pages': 9
26}

You can also retrieve a single space through its ID. To do so, use the following request URLs:

https://paper-trading.lemon.markets/v1/spaces/{space_id}/

to get a specific Paper Money Space, and

https://trading.lemon.markets/v1/spaces/{space_id}/

to get a specific Real Money Space.

Request

Specify your request as follows:

Path Parameters

space_id
string
required

Enter a space ID to retrieve a specific Space

Header Parameters

Authorization
string
required

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

Response

Response Parameters

time
string

Timestamp of your API request

status
string

API returns "ok" when spaces were successfully retrieved

mode
string

Environment the request was placed in: "paper" or "money"

name
string

Name of the Space

description
string

Description of the Space

risk_limit
int

Risk Limit assigned to the Space. The Risk Limit defines the maximum amount of money you can spend for trades executed in that space.

linked
string

potential linked Paper or Real Money Space

id
string

Identification Number to uniquely identify your Space

buying_power
int

The Buying Power is the amount of money in that Space that you have available to place new Orders. It is calculated through Risk Limit - Backfire - pending Orders

earnings
int

The Earnings tell you how much your current profit in that Space is

backfire
int

Backfire is an aggregated number that tells you about your combined Expenses and Losses

Request

1import requests
2import json
3
4request = requests.get("https://paper-trading.lemon.markets/v1/spaces/{space_id}/", headers={"Authorization": "Bearer YOUR-API-KEY"})
5print(request.json())
6      

Response

1{
2  "time": "2021-11-22T15:43:35.084+00:00",
3  "status": "ok",
4  "mode":"paper",
5  "results": {
6    "name": "MyPersonalSpace",
7    "description": "In this Space, I only trade stocks",
8    "risk_limit": 100000000,
9    "linked": "string",
10    "created_at": "2021-11-15T13:24:05.201+00:00",
11    "id": "sp_pyJHBffGGDyV4m8rxtJ7BnfGwKLNk3bnBy",
12    "buying_power": 97035000,
13    "earnings": 0,
14    "backfire": 2965000
15  }
16}

If you want to create a new space, you can either go to the Dashboard or you can use the API by making a POST request against the /spaces/ endpoint.

10 Spaces per environment

You can create 10 Spaces per environment (10 for Paper Money and 10 for Real Money). You have the option to delete a Space to make space for a new one.

To create a new Space, send a POST request against the following request URL:

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

Creating a Real Money Space

To create a Real Money Space, you at first need to upgrade to real money trading.


Request

Specify your request as follows:

Header Parameters

Authorization
string
required

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

Request Body

You can send your request using the following content-types:

  • application/json
  • application/x-www-form-urlencoded

Request Body Parameters

name
string
required

Give your new Space a name

risk_limit
string
required

Risk limit of your new Space. The Risk Limit defines the maximum amount of money you can spend for trades executed in that space.

description
string
optional

Description of the new Space

Response

Response Parameters

time
string

Timestamp of your API request

status
string

API returns "ok" when spaces were successfully retrieved

mode
string

Environment the request was placed in: "paper" or "money"

name
string

Name of the Space

description
string

Description of the Space

risk_limit
int

Risk Limit assigned to the Space. The Risk Limit defines the maximum amount of money you can spend for trades executed in that space.

linked
string

potential linked Paper or Real Money Space

id
string

Identification Number to uniquely identify your Space

buying_power
int

The Buying Power is the amount of money in that Space that you have available to place new Orders. It is calculated through Risk Limit - Backfire - pending Orders

earnings
int

The Earnings tell you how much your current profit in that Space is

backfire
int

Backfire is an aggregated number that tells you about your combined Expenses and Losses

Request

1import requests
2import json
3
4request = requests.post("https://paper-trading.lemon.markets/v1/spaces/",
5          data=json.dumps({
6              "name": "MyNewSpace",
7              "risk_limit": 10000000,
8              "description": "I am trying out my new strategy",
9            }), headers={"Authorization": "Bearer YOUR-API-KEY"})
10print(request.json())
11      

Response

1{
2  "time": "2021-11-22T15:43:35.084+00:00",
3  "status": "ok",
4  "mode":"paper",
5  "results": {
6    "name": "MyNewSpace",
7    "description": "I am trying out my new strategy",
8    "risk_limit": 10000000,
9    "linked": None,
10    "id": "sp_pyJHLNBHHfny5n8c76F747bB4d3ycQw2HB",
11    "buying_power": 10000000,
12    "earnings": 0,
13    "backfire": 10000000
14  }
15}

You can alter/update your space after you created it. This may be relevant if you, e.g. want to in- or decrease the risk limit or update the space description.

With this endpoint you can change (some of) the attributes of an existing Space. To do so, create a PUT request against the following request URLs:

https://paper-trading.lemon.markets/v1/spaces/{space_id}/

to alter a Paper Money Space, and:

https://trading.lemon.markets/v1/spaces/{space_id}/

to alter a Real Money Space.

Request

Specify your request as follows:

Path Parameters

space_id
string
required

ID of Space you wish to alter

Header Parameters

Authorization
string
required

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

Request Body

You can send your request using the following content-types:

  • application/json
  • application/x-www-form-urlencoded

Request Body Parameters

name
string
optional

New name for your Space

description
string
optional

New description for your Space

risk_limit
int
optional

New Risk Limit for your Space. The Risk Limit defines the maximum amount of money you can spend for trades executed in that space.

linked
string
optional

Real Money Spaces only: new potential linked Paper Money Space

Response

Response Parameters

time
string

Timestamp of your API request

status
string

API returns "ok" when spaces were successfully retrieved

mode
string

Environment the request was placed in: "paper" or "money"

name
string

Name of the Space

description
string

Description of the Space

risk_limit
int

Risk Limit assigned to the Space. The Risk Limit defines the maximum amount of money you can spend for trades executed in that space.

linked
string

potential linked Paper or Real Money Space

id
string

Identification Number to uniquely identify your Space

buying_power
int

The Buying Power is the amount of money in that Space that you have available to place new Orders. It is calculated through Risk Limit - Backfire - pending Orders

earnings
int

The Earnings tell you how much your current profit in that Space is

backfire
int

Backfire is an aggregated number that tells you about your combined Expenses and Losses

Request

1import requests
2import json
3
4request = requests.put("https://paper-trading.lemon.markets/v1/spaces/{space_id}/",
5          data=json.dumps({
6              "description": "Here is my new description",
7              "risk_limit": 30000000,
8            }), headers={"Authorization": "Bearer YOUR-API-KEY"})
9print(request.json())
10      

Response

1{
2  "time": "2021-11-22T15:43:35.084+00:00",
3  "status": "ok",
4  "mode":"paper",
5  "results": {
6    "name": "MyNewSpace",
7    "description": "Here is my new description",
8    "risk_limit": 30000000,
9    "linked": None,
10    "id": "sp_pyJHLNBHHfny5n8c76F747bB4d3ycQw2HB",
11    "buying_power": 10000000,
12    "earnings": 0,
13    "backfire": 10000000
14  }
15}

You have the possibility to delete a Space. You can only delete an empty space, meaning that the space has nothing in its portfolio and no pending orders.

To delete a space, send a DELETE request against the following request URLs:

https://paper-trading.lemon.markets/v1/spaces/{space_id}/

to delete a Paper Money Space, and:

https://trading.lemon.markets/v1/spaces/{space_id}/

to delete a Paper Money Space.

Request

Specify your request as follows:

Path Parameters

space_id
string
required

Identification Number of the Space you wish to delete

Header Parameters

Authorization
string
required

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

Response

Response Parameters

time
string

Returns the timestamp when the Space was deleted

status
string

API returns "ok" when Space was successfully deleted

mode
string

Environment the request was placed in: "paper" or "money"

Request

1import requests
2import json
3
4request = requests.delete("https://paper-trading.lemon.markets/v1/spaces/{space_id}/", headers={"Authorization": "Bearer YOUR-API-KEY"})
5print(request.json())
6      

Response

1{
2  "time":"2021-11-21T19:34:45.071+00:00",
3  "status": "ok"
4  "mode":"paper"
5}