EXECX Order Manager API (1.0.17)

Download OpenAPI specification:

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.

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
}

Dip Buyer API

Dip buyer API for automatically buying into a position when the price drops.

Start a New Dip Buyer

Creates a new dip buyer for a specific symbol. It will automatically buy a configured quantity when the price dips by a certain percentage from a recent high.

Request Body schema: application/json
required
sessionId
required
string

A previously created session id to use for placing orders.

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 the dip buyer.

required
object (dipbuyerconfig)

Configuration for the dip buyer strategy.

Responses

Request samples

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

Stop a Dip Buyer

Stops an existing dip buyer for a specific symbol.

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 dip buyer.

sessionId
required
string

The session ID used when starting the dip buyer.

Responses

Request samples

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

Grid Trader API

Grid trader API for automatically placing buy and sell orders in a grid to profit from volatility.

Start a New Grid Trader

Creates and starts a new grid trading session for a specific symbol.

Grid Trader

The grid trader is an automated trading strategy that places a series of buy and sell limit orders at predefined price intervals around a central price. This creates a "grid" of orders. When a buy order is filled, a sell order is placed one grid level above it. Conversely, when a sell order is filled, a buy order is placed one grid level below it. This strategy aims to profit from market volatility by buying low and selling high within a defined price range.

Grid Calculation

The grid can be defined in two ways:

  1. By setting upperPrice and lowerPrice.
  2. By setting gridRangePercentage around the current market price.

If upperPrice and lowerPrice are provided, they define the trading range. If gridRangePercentage is provided (scaled from 0-100), the range is calculated based on the current mid-price of the symbol. For example, a gridRangePercentage of 10 (for 10%) with a mid-price of 100 would set the lower price to 95 and the upper price to 105. You must provide either the price range or the percentage range.

Grid Modes

There are two modes for calculating the price levels within the grid:

Arithmetic Mode (ARITHMETIC)

In arithmetic mode, the price difference between each grid level is constant. For example, if the range is from 100 to 110 with 10 grid levels, each level will be 1 unit apart (100, 101, 102, ...). This mode is suitable for markets where price movements are expected to be linear.

Geometric Mode (GEOMETRIC)

In geometric mode, the price difference between each grid level is a constant percentage. This means the absolute price difference is smaller at lower prices and larger at higher prices. This mode is often preferred for volatile assets where price movements are more exponential.

Static vs. Dynamic Grids

Static Grid (dynamic: false)

A static grid operates within a fixed price range defined by lowerPrice and upperPrice or calculated from gridRangePercentage at startup. The grid levels do not change even if the market price moves outside this range. This is a simpler approach but may become ineffective if the price trends strongly in one direction out of the grid.

Dynamic Grid (dynamic: true)

A dynamic grid adjusts its position based on market movements. The recenterThreshold parameter determines when the grid should be recentered. This is defined as the number of grid levels the market price has moved away from the grid's original center price. For example, if a grid is centered at $100 with 1-dollar grid steps and the recenterThreshold is 5, the grid will be cancelled and recreated around the new market price if the price moves down to $95 or up to $105. This allows the grid to follow market trends but may result in realizing losses if the market reverses after recentering.

Request Body schema: application/json
required
symbol
required
string

Exchange symbol for the grid trader.

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.

upperPrice
number <double>

The upper price boundary of the grid. Not required if gridRangePercentage is set.

lowerPrice
number <double>

The lower price boundary of the grid. Not required if gridRangePercentage is set.

gridRangePercentage
number <double>

The percentage range for the grid, scaled from 0-100, centered around the current market price. For example, a value of 10 for 10% creates a range of +/- 5% from the mid-price. Not required if upperPrice and lowerPrice are set.

gridLevels
required
integer

The number of grid levels (buy/sell lines) to create.

orderQty
required
number <double>

The quantity for each order in the grid.

mode
required
string
Enum: "ARITHMETIC" "GEOMETRIC"

The mode for calculating grid levels. ARITHMETIC for constant price difference, GEOMETRIC for constant percentage difference.

dynamic
boolean

If true, the grid will recenter based on market movements. If false, it's a static grid.

recenterThreshold
integer

For dynamic grids, this is the number of grid steps away from the center price that will trigger a recenter. For example, a value of 5 means the grid will recenter if the price moves 5 grid levels up or down from its starting center. Only applicable if dynamic is true.

Responses

Request samples

Content type
application/json
{
  • "symbol": "BTC-USDT",
  • "exchange": "binance-spot",
  • "sessionId": "string",
  • "upperPrice": 28000,
  • "lowerPrice": 25000,
  • "gridRangePercentage": 10,
  • "gridLevels": 10,
  • "orderQty": 0.01,
  • "mode": "ARITHMETIC",
  • "dynamic": false,
  • "recenterThreshold": 5
}

Stop a Grid Trader

Stops an existing grid trading session for a specific symbol.

Request Body schema: application/json
required
symbol
required
string

The exchange symbol of the grid trader to stop.

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

The session ID used when the grid trader was started.

Responses

Request samples

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