Download OpenAPI specification:
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.
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.
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 |
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 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 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.
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.
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.
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.
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 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 for executing orders on an exchange, provides a websocket for receiving streaming order updates
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 urlwww.deribit.com:9883
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 |
{- "exchangeKey": {
- "apiKey": "abcd-efgh",
- "secretKey": "abcd-efgh",
- "passphrase": "secret-password",
- "exchange": "binance-spot"
}, - "sessionId": "unique-session-id",
- "wsUrl": "wss://stream.binance.com",
- "interface": "eth0",
- "useMargin": true
}
Sets the dynamic log level of the application
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 |
{- "logLevel": "debug"
}
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
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:
|
transactionType required | string (transactiontype) Enum: "insert" "update" "delete" "pull" Transaction type:
|
tif | string (timeinforce) Enum: "gtc" "ioc" "day" "fok" Time in force:
|
side | string (side) Enum: "buy" "sell" Side:
|
{- "clOrderId": "cl-abcd",
- "symbol": "BTCUSDT",
- "sessionId": "binance-spot-account",
- "price": 124.2,
- "qty": 1,
- "orderType": "postonly",
- "transactionType": "insert",
- "tif": "gtc",
- "side": "buy"
}
Refreshes the order state with the exchange in the event of stuck orders
sessionId required | string A previously created session id |
required | Array of objects (ordertransaction) A list of order transactions for refresh |
{- "sessionId": "string",
- "transactions": [
- {
- "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"
}
]
}
Returns a position for a given session ID by symbol and exchange
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 |
{- "sessionId": "test-session",
- "symbol": "BTCUSDT",
- "exchange": "binance-spot"
}
{- "position": 0.1
}
Creates a websocket connection that streams session position changes to the consumer
Requires an established order session
sessionId required | string A previously created session id |
{- "sessionId": "string"
}
{- "sessionId": "unique-session-id",
- "positions": {
- "property1": 0.1,
- "property2": 0.1
}
}
Creates a websocket connection that streams order updates to the consumer
Requires an established order session
sessionId required | string A previously created session id |
{- "sessionId": "string"
}
{- "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 for entering or exiting positions using maker orders to reduce fees, requires an existing order manager
Creates a new position manager, requires an order group
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) |
{- "sessionId": "test-session",
- "exchange": "binance-spot",
- "symbol": "BTCUSDT",
- "config": {
- "pullOnStartup": true,
- "maintainSpreads": true,
- "quoteLevels": 2,
- "minOrderQty": 0.1,
- "reEntryTickerSeconds": 5,
- "priceLevelInterval": 0.001
}
}
Stops a position manager
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 |
{- "exchange": "binance-spot",
- "symbol": "BTCUSDT"
}
Sets a new target position for an existing position manager
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 |
{- "exchange": "binance-spot",
- "symbol": "BTCUSDT",
- "targetPosition": 0.1
}
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.
Creates a new trigger manager, requires an order group
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 |
{- "symbol": "BTC-USDT",
- "exchange": "binance-spot",
- "sessionId": "string"
}
Stops an existing trigger manager
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 |
{- "symbol": "BTC-USDT",
- "exchange": "binance-spot",
- "sessionId": "string"
}
Set a new trigger
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) |
{- "id": "trigger-a",
- "price": 1020,
- "symbol": "BTC-USDT",
- "direction": "up",
- "exchange": "binance-spot",
- "orders": [
- {
- "clOrderId": "cl-abcd",
- "symbol": "BTCUSDT",
- "sessionId": "binance-spot-account",
- "price": 124.2,
- "qty": 1,
- "orderType": "postonly",
- "transactionType": "insert",
- "tif": "gtc",
- "side": "buy"
}
]
}
Clears a single existing trigger
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 |
{- "symbol": "BTC-USDT",
- "exchange": "binance-spot",
- "id": "trigger-a"
}
Clears all triggers for a specific symbol or across all managers
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 |
{- "symbol": "BTC-USDT",
- "exchange": "binance-spot",
- "clearAll": false
}
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.
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. |
{- "sessionId": "unique-session-id",
- "exchange": "binance-spot",
- "symbol": "BTCUSDT",
- "config": {
- "dipPercentage": 1,
- "orderQty": 0.1,
- "maxLongPos": 1,
- "timePeriod": 3600,
- "cooldown": 60
}
}
Stops an existing dip buyer for a specific 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 |
symbol required | string The symbol of an existing dip buyer. |
sessionId required | string The session ID used when starting the dip buyer. |
{- "exchange": "binance-spot",
- "symbol": "BTCUSDT",
- "sessionId": "unique-session-id"
}
Grid trader API for automatically placing buy and sell orders in a grid to profit from volatility.
Creates and starts a new grid trading session for a specific symbol.
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.
The grid can be defined in two ways:
upperPrice
and lowerPrice
.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.
There are two modes for calculating the price levels within the grid:
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
)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.
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: 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.
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 |
lowerPrice | number <double> The lower price boundary of the grid. Not required if |
gridRangePercentage | number <double> The percentage range for the grid, scaled from 0-100, centered around the current market price. For example, a value of |
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. |
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 |
{- "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
}
Stops an existing grid trading session for a specific symbol.
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. |
{- "symbol": "BTC-USDT",
- "exchange": "binance-spot",
- "sessionId": "unique-session-id"
}