Huobi Futures Trade Connector
Features
crypto-huobifutConnector KeyNotes
Rate Limits
The private API rate limit is 48 requests per 3 seconds per UID (24 for trade operations, 24 for read operations). This limit is shared across all altcoin contracts.
See the Huobi documentation for details:
- Futures: https://huobiapi.github.io/docs/dm/v1/en/#api-rate-limit-illustration
- Swap: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#api-rate-limit-illustration
Offset
Huobi Futures and Swap require an Offset parameter with each order to specify the order type.
Default offset is configured via defaultOffset. It can be overridden per order using the 6470 (Offset) attribute.
| Order type | Transaction Direction | Offset |
|---|---|---|
| Open Long | BUY | open |
| Close Long | SELL | close |
| Open Short | SELL | open |
| Close Short | BUY | close |
Important: Huobi Swap USDT in One-Way mode requires Offset = both.
Post Only
In Huobi Futures and Swap APIs Post Only orders are represented via Huobi Time In Force.
When Post Only flag is defined in an order request, it takes precedence over the specified Time In Force.
I.e. if Post Only flag is present - request's Time In Force is ignored and order will be placed as Post Only.
Errors
List of possible errors can be obtained from the Huobi documentation:
- Futures: https://huobiapi.github.io/docs/dm/v1/en/#details-of-each-error-code
- Swap: https://huobiapi.github.io/docs/coin_margined_swap/v1/en/#details-of-each-error-code
Huobi Swap
Huobi Swap uses the same API format as Huobi Futures but with different REST and WebSocket URLs. See the Config Sample section to configure the connector for Huobi Swap.
Huobi Swap USDT
Huobi Swap USDT uses the same API format as Huobi Futures but with different REST and WebSocket URLs. See the Config Sample section to configure the connector for Huobi Swap USDT.
Margin Mode
Configure the Margin Mode for Huobi Swap USDT via the marginMode connector setting. The connector operates in one Margin Mode at a time — CROSS and ISOLATED orders cannot be sent simultaneously.
Symbology
Huobi Futures symbols use the Contract Code format: base currency code followed by expiration date (no separator), e.g. BTC201225, ETH200925.
Full list of supported contracts can be retrieved via public REST API:
- Futures: https://api.hbdm.com/api/v1/contract_contract_info
- Swap: https://api.hbdm.com/swap-api/v1/swap_contract_info
- Swap USDT: https://api.hbdm.com/linear-swap-api/v1/swap_contract_info
Configuration
Connector settings
| Parameter | Default Value | Description |
|---|---|---|
| defaultLeverage | 10 | Default value for 6001 (LeverageRate) attribute. |
| defaultOffset | OPEN | Default value for 6470 (Offset) attribute. |
| marginMode | Margin mode for Huobi Swap USDT connector. Possible values: CROSS, ISOLATED. | |
| huobiFuturesSyncSettings.ordersRequestPageSize | 50 | Limitation for the number of orders in one open orders response. Maximum value is 50. |
| huobiFuturesSyncSettings.tradesRequestPageSize | 50 | Limitation for the number of trades in one trades history response. Maximum value is 50. |
| huobiFuturesSyncSettings.ordersBatchRequestSizeLimit | 50 | Limitation for the number of orders in the orders status batch request. Maximum value is 50. |
| huobiFuturesSyncSettings.historicalDataDaysPeriod | 1 | The number of days to query for historical trades data. Maximum value is 90. It is highly recommended from exchange to use 1 day period in the requests. |
Supported order attributes
| Key | Description |
|---|---|
| 18 | 18 (PostOnly) attribute relevant only for LIMIT orders with Good Till Cancel time in force. Switches between post_only and limit order price type. Possible values: 6. |
| 6001 | All orders should have 6001 (LeverageRate) attribute to determine order leverage rate. Default value can be specified with defaultLeverage configuration parameter. |
| 6470 | All orders should have 6470 (Offset) attribute to determine offset direction. Default value can be specified with defaultOffset configuration parameter. Possible values: OPEN, CLOSE or BOTH. See Offset section for detailed explanation. |
Config sample
include classpath("crypto-connectors.conf")
connectors {
HUOBIFUT: ${template.connector.crypto.huobifut} {
settings {
restUrl = "https://api.hbdm.com"
websocketUrl = "wss://api.hbdm.com/notification"
apiKeys: [
{
apiKey = "<API_KEY>"
apiSecret = "<API_SECRET>"
}
]
}
}
HUOBISWP: ${template.connector.crypto.huobiswp} {
settings {
restUrl = "https://api.hbdm.com"
websocketUrl = "wss://api.hbdm.com/swap-notification"
apiKeys: [
{
apiKey = "<API_KEY>"
apiSecret = "<API_SECRET>"
}
]
}
}
HUOBISWPT: ${template.connector.crypto.huobiswpt} {
settings {
restUrl = "https://api.hbdm.com"
websocketUrl = "wss://api.hbdm.vn/linear-swap-notification"
marginMode = "ISOLATED" # or "CROSS"
apiKeys: [
{
apiKey = "<API_KEY>"
apiSecret = "<API_SECRET>"
}
]
}
}
}