EXECX Order Manager API (1.0.14)

Download OpenAPI specification:

E-mail: [email protected] License: Private

Introduction

This is the documentation for the EXECX crypto execution platform, it provides a single API to send orders to some of the largest exchanges. In addition to sending orders it can also be configured to actively place orders using the position manager, this allows users to set target positions that will be entered over time using post only orders eliminating taker fees.

Getting Started

EXECX is run locally on your production machines through a Docker deployment, this is done to keep the latency between your trading application and the exchange as low as possible. An API key is required and will be sent you to upon signing up for an EXECX account.

To run EXECX use the following command, we recommend using host networking to reduce latency

$ docker run --net=host --name=execx -d execx/order-manager:latest --key [API_KEY]

An API key is required to verify the subscription and will be checked at start up, you will receive this API key via email when registering for an account.

Command Line Arguments

The following command line arguments are available -

Argument Description Default
--key Your unique API key, you should receive this when signing up for an EXECX account
--port The REST port number for communication, all REST and Websocket requests must be sent to this port 35027
--promPort The Prometheus metrics port 9091
--testnet Enable exchange testnets false
--debug Enable debug logging false

Exchanges

Please follow these notes to get the best performance from EXECX. If latency is a concern then you should focus on finding a machine that is a close as physically possible to the exchange matching engine; this can be achieved by spinning up multiple machines in the correct cloud zone and measuring latency between yourself and the exchange. We recommend using delete orders to ensure you are hitting the matching engine, ping is not enough.

Binance

Binance servers are located in AWS Tokyo zone A. Internally EXECX uses the REST order entry API to send orders and the websocket to receive order updates.

OKX

OKX servers are located in Alibaba Hong Kong zone C, if you are not able to use Alibaba cloud you can access through AWS and it is recommended to set the REST URL to https://aws.okx.com and the websocket URL to wss://wsaws.okx.com:8443. See here for more information.

OKX does not support pull by symbol except for options, to handle this EXECX internally constructs a batch cancel message for all working orders. This is continuously updated as orders are cancelled or removed to reduce latency on pulls.

Bybit

Bybit servers are located in AWS Singapore in zone ID apse1-az3.

Deribit

Deribit does not run their servers in a cloud instead it operates in a data centre Equinix LD4 in Slough, UK. The fastest connection possible is through renting a colocated server in this datacentre. If choosing to run your trading strategy in the cloud then please use a data centre that is as close as possible to Slough, UK.

Internally EXECX uses the FIX protocol for Deribit trading, this should provide a lower latency over the alternative APIs.

Features

Please find an explanation of the features provided by EXECX.

Order Entry

Prior to order entry you must establish a new order session, this is described in the API documentation below. The order session is named allowing you to have multiple order sessions to a single exchange.

All order types are supported, for example market orders will trade immediately at the current top of book price where as limit orders can be placed at specific price and volume points.

Position Manager

If you do not wish to manually create orders you can use the position manager, this service will actively seek to trade into a position using maker only orders, this reduces your total fee cost but increases the time it takes to enter a position. Orders are automatically updated on a time interval to be at the top of book, if the spread allows it will attempt to dime the market to ensure your orders are executed first.

The position manager will iceberg orders based on the minOrderQty configuration, over time these orders will reach your target position. Additionally the position manager can layer multiple levels of icebergs to take advantage of favourable price swings.

Triggers

To reduce latency between market price changes and orders being sent you can use the trigger manager, this allows setting of groups of orders to be executed whenever a price level is traded. The trigger manager supports directional triggers, for example if a sell order is the aggressor then the up triggers will be activated. For buy side aggressors the direction is down.

The trigger orders are sent to the same exchange as the trigger, this means that it's possible to execute trades on different symbols to the trigger symbol.

NOTE Having a large number of active triggers will reduce performance and increase latency between trade events and orders being sent.

Prometheus Metrics

Prometheus metrics are available through the /metrics endpoint. This includes order counts and latencies as well as information from the position manager such as target position and current position.

The metrics use the namespace om.

Order Manager API

Order manager API for executing orders on an exchange, provides a websocket for receiving streaming order updates

Start an order session

Creates a new named order session, it requires the API keys and a unique session id, orders are then sent through this session via the session id parameter on a new order transaction.

NOTE REST URL and Websocket URL are optional parameters, leaving them blank will use the default hostnames in EXECX. If you have private colocation you may need to override these addresses. In the case of Deribit the wsUrl is the FIX url www.deribit.com:9883

Request Body schema: application/json
required
required
object (exchangekey)

Contains the unique exchange keys for a specific trading account

sessionId
required
string

