Exchange

Exchange Endpoints #

Exchange Configuration Endpoints #

Active Exchange Configuration Retrieval #

GET /exchange/configs/active

Retrieves the active exchange configuration.

Authentication required: yes

Permissions: exchange-configs-read

Query parameters: none

Request body: none

Response body:

{
	"id": "9bsv0s78ajk0036f3m60",
	"created_at": "2020-09-10T21:01:20Z",
	"updated_at": "2020-09-10T21:01:20Z",
	"used_at": "2020-10-10T20:01:20Z",
	"name": "exchange1",
	"identity": {
		"id": "12sv0s78ajk0036f3m60",
		"created_at": "2020-09-10T21:01:20Z",
		"type": "binance",
		"codename": "exchange-code-name"
	},
	"scheme": {
		"type": "binance",
		"key": "12sv0s78ajk0036f3m60",
		"secret": "34sv0s78ajk0036f3m60"
	}
}
Exchange configuration properties are described in detail here.

Exchange Configuration Activation #

PUT /exchange/configs/active

Activates an exchange configuration.

The engine must be stopped before activation.

Authentication required: yes

Permissions: exchange-configs-write

Query parameters: none

Request body:

{
	"id": "9bsv0s78ajk0036f3m60"
}
  • id - string (optional; default: unused)
    The ID of the exchange configuration to activate.
    If not provided, the last used exchange configuration is activated.

Response body: none

Exchange Configuration Retrieval #

GET /exchange/configs/{id}

Retrieves an exchange configuration by its ID.

Authentication required: yes

Permissions: exchange-configs-read

Query parameters: none

Request body: none

Response body:

{
	"id": "9bsv0s78ajk0036f3m60",
	"created_at": "2020-09-10T21:01:20Z",
	"updated_at": "2020-09-10T21:01:20Z",
	"used_at": "2020-10-10T20:01:20Z",
	"name": "exchange1",
	"identity": {
		"id": "12sv0s78ajk0036f3m60",
		"created_at": "2020-09-10T21:01:20Z",
		"type": "binance",
		"codename": "exchange-code-name"
	},
	"scheme": {
		"type": "binance",
		"key": "12sv0s78ajk0036f3m60",
		"secret": "34sv0s78ajk0036f3m60"
	}
}
  • id - string
    The ID of the exchange configuration.

  • created_at - string (RFC 3339)
    The exact time when the exchange configuration was created.

  • updated_at - string (RFC 3339)
    The exact time when the exchange configuration was updated.

  • used_at - string (RFC 3339)
    The exact time when the exchange configuration was last used.

  • name - string
    The name of the exchange configuration.

  • identity - object
    The exchange identity that is assigned to the configuration.

    Exchange identity properties are described in detail here.

  • scheme - object
    The exchange configuration scheme.

    Exchange configuration scheme properties are described in detail here.

Multiple Exchange Configurations Retrieval #

GET /exchange/configs

Retrieves multiple exchange configurations.

Authentication required: yes

Permissions: exchange-configs-read

Query parameters:

  • limit - unsigned int
    The number of exchange configurations per page.

  • page - unsigned int
    The exchange configuration batch index.

  • omissions - array of strings (optional; default: unused)
    The array containing properties that are omitted from each returned exchange configuration object. Possible values:

    • scheme
  • filter-name-includes - string (optional; default: unused)
    If specified, only exchange configurations whose names include this value are returned. The filtering process is case-insensitive.

    filter-name-includes should be used as the default search bar filter.

  • sort-{index}-created-at - string (enum; optional; default: unused)
    If specified, exchange configurations are sorted by their creation timestamps. The value determines whether ascending (asc) or descending (desc) order is used.

  • sort-{index}-updated-at - string (enum; optional; default: unused)
    If specified, exchange configurations are sorted by their update timestamps. The value determines whether ascending (asc) or descending (desc) order is used.

  • sort-{index}-used-at - string (enum; optional; default: unused)
    If specified, exchange configurations are sorted by their last use timestamps. The value determines whether ascending (asc) or descending (desc) order is used.

  • sort-{index}-name - string (enum; optional; default: unused)
    If specified, exchange configurations are sorted by their names. The value determines whether ascending (asc) or descending (desc) order is used.

