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.
NOTE Having a large number of active triggers will reduce performance and increase latency between trade events and orders being sent.
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
}