Session ID that uniquely identifies this session, session IDs must not be reused and will return an error, usually corresponds to a trading strategy name

restUrl
string

Optionally override the default exchange REST hostname, must be sent without any path or trailing slash

wsUrl
string

Optionally override the default exchange websocket hostname, must be sent without any path or trailing slash

interface
string

Named network interface, where a single interface has multiple attached IP addresses use the format eth0:1 where 0 is the first network interface and 1 is the second attached IP address

useMargin
boolean

Enable margin mode on the order handler

Responses

Request samples

Content type
application/json
{
  • "exchangeKey": {
    },
  • "sessionId": "unique-session-id",
  • "wsUrl": "wss://stream.binance.com",
  • "interface": "eth0",
  • "useMargin": true
}

Stop an order session

Stops an existing order session

Request Body schema: application/json
required
sessionId
required
string

A previously created session id

Responses

Request samples

Content type
application/json
{
  • "sessionId": "unique-session-id"
}

Set dynamic log level

Sets the dynamic log level of the application

Request Body schema: application/json
required

Log level enum

logLevel
required
string (loglevels)
Default: "info"
Enum: "debug" "info" "warn" "error"

Sets the dynamc log level of the application to the specified severity

Responses

Request samples

Content type
application/json
{
  • "logLevel": "debug"
}

Send a new order

Send a new order to the exchange, requires a session id that must have been previously started using /startOrderHandler, updates can be received through the websocket subscription /subscribeUpdates

Request Body schema: application/json
required

Order details

clOrderId
required
string

Client order ID, must be unique, must match exchange rules

symbol
required
string

Exchange symbol

sessionId
required
string

Order handler session ID

price
number <double>

Order price, must be specified if sending a limit order

qty
number <double>

Order quantity, must be specified if sending an insert or update transaction

orderType
string (ordertype)
Enum: "limit" "market" "postonly"

Order type:

  • limit - Limit order, requires a price
  • market - Market order, will execute at market price
  • postonly - Post only order can be maker only, will not immediately match, requires a price
transactionType
required
string (transactiontype)
Enum: "insert" "update" "delete" "pull"

Transaction type:

  • insert - Create a new order, requires a new client order id
  • update - Update an existing order, requires an existing client order id
  • delete - Cancel an existing order by client order id
  • pull - Pull all orders, usually requires a symbol
tif
string (timeinforce)
Enum: "gtc" "ioc" "day" "fok"

Time in force:

  • gtc - Good till cancelled
  • ioc - Insert or cancel, can partially fill and the remainder is cancelled
  • day - Day order
  • fok - Must immediately fill for the full volume or is cancelled
side
string (side)
Enum: "buy" "sell"

Side:

  • buy - Buy side
  • sell - Sell side

Responses

Request samples

Content type
application/json
{
  • "clOrderId": "cl-abcd",
  • "symbol": "BTCUSDT",
  • "sessionId": "binance-spot-account",
  • "price": 124.2,
  • "qty": 1,
  • "orderType": "postonly",
  • "transactionType": "insert",
  • "tif": "gtc",
  • "side": "buy"
}

Refresh order state

Refreshes the order state with the exchange in the event of stuck orders

Request Body schema: application/json
required
sessionId
required
string

A previously created session id

required
Array of objects (ordertransaction)

A list of order transactions for refresh

Responses

Request samples

Content type
application/json
{
  • "sessionId": "string",
  • "transactions": [
    ]
}

Ping order manager

Provides a response if the order manager is alive

Responses

Get instrument position

Returns a position for a given session ID by symbol and exchange

Request Body schema: application/json
sessionId
string

An existing order handler session ID

symbol
string

An exchange symbol

exchange
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

Responses

Request samples

Content type
application/json
{
  • "sessionId": "test-session",
  • "symbol": "BTCUSDT",
  • "exchange": "binance-spot"
}

Response samples

Content type
application/json
{
  • "position": 0.1
}

Websocket API

Websocket API endpoints

Streaming position updates

Creates a websocket connection that streams session position changes to the consumer

Request Body schema: application/json
required

Requires an established order session

sessionId
required
string

A previously created session id

Responses

Request samples

Content type
application/json
{
  • "sessionId": "string"
}

Response samples

Content type
application/json
{
  • "sessionId": "unique-session-id",
  • "positions": {
    }
}

Streaming order updates

Creates a websocket connection that streams order updates to the consumer

Request Body schema: application/json
required

Requires an established order session

sessionId
required
string

A previously created session id

Responses

Request samples

Content type
application/json
{
  • "sessionId": "string"
}

Response samples