Many different filter- and sort- keys may be used at the same time, however, to ensure predictable sorting, sort- keys must include an index denoting their precendence. For example, if ?sort-1-name=asc&sort-2-created-at=desc query is being used, exchange configurations are first sorted by their names and only then by their creation timestamps.

Request body: none

Response body:

{
	"page_count": 300,
	"configs": [
		{
			"id": "9bsv0s78ajk0036f3m60",
			"created_at": "2020-09-10T21:01:20Z",
			"updated_at": "2020-09-10T21:01:20Z",
			"used_at": "2020-10-10T20:01:20Z",
			"name": "exchange1",
			"identity": {
				"id": "12sv0s78ajk0036f3m60",
				"created_at": "2020-09-10T21:01:20Z",
				"type": "binance",
				"codename": "exchange-code-name"
			},
			"scheme": {
				"type": "binance",
				"key": "12sv0s78ajk0036f3m60",
				"secret": "34sv0s78ajk0036f3m60"
			}
		},
		{
			"id": "12sv0s78ajk0036f3m60",
			"created_at": "2020-09-10T21:01:20Z",
			"updated_at": "2020-09-10T21:01:20Z",
			"used_at": "2020-10-10T20:01:20Z",
			"name": "exchange2",
			"identity": {
				"id": "12sv0s78ajk0036f3m60",
				"created_at": "2020-09-10T21:01:20Z",
				"type": "binance",
				"codename": "exchange-code-name"
			},
			"scheme": {
				"type": "binance",
				"key": "12sv0s78ajk0036f3m60",
				"secret": "34sv0s78ajk0036f3m60"
			}
		}
	]
}
  • page_count - unsigned int
    The number of available pages that may be retrieved with the same filtering options.

  • configs - array of objects
    The array of exchange configurations.

    Exchange configuration properties are described in detail here.

Exchange Configuration Count Retrieval #

GET /exchange/configs/count

Retrieves the total number of exchange configurations.

Authentication required: yes

Permissions: exchange-configs-read

Query parameters: none

Request body: none

Response body:

{
	"count": 300
}
  • count - unsigned int
    The total number of exchange configurations.

Exchange Configuration Creation #

POST /exchange/configs

Creates a new exchange configuration.

Authentication required: yes

Permissions: exchange-configs-write

Query parameters: none

Request body:

{
	"name": "exchange1",
	"identity_id": "12sv0s78ajk0036f3m60",
	"scheme": {
		"type": "binance",
		"key": "12sv0s78ajk0036f3m60",
		"secret": "34sv0s78ajk0036f3m60"
	}
}
  • name - string
    The name of the new exchange configuration. It must match the following regexp: ^[\w-.]+$

  • identity_id - string (optional; default: randomly generated)
    The ID of an existing exchange identity that should be assigned to the new exchange configuration. If not provided, a new identity is created and automatically assigned.

  • scheme - object
    The exchange configuration scheme.

    Exchange configuration scheme properties are described in detail here.

Response body:

{
	"id": "9bsv0s78ajk0036f3m60",
	"created_at": "2020-09-10T21:01:20Z",
	"updated_at": "2020-09-10T21:01:20Z",
	"used_at": "2020-10-10T20:01:20Z",
	"name": "exchange1",
	"identity": {
		"id": "12sv0s78ajk0036f3m60",
		"created_at": "2020-09-10T21:01:20Z",
		"type": "binance",
		"codename": "exchange-code-name"
	},
	"scheme": {
		"type": "binance",
		"key": "12sv0s78ajk0036f3m60",
		"secret": "34sv0s78ajk0036f3m60"
	}
}
Exchange configuration properties are described in detail here.

Exchange Configuration Update #

PATCH /exchange/configs/{id}

Updates an exchange configuration by its ID.

The active exchange configuration can be updated only when the engine is stopped.

Authentication required: yes

Permissions: exchange-configs-write

Query parameters: none

Request body:

{
	"name": "exchange2",
	"identity_id": "12sv0s78ajk0036f3m60",
	"scheme": {
		"type": "binance",
		"key": "12sv0s78ajk0036f3m60",
		"secret": "34sv0s78ajk0036f3m60"
	}
}
  • name - string (optional; default: unused)
    The new name of the exchange configuration. It must match the following regexp: ^[\w-.]+$

  • identity_id - string (optional; default: unused)
    The new ID of an existing exchange identity that should be assigned to the exchange configuration. Only if an empty string is provided, a new identity is created and automatically assigned.

  • scheme - object (optional; default: unused)
    The new exchange configuration scheme.

    Exchange configuration scheme properties are described in detail here.

Response body: none

Exchange Configuration Deletion #

DELETE /exchange/configs/{id}

Deletes an exchange configuration by its ID.

The active exchange configuration cannot be deleted.

Authentication required: yes

Permissions: exchange-configs-write

Query parameters: none

Request body: none

Response body: none

Exchange Identity Endpoints #

Multiple Exchange Identities Retrieval #

GET /exchange/indentities

Retrieves multiple exchange identities.

Authentication required: yes

Permissions: exchange-identities-read

Query parameters:

  • limit - unsigned int
    The number of exchange identities per page.

  • page - unsigned int
    The exchange identity batch index.

  • sort-{index}-created-at - string (enum; optional; default: unused)
    If specified, exchange identities are sorted by their creation timestamps. The value determines whether ascending (asc) or descending (desc) order is used.

  • sort-{index}-codename - string (enum; optional; default: unused)
    If specified, exchange identities are sorted by their codenames. The value determines whether ascending (asc) or descending (desc) order is used.

Many different filter- and sort- keys may be used at the same time, however, to ensure predictable sorting, sort- keys must include an index denoting their precendence. For example, if ?sort-1-codename=asc&sort-2-created-at=desc query is being used, exchange identities are first sorted by their codenames and only then by their creation timestamps.

Request body: none

Response body:

{
	"page_count": 300,
	"identities": [
		{
			"id": "12sv0s78ajk0036f3m60",
			"created_at": "2020-09-10T21:01:20Z",
			"type": "binance",
			"codename": "exchange1-code-name"
		},
		{
			"id": "34sv0s78ajk0036f3m60",
			"created_at": "2020-09-10T21:01:20Z",
			"type": "binance",
			"codename": "exchange2-code-name"
		}
	]
}
  • page_count - unsigned int
    The number of available pages that may be retrieved with the same filtering options.

  • identities - array of objects
    The array of exchange identities. Exchange identity object properties are:

    • id - string
      The ID of the exchange identity.

    • created_at - string (RFC 3339)
      The exact time when the exchange identity was created.

    • type - string
      The type of the exchange identity.

    • codename - string
      The codename of the exchange identity.

Live Exchange Data Endpoints #

Multiple Live Exchange Symbols Retrieval #

GET /exchange/live/symbols

Retrieves all available exchange symbols.

Authentication required: yes

Permissions: exchange-live-data-read

Query parameters: none

Request body: none

Response body:

[
	"BTC_USDT",
	"ETH_USDT",
	"LTC_USDT"
]

The returned array contains symbol strings.

Multiple Live Exchange Intervals Retrieval #

GET /exchange/live/intervals

Retrieves all available exchange intervals.

Authentication required: yes

Permissions: exchange-live-data-read

Query parameters: none

Request body: none

Response body:

[
	"1hour",
	"4hours",
	"1day",
	"1week"
]

The returned array contains interval strings.

Multiple Live Exchange Tickers Retrieval #

GET /exchange/live/tickers

Retrieves multiple exchange tickers.

Authentication required: yes

Permissions: exchange-live-data-read

Query parameters:

  • symbols - array of strings
    The array of ticker symbols.

Request body: none

Response body:

{
	"BTC_USDT": {
		"last": "31211.45",
		"ask": "32211.45",
		"bid": "30211.45",
		"change": "1201.12",
		"percent_change": "7",
		"volume": "31234512.1"
	},
	"ETH_USDT": {
		"last": "3111.45",
		"ask": "3221.45",
		"bid": "3021.45",
		"change": "1201.12",
		"percent_change": "12",
		"volume": "3124512.1"
	}
}

