Skip to main content

BitMEX Trade Connector

Features

crypto-bitmexConnector Key
Instruments
FUTUREFX
Request Types
SUBMITCANCELREPLACE
Order Types
MARKETLIMITSTOPSTOP_LIMIT
Time In Force
DAYGTCIOCFOK
Order ID Mapper
COMPOSITE
Order Status Request
Cancel On Disconnect
Commission
Post Only
Fast Cancel
Fast Replace

Notes

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 typeContractValueCommission
Inverse Futures and PerpetualsMultiplier / PriceContractValue * OrderQty * FeeRate
Quanto Futures and PerpetualsMultiplier * PriceContractValue * OrderQty * FeeRate
Linear Futures and PerpetualsMultiplier * PriceContractValue * OrderQty * FeeRate
Linear SpotsMultiplier * PriceContractValue * 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

ContractInstrument typeCommission currencyMultiplier
XBTmonth codeInverse FuturesBTC1
ETHUSDmonth code_ETHInverse FuturesETH1
XBTUSDInverse PerpetualBTC1
XBTEURInverse PerpetualBTC1
ETHUSD_ETHInverse PerpetualETH1
ETHUSDmonth codeQuanto FuturesBTC0.000001
ETHUSDQuanto PerpetualBTC0.000001
XRPUSDQuanto PerpetualBTC0.0002
BCHUSDQuanto PerpetualBTC0.000001
LTCUSDQuanto PerpetualBTC0.000002
DOGEUSDQuanto PerpetualBTC0.001
BNBUSDQuanto PerpetualBTC0.000001
ADAUSDQuanto PerpetualBTC0.0001
DOTUSDQuanto PerpetualBTC0.00001
AVAXUSDQuanto PerpetualBTC0.00001
LINKUSDQuanto PerpetualBTC0.00001
SOLUSDQuanto PerpetualBTC0.000001
EOSUSDQuanto PerpetualBTC0.0001
AXSUSDQuanto PerpetualBTC0.000001
GMTUSDQuanto PerpetualBTC0.0001
NEARUSDQuanto PerpetualBTC0.0001
APEUSDQuanto PerpetualBTC0.00001
TRXUSDQuanto PerpetualBTC0.001
GALUSDQuanto PerpetualBTC0.0001
LUNAUSDQuanto PerpetualBTC0.0001
ADAmonth codeLinear FuturesBTC0.01
ETHmonth codeLinear FuturesBTC0.00001
XRPmonth codeLinear FuturesBTC0.01
XBTUSDTmonth codeLinear FuturesUSDT0.000001
ETHUSDTmonth codeLinear FuturesUSDT0.00001
DOGEUSDTLinear PerpetualUSDT0.01
SOLUSDTLinear PerpetualUSDT0.0001
XRPUSDTLinear PerpetualUSDT0.01
BCHUSDTLinear PerpetualUSDT0.00001
XBTUSDTLinear PerpetualUSDT0.000001
ETHUSDTLinear PerpetualUSDT0.00001
LTCUSDTLinear PerpetualUSDT0.0001
ADAUSDTLinear PerpetualUSDT0.01
BNBUSDTLinear PerpetualUSDT0.0001
SHIBUSDTLinear PerpetualUSDT1
FTMUSDTLinear PerpetualUSDT0.01
DOTUSDTLinear PerpetualUSDT0.001
MATICUSDTLinear PerpetualUSDT0.01
SANDUSDTLinear PerpetualUSDT0.001
MANAUSDTLinear PerpetualUSDT0.001
ALTMEXTUSDTLinear PerpetualUSDT0.0001
DEFIMEXTUSDTLinear PerpetualUSDT0.0001
METAMEXTUSDTLinear PerpetualUSDT0.0001
LINKUSDTLinear PerpetualUSDT0.001
EOSUSDTLinear PerpetualUSDT0.001
AVAXUSDTLinear PerpetualUSDT0.0001
APEUSDTLinear PerpetualUSDT0.001
GMTUSDTLinear PerpetualUSDT0.001
NEARUSDTLinear PerpetualUSDT0.001
TRXUSDTLinear PerpetualUSDT0.1
GALUSDTLinear PerpetualUSDT0.001
LUNAUSDTLinear PerpetualUSDT0.001
XBT_USDTLinear SpotUSDT0.00000001
ETH_USDTLinear SpotUSDT0.000000001
APE_USDTLinear SpotUSDT0.00000001
AXS_USDTLinear SpotUSDT0.00000001
LINK_USDTLinear SpotUSDT0.00000001
MATIC_USDTLinear SpotUSDT0.00000001
UNI_USDTLinear SpotUSDT0.00000001

Commission calculation parameters must be specified in the instrument attributes:

Attribute nameAllowed values
bitmexFutureTypeINVERSE, LINEAR, QUANTO
bitmexContractMultiplierany floating point value
bitmexCommissionCurrencyalphanumeric-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

ParameterDefault ValueDescription
maxSyncBatchSize100Max number of orders to be requested within single order status request.
expireInterval5sAn interval after which the request is no longer valid. This is to prevent replay attacks.
submitExpireInterval2sRequest Expire Interval for submit and replace requests. If not specified, by default will be used expire interval above.
cancelExpireInterval10sRequest Expire Interval for cancel requests. If not specified, by default will be used expire interval above.
cancelAllOrdersAfternot enabledHas 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

KeyDescription
186 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"
}
]
}
}
}