Content type
application/json
{
  • "exchOrderId": "abcd",
  • "message": "quantity does not match minimum notional",
  • "clOrderId": "cl-abcd",
  • "exchange": "binance-spot",
  • "symbol": "BTCUSDT",
  • "sessionId": "binance-spot-account",
  • "tradeId": "t-abcd",
  • "localTime": 1720181590000000000,
  • "exchTime": 1720181590000000000,
  • "sendTime": 1720181590000000000,
  • "price": 124.2,
  • "qty": 1,
  • "cumulativeFilledQty": 0.2,
  • "executedQty": 0.2,
  • "remainingQty": 0.2,
  • "orderType": "postonly",
  • "orderStatus": "partiallyfilled",
  • "transactionType": "insert",
  • "tif": "gtc",
  • "side": "buy",
  • "tradeLiquidity": "add",
  • "triggerId": "trigger-a"
}

Position Manager API

Position manager API for entering or exiting positions using maker orders to reduce fees, requires an existing order manager

Start a new position manager

Creates a new position manager, requires an order group

Request Body schema: application/json
required
sessionId
required
string

A previously created order session

exchange
required
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

symbol
required
string

An exchange symbol, required for retrieving market data

required
object (positionmanagerconfig)

Responses

Request samples

Content type
application/json
{
  • "sessionId": "test-session",
  • "exchange": "binance-spot",
  • "symbol": "BTCUSDT",
  • "config": {
    }
}

Stop a position manager

Stops a position manager

Request Body schema: application/json
required
exchange
required
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

symbol
required
string

The symbol of an existing position manager

Responses

Request samples

Content type
application/json
{
  • "exchange": "binance-spot",
  • "symbol": "BTCUSDT"
}

Set target position

Sets a new target position for an existing position manager

Request Body schema: application/json
required
exchange
required
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

symbol
required
string

The exchange symbol for an existing position manager

targetPosition
required
number <double>

The new target position, positive for long, negative for short

Responses

Request samples

Content type
application/json
{
  • "exchange": "binance-spot",
  • "symbol": "BTCUSDT",
  • "targetPosition": 0.1
}

Trigger Manager API

Trigger manager API allows you to send groups of orders on trade price events, orders can be sent seperately for buy and sell events. Order updates should be consumed through the /subscribeUpdates endpoint.

Start a new trigger manager

Creates a new trigger manager, requires an order group

Request Body schema: application/json
required
symbol
required
string

Exchange symbol

exchange
required
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

sessionId
required
string

A previously created order session id

Responses

Request samples

Content type
application/json
{
  • "symbol": "BTC-USDT",
  • "exchange": "binance-spot",
  • "sessionId": "string"
}

Stop a trigger manager

Stops an existing trigger manager

Request Body schema: application/json
required
symbol
required
string

Exchange symbol

exchange
required
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

sessionId
required
string

A previously created order session id

Responses

Request samples

Content type
application/json
{
  • "symbol": "BTC-USDT",
  • "exchange": "binance-spot",
  • "sessionId": "string"
}

Set a trigger

Set a new trigger

Request Body schema: application/json
required
id
required
string

A unique trigger ID, can be used later to cancel this trigger

price
required
number <double>

The trade price to activate the trigger on

symbol
required
string

An exchange symbol to use as the source of price data for the trigger

direction
required
string
Enum: "up" "down"

Uses the trade event aggressor side to select up or down triggers. Buy side aggressors trigger the up direction and sell side aggressors trigger the down direction.

exchange
required
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

required
Array of objects (sendorder)

Responses

Request samples

Content type
application/json
{
  • "id": "trigger-a",
  • "price": 1020,
  • "symbol": "BTC-USDT",
  • "direction": "up",
  • "exchange": "binance-spot",
  • "orders": [
    ]
}

Cancel a trigger

Clears a single existing trigger

Request Body schema: application/json
required
symbol
required
string

Exchange symbol

exchange
required
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

id
required
string

A previously created trigger id

Responses

Request samples

Content type
application/json
{
  • "symbol": "BTC-USDT",
  • "exchange": "binance-spot",
  • "id": "trigger-a"
}

Clear triggers

Clears all triggers for a specific symbol or across all managers

Request Body schema: application/json
required
symbol
string

Exchange symbol

exchange
string (exchange)
Enum: "binance-spot" "binance-usdm-future" "binance-coinm-future" "bybit-spot" "bybit-linear" "bybit-inverse" "bybit-option" "okx" "deribit"

Exchange enum, defines which API to use for feed and order routing as well as for account and positions

clearAll
boolean

Clears every trigger across all trigger managers

Responses

Request samples

Content type
application/json
{
  • "symbol": "BTC-USDT",
  • "exchange": "binance-spot",
  • "clearAll": false
}