The returned object is a map that contains symbols along with their ticker data. Ticker object properties are:

  • last - string (decimal)
    The last (most recent) price of the asset.

  • ask - string (decimal)
    The ask price of the asset.

  • bid - string (decimal)
    The bid price of the asset.

  • change - string (decimal)
    The 24-hour price change.

  • percent_change - string (decimal)
    The 24-hour price change percentage.

  • volume - string (decimal)
    The 24-hour transaction volume.

Multiple Live Exchange Candles Retrieval #

GET /exchange/live/candles

Retrieves multiple exchange candles.

Authentication required: yes

Permissions: exchange-live-data-read

Query parameters:

  • symbol - string
    The symbol of candles.

  • interval - string
    The interval of candles.

  • limit - unsigned int
    The number of candles.

    Fewer candles than requested may be returned if the exchange cannot provide the required number of them. This may happen when the target asset is still new or the selected interval is too big.

  • end-time - string (RFC 3339; optional; default: current time)
    If specified, only candles whose timestamps are not greater than this value are returned.

Request body: none

Response body:

[
	{
		"opened_at": "2020-09-10T21:00:20Z",
		"open": "2.1",
		"high": "3.1",
		"low": "4.1",
		"close": "5.1",
		"volume": "6.1"
	},
	{
		"opened_at": "2020-09-10T21:05:20Z",
		"open": "3.1",
		"high": "4.1",
		"low": "5.1",
		"close": "6.1",
		"volume": "7.1"
	},
	{
		"opened_at": "2020-09-10T21:10:20Z",
		"open": "4.1",
		"high": "5.1",
		"low": "6.1",
		"close": "7.1",
		"volume": "8.1"
	}
]
The candles are ordered in ascending order, which means that the latest candle is always the last one.

The returned array contains candles belonging to a specific symbol and interval. Candle object properties are:

  • opened_at - string (RFC 3339)
    The exact time when the candle was opened. It may be used to uniquely identify the candle.

  • open - string (decimal)
    The open price of the candle.

  • high - string (decimal)
    The high price of the candle.

  • low - string (decimal)
    The low price of the candle.

  • close - string (decimal)
    The close price of the candle.

  • volume - string (decimal)
    The transaction volume of the candle.

Live Exchange Account Information Retrieval #

GET /exchange/live/account

Retrieves exchange account information.

Authentication required: yes

Permissions: exchange-live-data-read

Query parameters: none

Request body: none

Response body:

{
	"cash": {
		"asset": "USD",
		"quantity": "31.0"
	}
}
  • cash - object
    The information about cash resources.
    • asset - string
      The asset that is being used as cash. If the cash resources are not being used, the asset is returned as an empty string.

    • quantity - string (decimal)
      The available quantity of the cash asset.

Multiple Live Exchange Positions Retrieval #

GET /exchange/live/positions

Retrieves all exchange positions.

Authentication required: yes

Permissions: exchange-live-data-read

Query parameters: none

Request body: none

Response body:

{
	"BTC": {
		"quantity": "0.31"
	},
	"ETH": {
		"quantity": "1203.12"
	}
}

The returned object is a map that contains assets along with their position data. Position object properties are:

  • quantity - string (decimal)
    The number of asset units that are owned.

Exchange Order Endpoints #

Exchange Order Retrieval #

GET /exchange/orders/{id}

Retrieves an order by its ID.

Authentication required: yes

Permissions: exchange-orders-read

Query parameters: none

Request body: none

Response body:

