BitMEX Trade Connector
Features
crypto-bitmexConnector KeyNotes
Rate limits (for API v1)
Requests to our REST API are rate limited to 60 requests per 1 minute. This counter refills continuously. If you are not logged in, your ratelimit is 30/1 minute.
Be very careful about the number of errors your tools throw! If a large number of 4xx or 5xx responses are delivered in a short period of time, your IP may be banned for an hour.
Multiple bans in a short time will result in a week ban
https://www.bitmex.com/app/restAPI#Request-Rate-Limits
The following routes count as requests but are not rate limited with 429s.
DELETE /api/v1/order
DELETE /api/v1/order/all
POST /api/v1/user/logout
Testnet and bitmex.com have the same rate-limiting rules.
Rate limits checker is built into the connector.
Reject reasons for internal and exchange limits:
Rate limit reached. (Expires at: 1592475444613)
Exchange rate limit reached. (Expires at: 1592475444613)
Commission
BitMEX has one type of Spot and three types of Futures (https://www.bitmex.com/app/futuresGuide and https://www.bitmex.com/app/perpetualContractsGuide):
- Inverse Futures and Perpetuals
- Linear Futures and Perpetuals
- Quanto Futures and Perpetuals
- Linear Spot
Commission calculation is based on a ContractValue which is calculated in the instrument's Margin and PnL currency according to the tables:
| Instrument type | ContractValue | Commission |
|---|---|---|
| Inverse Futures and Perpetuals | Multiplier / Price | ContractValue * OrderQty * FeeRate |
| Quanto Futures and Perpetuals | Multiplier * Price | ContractValue * OrderQty * FeeRate |
| Linear Futures and Perpetuals | Multiplier * Price | ContractValue * OrderQty * FeeRate |
| Linear Spots | Multiplier * Price | ContractValue * OrderQty * FeeRate |
month code consists of a month code char and two last digits of delivery year. For example: M22, U22, X23. List of used month code char's: https://www.bitmex.com/app/futuresGuideExamples#Futures-Month-Codes
| Contract | Instrument type | Commission currency | Multiplier |
|---|---|---|---|
XBTmonth code | Inverse Futures | BTC | 1 |
ETHUSDmonth code_ETH | Inverse Futures | ETH | 1 |
| XBTUSD | Inverse Perpetual | BTC | 1 |
| XBTEUR | Inverse Perpetual | BTC | 1 |
| ETHUSD_ETH | Inverse Perpetual | ETH | 1 |
ETHUSDmonth code | Quanto Futures | BTC | 0.000001 |
| ETHUSD | Quanto Perpetual | BTC | 0.000001 |
| XRPUSD | Quanto Perpetual | BTC | 0.0002 |
| BCHUSD | Quanto Perpetual | BTC | 0.000001 |
| LTCUSD | Quanto Perpetual | BTC | 0.000002 |
| DOGEUSD | Quanto Perpetual | BTC | 0.001 |
| BNBUSD | Quanto Perpetual | BTC | 0.000001 |
| ADAUSD | Quanto Perpetual | BTC | 0.0001 |
| DOTUSD | Quanto Perpetual | BTC | 0.00001 |
| AVAXUSD | Quanto Perpetual | BTC | 0.00001 |
| LINKUSD | Quanto Perpetual | BTC | 0.00001 |
| SOLUSD | Quanto Perpetual | BTC | 0.000001 |
| EOSUSD | Quanto Perpetual | BTC | 0.0001 |
| AXSUSD | Quanto Perpetual | BTC | 0.000001 |
| GMTUSD | Quanto Perpetual | BTC | 0.0001 |
| NEARUSD | Quanto Perpetual | BTC | 0.0001 |
| APEUSD | Quanto Perpetual | BTC | 0.00001 |
| TRXUSD | Quanto Perpetual | BTC | 0.001 |
| GALUSD | Quanto Perpetual | BTC | 0.0001 |
| LUNAUSD | Quanto Perpetual | BTC | 0.0001 |
ADAmonth code | Linear Futures | BTC | 0.01 |
ETHmonth code | Linear Futures | BTC | 0.00001 |
XRPmonth code | Linear Futures | BTC | 0.01 |
XBTUSDTmonth code | Linear Futures | USDT | 0.000001 |
ETHUSDTmonth code | Linear Futures | USDT | 0.00001 |
| DOGEUSDT | Linear Perpetual | USDT | 0.01 |
| SOLUSDT | Linear Perpetual | USDT | 0.0001 |
| XRPUSDT | Linear Perpetual | USDT | 0.01 |
| BCHUSDT | Linear Perpetual | USDT | 0.00001 |
| XBTUSDT | Linear Perpetual | USDT | 0.000001 |
| ETHUSDT | Linear Perpetual | USDT | 0.00001 |
| LTCUSDT | Linear Perpetual | USDT | 0.0001 |
| ADAUSDT | Linear Perpetual | USDT | 0.01 |
| BNBUSDT | Linear Perpetual | USDT | 0.0001 |
| SHIBUSDT | Linear Perpetual | USDT | 1 |
| FTMUSDT | Linear Perpetual | USDT | 0.01 |
| DOTUSDT | Linear Perpetual | USDT | 0.001 |
| MATICUSDT | Linear Perpetual | USDT | 0.01 |
| SANDUSDT | Linear Perpetual | USDT | 0.001 |
| MANAUSDT | Linear Perpetual | USDT | 0.001 |
| ALTMEXTUSDT | Linear Perpetual | USDT | 0.0001 |
| DEFIMEXTUSDT | Linear Perpetual | USDT | 0.0001 |
| METAMEXTUSDT | Linear Perpetual | USDT | 0.0001 |
| LINKUSDT | Linear Perpetual | USDT | 0.001 |
| EOSUSDT | Linear Perpetual | USDT | 0.001 |
| AVAXUSDT | Linear Perpetual | USDT | 0.0001 |
| APEUSDT | Linear Perpetual | USDT | 0.001 |
| GMTUSDT | Linear Perpetual | USDT | 0.001 |
| NEARUSDT | Linear Perpetual | USDT | 0.001 |
| TRXUSDT | Linear Perpetual | USDT | 0.1 |
| GALUSDT | Linear Perpetual | USDT | 0.001 |
| LUNAUSDT | Linear Perpetual | USDT | 0.001 |
| XBT_USDT | Linear Spot | USDT | 0.00000001 |
| ETH_USDT | Linear Spot | USDT | 0.000000001 |
| APE_USDT | Linear Spot | USDT | 0.00000001 |
| AXS_USDT | Linear Spot | USDT | 0.00000001 |
| LINK_USDT | Linear Spot | USDT | 0.00000001 |
| MATIC_USDT | Linear Spot | USDT | 0.00000001 |
| UNI_USDT | Linear Spot | USDT | 0.00000001 |
Commission calculation parameters must be specified in the instrument attributes:
| Attribute name | Allowed values |
|---|---|
bitmexFutureType | INVERSE, LINEAR, QUANTO |
bitmexContractMultiplier | any floating point value |
bitmexCommissionCurrency | alphanumeric-compatible string value |
If any attribute is missing, the connector attempts to determine it from the instrument's broker symbol. If determination fails, all trading operations with that instrument will be rejected.
Replacement
BitMEX permits replacing fully filled orders; the connector prevents this internally.
Cancel all orders after
cancelAllOrdersAfter provides a "Dead Man's Switch" functionality to help prevent unexpected losses from network malfunctions. The client can send a request with a timeout (in seconds), that will start a countdown timer which will cancel all client orders on all symbols when the timer expires. https://www.bitmex.com/app/wsAPI#Dead-Mans-Switch-Auto-Cancel
Config block sample:
cancelAllOrdersAfter {
period = 30s
timeout = 60s
}
Symbology
Lists of available futures
and perpetuals.
Alternatively, retrieve all instruments via REST API Instrument requests.
Configuration
Connector settings
| Parameter | Default Value | Description |
|---|---|---|
| maxSyncBatchSize | 100 | Max number of orders to be requested within single order status request. |
| expireInterval | 5s | An interval after which the request is no longer valid. This is to prevent replay attacks. |
| submitExpireInterval | 2s | Request Expire Interval for submit and replace requests. If not specified, by default will be used expire interval above. |
| cancelExpireInterval | 10s | Request Expire Interval for cancel requests. If not specified, by default will be used expire interval above. |
| cancelAllOrdersAfter | not enabled | Has two settings: period, timeout. This feature can work like Cancel-On-Disconnect behavior. https://www.bitmex.com/app/wsAPI#Dead-Mans-Switch-Auto-Cancel |
Supported order attributes
| Key | Description |
|---|---|
| 18 | 6 value used for post only orders submission. |
Config sample
connectors {
BITMEX: ${template.connector.crypto.bitmex} {
settings {
restUrl = "https://www.bitmex.com/api/v1"
websocketUrl = "wss://www.bitmex.com/realtime"
apiKeys: [
{
apiKey = "API_KEY"
apiSecret = "API_SECRET"
}
]
}
}
}