{
	"id": "9bsv0s78ajk0036f3m60",
	"identity": {
		"id": "12sv0s78ajk0036f3m60",
		"created_at": "2020-09-10T21:01:20Z",
		"type": "binance",
		"codename": "exchange-code-name"
	},
	"external_id": "78ajk0036f3m60",
	"symbol": "BTC_USDT",
	"side": "buy",
	"price": "38012.123",
	"total_quantity": "0.0541",
	"filled_quantity": "0.0241",
	"cancelled": true,
	"manual": false,
	"placed_at": "2020-09-10T21:01:20Z",
	"accepted_at": "2020-09-10T21:01:20Z",
	"closed_at": "2020-10-10T20:01:20Z"
}
  • id - string
    The ID of the order.

  • identity - object
    The exchange identity that is assigned to the order.

    Exchange identity properties are described in detail here.

  • external_id - string
    The ID of the order that is used by the exchange.

  • symbol - string
    The symbol of the order.

  • side - string (enum)
    The side of the order. Possible values:

    • buy
    • sell
  • price - string (decimal)
    The price of the asset.

  • total_quantity - string (decimal)
    The total quantity of the asset.

  • filled_quantity - string (decimal)
    The quantity of the asset that is already filled/traded.

  • cancelled - boolean
    Specifies whether the order is cancelled or not.

  • manual - boolean
    Specifies whether the order was placed manually or not.

  • placed_at - string (RFC 3339)
    The exact time when the order was placed.

  • accepted_at - string (RFC 3339)
    The exact time when the order was successfully accepted by the exchange.

  • closed_at - string (RFC 3339)
    The exact time when the order was either filled or cancelled.

Multiple Exchange Orders Retrieval #

GET /exchange/orders

Retrieves multiple orders.

Authentication required: yes

Permissions: exchange-orders-read

Query parameters:

  • limit - unsigned int
    The number of orders per page.

  • page - unsigned int
    The order batch index.

  • filter-identity-id-eq - string (optional; default: unused)
    If specified, only orders whose exchange identity IDs match this value are returned.

  • filter-identity-type-eq - string (optional; default: unused)
    If specified, only orders whose exchange identity types match this value are returned.

  • filter-identity-type-includes - string (optional; default: unused)
    If specified, only orders whose exchange identity types include this value are returned. The filtering process is case-insensitive.

  • filter-identity-codename-eq - string (optional; default: unused)
    If specified, only orders whose exchange identity codenames match this value are returned.

  • filter-identity-codename-includes - string (optional; default: unused)
    If specified, only orders whose exchange identity codenames include this value are returned. The filtering process is case-insensitive.

  • filter-closed-at-le - string (RFC 3339; optional; default: unused)
    If specified, only orders whose close timestamps are not greater than this value are returned.

  • filter-closed-at-ge - string (RFC 3339; optional; default: unused)
    If specified, only orders whose close timestamps are not lesser than this value are returned.

  • filter-accepted-at-le - string (RFC 3339; optional; default: unused)
    If specified, only orders whose acceptance timestamps are not greater than this value are returned.

  • filter-accepted-at-ge - string (RFC 3339; optional; default: unused)
    If specified, only orders whose acceptance timestamps are not lesser than this value are returned.

  • filter-closed-eq - boolean (optional; default: unused)
    If specified, only orders whose close statuses match this value are returned.

  • filter-accepted-eq - boolean (optional; default: unused)
    If specified, only orders whose acceptance statuses match this value are returned.

  • filter-cancelled-eq - boolean (optional; default: unused)
    If specified, only orders whose cancellation statuses match this value are returned.

  • filter-symbol-eq - string (optional; default: unused)
    If specified, only orders whose symbols match this value are returned.

  • filter-symbol-includes - string (optional; default: unused)
    If specified, only orders whose symbols include this value are returned. The filtering process is case-insensitive.

    filter-symbol-includes should be used as the default search bar filter.

  • filter-side-eq - string (optional; default: unused)
    If specified, only orders whose sides match this value are returned.

  • filter-manual-eq - boolean (optional; default: unused)
    If specified, only orders whose placement types match this value are returned.

  • filter-filled-quantity-le - string (decimal; optional; default: unused)
    If specified, only orders whose filled quantities are not greater than this value are returned.

  • filter-filled-quantity-ge - string (decimal; optional; default: unused)
    If specified, only orders whose filled quantities are not lesser than this value are returned.

  • filter-filled-quantity-gt - string (decimal; optional; default: unused)
    If specified, only orders whose filled quantities are greater than this value are returned.

  • sort-{index}-placed-at - string (enum; optional; default: unused)
    If specified, orders are sorted by their placement timestamps. The value determines whether ascending (asc) or descending (desc) order is used.

  • sort-{index}-accepted-at - string (enum; optional; default: unused)
    If specified, orders are sorted by their acceptance timestamps. The value determines whether ascending (asc) or descending (desc) order is used.

  • sort-{index}-closed-at - string (enum; optional; default: unused)
    If specified, orders are sorted by their closing timestamps. The value determines whether ascending (asc) or descending (desc) order is used.

  • sort-{index}-filled-quantity - string (enum; optional; default: unused)
    If specified, orders are sorted by their filled quantities. The value determines whether ascending (asc) or descending (desc) order is used.

Many different filter- and sort- keys may be used at the same time, however, to ensure predictable sorting, sort- keys must include an index denoting their precendence. For example, if ?sort-1-closed-at=asc&sort-2-placed-at=desc query is being used, orders are first sorted by their close and only then by their placement timestamps.

Request body: none

Response body:

{
	"page_count": 300,
	"orders": [
		{
			"id": "9bsv0s78ajk0036f3m60",
			"identity": {
				"id": "12sv0s78ajk0036f3m60",
				"created_at": "2020-09-10T21:01:20Z",
				"type": "binance",
				"codename": "exchange-code-name"
			},
			"external_id": "78ajk0036f3m60",
			"symbol": "BTC_USDT",
			"side": "buy",
			"price": "38012.123",
			"total_quantity": "0.0541",
			"filled_quantity": "0.0341",
			"cancelled": true,
			"manual": false,
			"placed_at": "2020-09-10T21:01:20Z",
			"accepted_at": "2020-09-10T21:01:20Z",
			"closed_at": "2020-10-10T20:01:20Z"
		},
		{
			"id": "32sv0s78ajk0036f3m60",
			"identity": {
				"id": "12sv0s78ajk0036f3m60",
				"created_at": "2020-09-10T21:01:20Z",
				"type": "binance",
				"codename": "exchange-code-name"
			},
			"external_id": "78ajk0036f3m60",
			"symbol": "BTC_USDT",
			"side": "buy",
			"price": "38012.123",
			"total_quantity": "0.0141",
			"filled_quantity": "0.0041",
			"cancelled": true,
			"manual": false,
			"placed_at": "2020-09-10T21:01:20Z",
			"accepted_at": "2020-09-10T21:01:20Z",
			"closed_at": "2020-10-10T20:01:20Z"
		}
	]
}
  • page_count - unsigned int
    The number of available pages that may be retrieved with the same filtering options.

  • orders - object array
    The array of orders.

    Order properties are described in detail here.

Exchange Order Count Retrieval #

GET /exchange/orders/count

Retrieves the total number of orders.

Authentication required: yes

Permissions: exchange-orders-read

Query parameters: none

Request body: none

Response body:

{
	"count": 300
}
  • count - unsigned int
    The total number of orders.

Manual Exchange Order Placement #

POST /exchange/orders

Places a new manual order.

Authentication required: yes

Permissions: exchange-orders-write

Query parameters: none

Request body:

{
	"symbol": "BTC_USDT",
	"side": "buy",
	"price": "39131.012",
	"quantity": "0.134"
}
  • symbol - string
    The symbol of the order.

  • side - string (enum)
    The side of the order. Possible values:

    • buy
    • sell
  • price - string (decimal)
    The price of the asset.

  • quantity - string (decimal)
    The quantity of the asset.

Response body:

{
	"id": "9bsv0s78ajk0036f3m60",
	"identity": {
		"id": "12sv0s78ajk0036f3m60",
		"created_at": "2020-09-10T21:01:20Z",
		"type": "binance",
		"codename": "exchange-code-name"
	},
	"external_id": "78ajk0036f3m60",
	"symbol": "BTC_USDT",
	"side": "buy",
	"price": "38012.123",
	"total_quantity": "0.0541",
	"filled_quantity": "0.0241",
	"cancelled": false,
	"manual": true,
	"placed_at": "2020-09-10T21:01:20Z",
	"accepted_at": "2020-09-10T21:01:20Z",
	"closed_at": "2020-10-10T20:01:20Z"
}
Order properties are described in detail here.