Navbar
简体中文
shell

Introduction

Documentation Summary

Welcome to the HuobiDM API! You can use our API to access all market data, trading, and account management endpoints.

We have code example in Shell! You can view code examples in the dark area to the right.

You can use the drop down list above to change the API version. You can also use the language option at the top right to switch documentation language.

Market Maker Program

Market maker program gives clients with good market making strategy an opportunity to access customized trading fee structure.

Eligibility Criteria as a Market Maker on HuobiDM

  1. You should possess good market strategy
  2. You must have at least 3 BTC or equivalent assets, not including rebates in your account with HuobiDM

Application Process as Market Maker on Huobidm

If you satisfied our eligibility criteria and is interested to participate in our market-making project, please email to MM_service@huobi.com with following information:

  1. UIDs (not linked to any rebate program in any accounts)
  2. Provide screenshot of trading volume for the past 30 days or VIP/corporate status with other Exchanges
  3. A brief description in writing of your market-making strategy

Changelog

1.0.7

1、Modified rest interface: Order details acquisition

The request parameter“created_at”in rest interface “Order details acquisition” (URL: api/v1/contract_order_detail) was changed from “true” to “false”under Mandatory.

2、 Modified rest interface: User’s Account Information

Added return string “margin_static”in rest interface User’s Account Information (URL: api/v1/contract_account_info). The newly added return string “margin_static” in data array means account static equity.

3、 Added string “ID “in three interfaces;

Added string“ID”in rest interface Order details acquisition (URL: api/v1/contract_order_detail) , rest interface Acquire History Match Results (URL: api/v1/contract_matchresults) as well as the match result on Order Push in WebSocket Subscription.

4、Added “IOC”and “FOK order types for order placement

Added order_price_type “ioc”(ioc:Immediate Or Cancel) and “fok”(fok:Fill Or Kill)under Request Parameter in rest interface Place an Order(URL: api/v1/contract_order) and rest interface Place a Batch of Orders(URL: api/v1/contract_batchorder)

5、Modified interface: Query contract information on order limit

Added “fok”:FOK Order(fok:Fill Or Kill),“ioc”:IOC Order(ioc:Immediate Or Cancel) into string of“ order_price_type” in Returning Parameter under rest interface Query contract information on order limit (URL: api/v1/contract_order_limit)

The“ order_price_type” means Order Type here.

6、Added rest API interface: Query information on system status

Interface URL: api/v1/contract_api_state

7、 Added rest interface: Top Trader Sentiment Index Function-Account

Interface URL: api/v1/contract_elite_account_ratio

8、Added rest interface: Top Trader Sentiment Index Function-Position

Interface URL: api/v1/contract_elite_position_ratio

9、Added Liquidation order query function in API and WS subscription.

Added rest interface: Request Liquidation Order Information

Interface URL: rest interface api/v1/contract_liquidation_orders

Liquidation order push is added also into WebSocket Subscription.

1.0.6 API Upgrade: added rest interface

Added rest interface

Request access to address: https://www.hbdm.com/heartbeat

Note: To query whether the system is available or not, request https://www.hbdm.com/heartbeat. When Heartbeat is 1, system is available; when Heartbeat is 0, system is unavailable.

1.0.5 API Upgrade: New Features of Query and Order Placing

Newly Added API Restful Interface

Newly added Interface: query user’s order limit information

Newly added Interface: query user’s trading fee information

Newly added Interface: query user’s transfer limit information

Newly added Interface: query users’ position limit information

Newly added Interface: query platform information on insurance fund and estimated clawback rate

Newly added Interface: query platform information on open interest information

Newly added Interface: query history records information on insurance fund

Newly added Interface: query platform information on Tiered Adjustment Factor

Newly added Interface: place Flash Close order

Modified API Interface

Restful interface: add “return to users’ adjustment factor” on Query Users’ Account Information Interface;

Restful interface: add “return to users’ adjustment factor” on Query a Single Sub-Account’s Assets Information Interface.

WebSocket Interface: add “return to users’ adjustment factor” on WebSoket Portfolio Push Interface;

Restful Interface: add Optimal price set with optimal top 5, optimal 10 and optimal top 20 on Order Place Interface and Place a Batch of Orders Interface

Restful Interface: add “query according contract code” on Acquire History of Match Results Interface.

1.0.4 API Upgrade:Restful interface

Query assets information of all sub-accounts under the master account

URL:api/v1/contract_sub_account_list

Notice: Only return data for activated contract sub-account (i.e. sub-accounts that have gained contract trading permission).

Query a single sub-account's assets information

URL:api/v1/contract_sub_account_info

Notice: Only query account information for activated contract sub-account (i.e. sub-accounts that have gained contract trading permission); No data return for sub-accounts which has logged in hbdm but have not gained trading permission/activated.

Query a single sub-account's position information

URL:api/v1/contract_sub_position_info

Query account financial records

URL:api/v1/contract_financial_record

1.0.3 API Upgrade: WebSocket Portfolio Push

WebSoket balance push is available:

users could subscribe the interface to get information of their balances automatically.

WebSoket position push is available:

users could subscribe the interface to get information of their positions automatically.

Acuqire positions information via Restful interface:

api/v1/contract_position_info.

The string of “latest price”is added into response

1.0.2 API Upgrade: Transfer margin between Spot account and Future account

URL /v1/futures/transfer

This interface is used to transfer assets between Spot account and Future account.

The type is “pro-to-futures” when transferring assets from Spot account to Future; “futures-to-pro” when transferring from Future account to Spot account.

API rate limit for this interface is up to 10 times per minute.

API rate limit

Private interface rate limit has been increased from 10 times/second to 30 times every 3 seconds, which means users could send up to 30 requests within 3 seconds.

The rate limit of other non-market public interface has been increased from 20 times/second to 60 times every 3 seconds, which means users could send up to 60 requests within 3 seconds.

1.0.1 API Upgrade: Post_only and more

Cancel all interface: URL api/v1/contract_cancelall

Send symbol to cancel all the contracts of that kind of symbol, e.g. send “BTC” to cancel all BTC weekly, biweekly and quarterly contracts.

Send contract_code to cancel the contracts of that code.

Send symbol+contract_type to cancel the certain contracts under the symbol of that contract_type, e.g. send “BTC” and “this week”, then the BTC weekly contracts will be cancelled.

Order place interface: URL api/v1/contract_order

Post_only is added into the string of order_price_type.

Description of post_only: assure that the maker order remains as maker order, it will not be filled immediately with the use of post_only, for the match system will automatically check whether the price of the maker order is higher/lower than the opponent first price, i.e. higher than bid price 1 or lower than the ask price 1. If yes, the maker order will placed on the orderbook, if not, the maker order will be cancelled.

Position limit will be applied to post_only while order limit will not.

Place a batch of orders: URL /v1/contract_batchorder

Post_only is added into the string of order_price_type.

Description of post_only: assure that the maker order remains as maker order, it will not be filled immediately with the use of post_only, for the match system will automatically check whether the price of the maker order is higher/lower than the opponent first price, i.e. higher than bid price 1 or lower than the ask price 1. If yes, the maker order will placed on the orderbook, if not, the maker order will be cancelled.

Position limit will be applied to post_only while order limit will not.

Will response following string for "header" via api

ratelimit-limit: the upper limit of requests per time, unit: time

ratelimit-interval: reset interval (reset the number of request), unit: ms

ratelimit-remaining: the left available request number for this round, unit: time

ratelimit-reset: upper limit of reset time used to reset request number, unit: ms

Order details acquisition: URL api/v1/contract_order_detail

The string of “role” (i.e. taker or maker) is added into “trades”

Acquire history of match results: URL api/v1/contract_matchresults

The string of “role” (i.e. taker or maker) is added into “trades

WebSoket, the private order push interface, requires API KEY Verification

Each UID can build at most create 10 WS connections for private order push at the same time. For each account, contracts of the same underlying coin only need to subscribe one WS order push, e.g. users only need to create one WS order push connection for BTC Contract which will automatically push orders of BTC weekly, BTC biweekly and BTC quarterly contracts.

Please note that the rate limit of WS order push and RESTFUL private interface are separated from each other, with no relations.

1.0.0 has launched on December 10, 2018

Huobi Derivative Market (HBDM) API Access Illustration

API List

permission type Content Type Context Request Type Desc Signature Required
Read Market Data api/v1/contract_contract_info GET Get Contracts Information No
Read Market Data api/v1/contract_index GET Get contract Index Price Information No
Read Market Data api/v1/contract_price_limit GET Get Contract Price Limits No
Read Market Data api/v1/contract_open_interest GET Get Contract Open Interest Information No
Read Market Data api/v1/contract_delivery_price GET Get the estimated delivery price No
Read Market Data https://www.hbdm.com/heartbeat GET Query whether the system is available No
Read Market Data api/v1/contract_api_state GET Query information on system status No
Read Market Data /market/depth GET Get Market Depth No
Read Market Data /market/history/kline GET Get K-Line Data No
Read Market Data /market/detail/merged GET Get Market Data Overview No
Read Market Data /market/trade GET The Last Trade of a Contract No
Read Market Data /market/history/trade GET Request a Batch of Trade Records of a Contract No
Read Market Data api/v1/contract_risk_info GET Query information on contract insurance fund balance and estimated clawback rate No
Read Market Data api/v1/contract_insurance_fund GET Query history records of insurance fund balance No
Read Market Data api/v1/contract_adjustfactor GET Query information on Tiered Adjustment Factor No
Read Market Data api/v1/contract_his_open_interest GET Query information on open interest No
Read Market Data api/v1/contract_elite_account_ratio GET Top Trader Sentiment Index Function-Account No
Read Market Data api/v1/contract_elite_position_ratio GET Top Trader Sentiment Index Function-Position No
Read Market Data api/v1/api/v1/contract_liquidation_orders GET Request Liquidation Order Information No
Read Account api/v1/contract_account_info POST User’s Account Information Yes
Read Account api/v1/contract_position_info POST User’s position Information Yes
Read Account api/v1/contract_sub_account_list POST Query assets information of all sub-accounts under the master account (Query by coins) Yes
Read Account api/v1/contract_sub_account_info POST Query a single sub-account's assets information Yes
Read Account api/v1/contract_sub_position_info POST Query a single sub-account's position information Yes
Read Account api/v1/contract_financial_record POST Query account financial records Yes
Read User Account api/v1/contract_order_limit POST Query contract information on order limit Yes
Read User Account api/v1/contract_fee POST Query information on contract trading fee Yes
Read User Account api/v1/contract_transfer_limit POST Query information on Transfer Limit Yes
Read User Account api/v1/contract_position_limit POST Query information on position limit Yes
Trade Trade api/v1/contract_order POST Place an Order Yes
Trade Trade api/v1/contract_batchorder POST Place a Batch of Orders Yes
Trade Trade api/v1/contract_cancel POST Cancel an Order Yes
Trade Trade api/v1/contract_cancelall POST Cancel All Orders Yes
Trade Trade api/v1/lightning_close_position POST Place Flash Close Order Yes
Read User Order Info api/v1/contract_order_info POST Get Information of an Order Yes
Read User Order Info api/v1/contract_order_detail POST Get Trade Details of an Order Yes
Read User Order Info api/v1/contract_openorders POST Get Current Orders Yes
Read User Order Info api/v1/contract_hisorders POST Get History Orders Yes
Read User Order Info api/v1/contract_matchresults POST Acquire History Match Results Yes
Trade User Account v1/futures/transfer POST Transfer margin between Spot account and Future account Yes

Address

Address Applicable sites Applicable functions Applicable trading pairs
https://api.hbdm.com Huobi DM Market Trading pairs provided by Huobi DM

Notice

If you can't connect "https://api.hbdm.com", please use "https://api.btcgateway.pro".

Signature Authentication & Verification

Signature Illustration

Considering that API requests may get tampered in the process of transmission, to keep the transmission secure, you have to use your API Key to do Signature Authentication for all private interface except for public interface (used for acuqiring basic information and market data), in this way to verify whether the parameters/ parameter value get tampered or not in the process of transmission

A legitimate request consists of following parts:

Create API Key

You could create API Key at

API Key consists of the following two parts.

Steps for Signature

Normative request for Signature calculation Different contents will get totally different results when use HMAC to calculate Signature, therefore, please normalize the requests before doing Signature calculation. Take the request of inquering order details as an example:

query details of one order

https://api.hbdm.com/api/v1/contract_order?

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

&SignatureMethod=HmacSHA256

&SignatureVersion=2

&Timestamp=2017-05-11T15:19:30

1. Request methods (GET/POST): add line breaker "\n".

POST\n

2. Text the visit address in lowercase, adding line breake "\n"

api.hbdm.com\n

3. Visit the path of methods, adding line breaker "\n"

/api/v1/contract_order\n

4. Rank the parameter names according to the sequence of ASCII codes, for example, below is the parameters in original sequence and the new sequence:

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

SignatureMethod=HmacSHA256

SignatureVersion=2

Timestamp=2017-05-11T15%3A19%3A30

5. After ranking

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx

SignatureMethod=HmacSHA256

SignatureVersion=2

Timestamp=2017-05-11T15%3A19%3A30

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30

7. Form the final character strings that need to do Signature calculation as following:

POST\n

api.hbdm.com\n

/api/v1/contract_order\n

AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30

8. Use the "request character strings" formed in the last step and your Secret Key to create a digital Signature.

4F65x5A2bLyMWVQj3Aqp+B4w+ivaA7n5Oi2SuYtCJ9o=

  1. Take the request character string formed in the last step and API Secret Key as two parameters, encoding them with the Hash Function HmacSHA256 to get corresponding Hash value.

  2. Encoding the Hash value with base-64 code, the result will be the digital Signature of this request.

9. Add the digital Signature into the parameters of request path.

The final request sent to Server via API should be like:

https://api.hbdm.com/api/v1/contract_order?AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&order-id=1234567890&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30&Signature=4F65x5A2bLyMWVQj3Aqp%2BB4w%2BivaA7n5Oi2SuYtCJ9o%3D

  1. Add all the must authentication parameters into the parameters of request path;

  2. Add the digital Signature encoded with URL code into the path parameters with the parameter name of "Signature".

API Rate Limit Illustration

Please note that, for both public interface and private interface, there are rate limits, more details are as below:

Query whether the system is available

Response:


  {
  "status": "ok",
  "data": {"heartbeat": 1},
  "ts": 1557714418033,
  }

Details of Each Error Code

Error Code Error Details Description
403 invalid ID
1000 system exception
1001 system not on deck
1002 query exception
1003 redis operation exception
1010 user not existing
1011 user session not exists
1012 user account not exists
1013 contract type not exists
1014 contract not exists
1015 index price not exists
1016 BBO price not exists
1017 query order not exists
1030 input error
1031 illegal order source
1032 beyond visit limits
1033 wrong field value of contract period
1034 wrong field value of order type
1035 wrong field value of order direction
1036 wrong closing/opening field value of orders
1037 invalid leverage ratio
1038 order price beyond the requirement of minimum variable price
1039 order price beyond the limits
1040 illegal order quantity
1041 order quantity beyond limits
1042 long positions beyond limits
1043 short positions beyond limits
1044 beyond position limits
1045 leverage ratio not in accordance with the leverage ratio of open positions
1046 uninitialized open positions
1047 lack of available margin
1048 lack of open positions
1050 repeated order id
1051 no orders could be withdrawed
1052 beyond the limits of bacth order quantity
1053 cannot acquire contracts' latest price range
1054 cannot acquire contracts' latest
1055 cannot close positions for lack of equity
1056 cannot place or withdraw orders during settlement
1057 cannot place or withdraw orders during trading pause
1058 cannot place or withdraw orders when trading suspended
1059 cannot place or withdraw orders during delivery
1060 cannot place or withdraw orders under no-trading status
1061 cannot withdraw not existed orders
1062 cannot repeatedly withdraw orders when in withdrawing status
1063 cannot withdraw filled orders
1064 order primary key duplication
1065 user's order id is not integer
1066 do not leave the field blank
1067 illegal fields
1068 output error
1069 illegal order price
1100 users do not have rights to open positions
1101 users do not have rights to close positions
1102 users do not have rights to deposit
1103 users do not have rights to withdraw
1104 without contract trading permission, you are banned to trade
1105 with current contract trading permission, you are only allowed to close positions
1200 login error
1220 user has not onboarded Huobi DM or activate the account
1221 lack of margin to open account
1222 insufficient account opening days
1223 account VIP level not high enough
1224 account registration place restricted
1225 unsuccessful account opening
1250 token cannot acquire HT_token
1251 cannot acquire BTC equivalent assets
1252 cannot acquire spot assets
1071 The order has been cancelled, please do not cancel orders repeatedly
1077 failed query of current contract assets during settlement and delivery
1078 failed query of partial contracts' assets during settlement and delivery
1079 failed query of current contract open positions during settlement and delivery
1080 failed query of partial contract assets during settlement and delivery
1083 Error detected, Order closing failed.

Code Demo

REST

Websocket

HuobiDM Market Data interface

Get Contract Info

Example

curl "https://api.hbdm.com/api/v1/contract_contract_info"      

Request Parameter

Parameter Name Type Mandatory Description
symbol string false "BTC","ETH"...
contract_type string false "this_week","next_week", "quarter"
contract_code string false BTC180914

Note:

Note:If there is a number in the Contract Code row,inquiry with Contract_Code. If there is no number,inquiry by Symbol + Contract Type. One of the query conditions must be chosen.

Response

{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "contract_code": "BTC180914",
      "contract_type": "this_week",
      "contract_size": 100,
      "price_tick": 0.001,
      "delivery_date": "20180704",
      "create_date": "20180604",
      "contract_status": 1
     }
    ],
  "ts":158797866555
}

Returning Parameter

Parameter Name Mandatory Type Description Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: data)
symbol true string Product Code "BTC","ETH"...
contract_code true string Contract Code "BTC180914" ...
contract_type true string Contract Type "this_week","next_week", "quarter"
contract_size true decimal Contract Value (USD of one contract) 10, 100...
price_tick true decimal Minimum Variation of Contract Price 0.001, 0.01...
delivery_date true string Contract Delivery Date eg "20180720"
create_date true string Contract Listing Date eg "20180706"
contract_status true int Contract Status 0: Delisting,1: Listing,2: Pending Listing,3: Suspension,4: Suspending of Listing,5: In Settlement,6: Delivering,7: Settlement Completed,8: Delivered,9: Suspended Listing
</list>
ts true long Time of Respond Generation,Unit:Millisecond

Get Contract Index Price Information

Example

curl "https://api.hbdm.com/api/v1/contract_index?symbol=BTC" 

Request Parameter

Parameter Name Parameter Type Mandatory Desc
symbol string true "BTC","ETH"...

Response

{
  "status":"ok",
  "data": [
     {
       "symbol": "BTC",
       "index_price":471.0817
      }
    ],
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: data)
symbol true string symbol "BTC","ETH"...
index_price true decimal Index Price
</list>
ts true long Time of Respond Generation,Unit:Millisecond

Contract Price Limitation

Example

curl "https://api.hbdm.com/api/v1/contract_price_limit?symbol=BTC&contract_type=this_week"

Request Parameter

Parameter Name Parameter Type Mandatory Desc
symbol string false "BTC","ETH"...
contract_type string false Contract Type ("this_week","next_week","quarter")
contract_code string false BTC180914 ...

Note :

If there is a number in the Contract Code row,inquiry with Contract_Code. If there is no number,inquiry by Symbol + Contract Type. One of the query conditions must be chosen.

Response

{
  "status":"ok",
  "data": 
    {
      "symbol":"BTC",
      "high_limit":443.07,
      "low_limit":417.09,
      "contract_code":"BTC180914",
      "contract_type":"this_week"
     },
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" ,"error"
<list>(Attribute Name: data)
symbol true string Variety code "BTC","ETH" ...
high_limit true decimal Highest Buying Price
low_limit true decimal Lowest Selling Price
contract_code true string Contract Code eg "BTC180914" ...
contract_type true string Contract Type "this_week","next_week","quarter"
<list>
ts true long Time of Respond Generation, Unit: Millisecond

Get Contract Open Interest Information

Example

curl "https://api.hbdm.com/api/v1/contract_open_interest?symbol=BTC&contract_type=this_week"

Request Parameter

Parameter Name Parameter Type Mandatory Desc
symbol string false "BTC","ETH"...
contract_type string false Contract Type ("this_week","next_week","quarter")
contract_code string false BTC180914

Response:

{
  "status":"ok",
  "data":
    [{
      "symbol":"BTC",
      "contract_type": "this_week",
      "volume":123,
      "amount":106,
      "contract_code": "BTC180914"
     }],
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: data)
symbol true string Variety code "BTC", "ETH" ...
contract_type true string Contract Type "this_week","next_week","quarter"
volume true decimal Position quantity(amount)
amount true decimal Position quantity(Currency)
contract_code true string Contract Code eg "BTC180914" ...
</list>
ts true long Time of Respond Generation, Unit: Millisecond

Get the estimated delivery price

Example

curl "https://api.hbdm.com/api/v1/contract_delivery_price?symbol=BTC"

Request Parameter

Parameter Name Parameter Type Mandatory Desc
symbol string true "BTC","ETH"...

Response:

Response:

    {
      "status":"ok",
      "data":
        {
          "delivery_price": 3806.4615259197324414715719     
         },
      "ts": 1490759594752
    }

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: data)
delivery_price true string estimated delivery price
</list>
ts true long Time of Respond Generation, Unit: Millisecond

Get Market Depth

Example

curl "https://api.hbdm.com/market/depth?symbol=BTC_CQ&type=step5"

Request Parameter

Parameter Name Parameter Type Mandatory Desc
symbol string true e.g. "BTC_CQ" represents BTC “This Week”,"BTC_CQ" represents BTC “Next Week”,"BTC_CQ" represents BTC “Quarter”
type string true ( 150 depth data)step0, step1, step2, step3, step4, step5(merged deep data 0-5);when step is 0,deep data will not be merged; (20 depth data) step6, step7, step8, step9, step10, step11(merged deep data 7-11); when step is 6, deep data will not be merged.

tick illustration:

"tick": {
    "id": Message id.
    "ts": Time of Message Generation, unit: millisecond
    "bids": Buying, [price(hanging unit price), vol(this price represent single contract)], According to the descending order of Price
    "asks": Selling, [price(hanging unit Price), vol(this price represent single contract)], According to the ascending order of Price  
    }

Response:

{
  "ch":"market.BTC_CQ.depth.step5",
  "status":"ok",
    "tick":{
      "asks":[
        [6580,3000],
        [70000,100]
        ],
      "bids":[
        [10,3],
        [2,1]
        ],
      "ch":"market.BTC_CQ.depth.step5",
      "id":1536980854,
      "mrid":6903717,
      "ts":1536980854171,
      "version":1536980854
    },
  "ts":1536980854585
}

Returning Parameter

Parameter Name Mandatory Data Type Desc Value Range
ch true string Data belonged channel,Format: market.period
status true string Request Processing Result "ok" , "error"
asks true object Selling, [price(hanging unit Price), vol(this price represent single contract)], According to the ascending order of Price
bids true object Buying, [price(hanging unit price), vol(this price represent single contract)], According to the descending order of Price
ts true number Time of Respond Generation,Unit:Millisecond

Get K-Line Data

Example

curl "https://api.hbdm.com/market/history/kline?period=1min&size=200&symbol=BTC_CQ"

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol true string Contract Name e.g. "BTC_CQ" represents BTC “This Week”,"BTC_CQ" represents BTC “Next Week”,"BTC_CQ" represents BTC “Quarter”
period true string K-Line Type 1min, 5min, 15min, 30min, 60min, 1hour,4hour,1day, 1mon
size false integer Acquisition Quantity 150 [1,2000]

Data Illustration:

"data": [
  {
        "id": K-Line id,
        "vol": Transaction Volume(amount),
        "count": transaction count
        "open": opening Price
        "close": Closing Price, when the K-line is the latest one,it means the latest price
        "low": Lowest price
        "high": highest price
        "amount": transaction volume(currency), sum(every transaction volume(amount)*every contract value/transaction price for this contract)
   }
]

Response:

{
  "ch": "market.BTC_CQ.kline.1min",
  "data": [
    {
      "vol": 2446,
      "close": 5000,
      "count": 2446,
      "high": 5000,
      "id": 1529898120,
      "low": 5000,
      "open": 5000,
      "amount": 48.92
     },
    {
      "vol": 0,
      "close": 5000,
      "count": 0,
      "high": 5000,
      "id": 1529898780,
      "low": 5000,
      "open": 5000,
      "amount": 0
     }
   ],
  "status": "ok",
  "ts": 1529908345313
}

Returning Parameter

Parameter Name Mandatory Data Type Desc Value Range
ch true string Data belonged channel,Format: market.period
data true object KLine Data
status true string Request Processing Result "ok" , "error"
ts true number Time of Respond Generation, Unit: Millisecond

Get Market Data Overview

Example

curl "https://api.hbdm.com/market/detail/merged?symbol=BTC_CQ"

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol true string Contract Name e.g. "BTC_CQ" represents BTC “This Week”,"BTC_CQ" represents BTC “Next Week”,"BTC_CQ" represents BTC “Quarter”

tick Illustration:

"tick": {
    "id": K-Line id,
    "vol": transaction volume(contract),
    "count": transaction count
    "open": opening price,
    "close": Closing Price, when the K-line is the latest one,it means the latest price
        "low": Lowest price
        "high": highest price
        "amount": transaction volume(currency), sum(every transaction volume(amount)*every contract value/transaction price for this contract)
    "bid": [price of buying one (amount)],
    "ask": [price of selling one (amount)]

  }

Response:

{
  "ch": "market.BTC_CQ.detail.merged",
  "status": "ok",
  "tick": 
    {
      "vol":"13305",
      "ask": [5001, 2],
      "bid": [5000, 1],
      "close": "5000",
      "count": "13305",
      "high": "5000",
      "id": 1529387841,
      "low": "5000",
      "open": "5000",
      "ts": 1529387842137,
      "amount": "266.1"
     },
  "ts": 1529387842137
}

Returning Parameter

Parameter Name Mandatory Data Type Desc Value Range
ch true string Data belonged channel,format: market.$symbol.detail.merged
status true string Request Processing Result "ok" , "error"
tick true object K-Line Data
ts true number Time of Respond Generation, Unit: Millisecond

The Last Trade of a Contract

Example

curl "https://api.hbdm.com/market/trade?symbol=BTC_CQ"

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol true string Contract Name e.g. "BTC_CQ" represents BTC “This Week”,"BTC_CQ" represents BTC “Next Week”,"BTC_CQ" represents BTC “Quarter”

Tick Illustration:

"tick": {
  "id": Message id,
  "ts": Latest Transaction time,
  "data": [
    {
      "id": Transaction id,
      "price": Transaction price,
      "amount": transaction amount,
      "direction": Active transaction direction,
      "ts": transaction time

    }
  ]
}

Response:

{
  "ch": "market.BTC_CQ.trade.detail",
  "status": "ok",
  "tick": {
    "data": [
      {
        "amount": "1",
        "direction": "sell",
        "id": 6010881529486944176,
        "price": "5000",
        "ts": 1529386945343
       }
     ],
    "id": 1529388202797,
    "ts": 1529388202797
    },
  "ts": 1529388202797
}

Returning Parameter

Parameter Name Mandatory Type Desc Default Value Range
ch true string Data belonged channel,Format: market.$symbol.trade.detail
status true string "ok","error"
tick true object Trade Data
ts true number Sending time

Request a Batch of Trade Records of a Contract

Example

curl "https://api.hbdm.com/market/history/trade?symbol=BTC_CQ&size=100"

Request Parameter

Parameter Name Mandatory Data Type Desc Default Value Range
symbol true string Contract Name e.g. "BTC_CQ" represents BTC “This Week”,"BTC_CQ" represents BTC “Next Week”,"BTC_CQ" represents BTC “Quarter”
size false number Number of Trading Records Acquisition 1 [1, 2000]

data Illustration:

"data": {
  "id": Message id,
  "ts": Latest transaction time,
  "data": [
    {
      "id": Transaction id,
      "price": transaction price,
      "amount": transaction (amount),
      "direction": active transaction direction
      "ts": transaction time
      }
}

Response:

{
  "ch": "market.BTC_CQ.trade.detail",
  "status": "ok",
  "ts": 1529388050915,
  "data": [
    {
      "id": 601088,
      "ts": 1529386945343,
      "data": [
        {
         "amount": 1,
         "direction": "sell",
         "id": 6010881529486944176,
         "price": 5000,
         "ts": 1529386945343
         }
       ]
    }
   ]
}

Returning Parameter

Parameter Name Mandatory Data Type Desc Value Range
ch true string Data belonged channel,Format: market.$symbol.trade.detail
data true object Trade Data
status true string "ok","error"
ts true number Time of Respond Generation, Unit: Millisecond

Query information on contract insurance fund balance and estimated clawback rate

curl "https://api.hbdm.com/api/v1/contract_risk_info"

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol false string Contract Type "BTC","ETH"...,If no data detected, system will return to all contracts by default.

Response:

{
  "status": "ok",
  "ts": 158797866555,
  "data": [
    {
      "symbol": "ETH",
      "insurance_fund": 3806.4615259197324414715719,
      "estimated_clawback": 0.0023
    }
  ]
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: milesecond
<data>
symbol true string Contract Code "BTC","ETH"...
insurance_fund true decimal Insurance Fund Balance
estimated_clawback true decimal Estimated Clawback Rate
</data>

Query history records of insurance fund balance

curl "https://api.hbdm.com/api/v1/contract_insurance_fund?symbol=ETH"

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol true string Contract Code "BTC","ETH"...

Response:


{
  "status": "ok",
  "ts": 158797866555,
  "data":   {
      "symbol": "ETH",
      "tick": [
        {
          "insurance_fund": 3806.4615259197324414715719,
          "ts": 158797866555
         }
       ]
  }
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Milesecond
<data> Dictionary Data
symbol true string Contract Code "BTC","ETH"...
<tick>
insurance_fund true decimal Insurance Fund Balance
ts true long Timestamp, Unit: Milesecond
</tick>
</data>

Query information on Tiered Adjustment Factor

curl "https://api.hbdm.com/api/v1/contract_adjustfactor"

Request Parameter

Parameter Name Mandatory Type Desc Data Value
symbol false string Contract Code "BTC","ETH"...,If no data detected, system will return to all contracts by default.

Response:


{
  "status": "ok",
  "data": [
   {
      "symbol": "BTC",
      "list": [
       {
          "lever_rate": 10,
          "ladders": [
           {
             "ladder": 1,
             "min_size": 0,
             "max_size": 100,
             "adjust_factor": 0.1
           },
           {
             "ladder": 2,
             "min_size": 101,
             "max_size": 500,
             "adjust_factor": 0.2
           }
           ]
       }
       ]
   }
   ],
   "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Milesecond
<data>
symbol true string Contract Code "BTC","ETH"...
<list>
lever_rate true decimal Leverage
<ladderDetail>
min_size true decimal Min net position limit
max_size true decimal Max net position limit
ladder true int Tier
adjust_factor true decimal Adjustment Factor
</ladderDetail>
</list>
</data>

Query information on open interest

curl "https://api.hbdm.com/api/v1/contract_his_open_interest?symbol=BTC&contract_type=this_week&period=60min&amount_type=1"

Request Parameter

Parameter Name Mandatory Type Desc Data Range
symbol true string Contract Code "BTC","ETH"...
contract_type true string Contract Type Weekly:"this_week", Bi-weekly:"next_week", -Quarterly:"quarter"
period true string Period Type 1 hour:"60min",4 hours:"4hour",12 hours:"12hour",1 day:"1day"
size false int Request Amount Default:48,Data Range [1,200]
amount_type true int Open interest unit 1:-cont,2:-cryptocurrenty

Response:

{
  "status": "ok",
  "data": 
    {
    "symbol": "BTC",
    "contract_type": "this_week",
    "tick": [{
      "volume": 1,
      "amount_type": 1,
      "ts": 1529387842137
      }]
    },
    "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Data Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Milesecond
<data> Dictionary Data
symbol true string Contract Code "BTC","ETH"...
contract_type true string Contract Type Weekly:"this_week", Bi-weekly:"next_week", -Quarterly:"quarter"
<tick>
volume true decimal Open Interest
amount_type true int Open Interest Unit 1:-cont,2:- cryptocurrency
ts true long Recording Time
</tick>
</data>

Notice

Query information on system status

curl "https://api.hbdm.com/api/v1/contract_api_state"

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol false string symbol "BTC","ETH"... If no data detected, system will return to all symbols by default

Response:


{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "open": 1,
      "close": 1,
      "cancel": 1,
      "transfer_in": 1,
      "transfer_out": 1,
    }
 ],
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: milesecond
<data>
symbol true string symbol "BTC","ETH"...
open true int open order access:when “1”, then access available; when “0”, access unavailable"1"
close true int close order access:when “1”, then access available; when “0”, access unavailable "1"
cancel true int order cancellation access:when “1”, then access available; when “0”, access unavailable "1"
transfer_in true int deposit access:when “1”, then access available; when “0”, access unavailable "1"
transfer_out true int withdraw access: when “1”, then access available; when “0”, access unavailable "1"
</data>

Notice

Top Trader Sentiment Index Function-Account

curl "https://api.hbdm.com/api/v1/contract_elite_account_ratio?symbol=BTC&period=60min"

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol true string symbol "BTC","ETH"...
period true string period 5min, 15min, 30min, 60min,4hour,1day

Response:


{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "list": [
        {
         "buy_ratio": 0.2323,
         "sell_ratio": 0.4645,
         "locked_ratio": 0.4142,
         "ts": 158797866555
       }
       ]
    }
 ],
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Vaue Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Milesecond
<data>
symbol true string symbol "BTC","ETH"...
<list>
buy_ratio true decimal net long accounts ratio
sell_ratio true decimal net short accounts ratio
locked_ratio true decimal locked accounts ratio
ts true long Time of Respond Generation
</list>
</data>

Top Trader Sentiment Index Function-Position

curl "https://api.hbdm.com/api/v1/contract_elite_position_ratio?symbol=BTC&period=60min"

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol true string symbol "BTC","ETH"...
period true string period 5min, 15min, 30min, 60min,4hour,1day

Response:


{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "list": [
        {
         "buy_ratio": 0.2323,
         "sell_ratio": 0.4645,
         "ts": 158797866555
       }
       ]
    }
 ],
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Milesecond
<data>
symbol true string symbol "BTC","ETH"...
<list>
buy_ratio true decimal Net long position ratio
sell_ratio true decimal Net short position ratio
ts true long Time of Respond Generation
</list>
</data>

Request Liquidation Order Information

curl "https://api.hbdm.com/api/v1/contract_liquidation_orders?symbol=BTC&trade_type=0&create_date=7"

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol true string symbol "BTC","ETH"...
trade_type true int trading types when “0”, request fully filled liquidated orders; when “5’, request liquidated close orders; when “6”, request liquidated open orders
create_date true int date 7,90( 7 days or 90 days)
page_index false int page, system sets page 1 by default without further instruction
page_size false int system sets page 20 by default without further instruction. Max page size is 50.

Response:


{
  "status": "ok",
  "data":{
    "orders":[
      {
        "symbol": "BTC",
        "contract_code": "BTC180914",    
        "direction": "buy",
        "offset": "close",
        "volume": 111,
        "price": 1111,
        "created_at": 1408076414000
      }
     ],
    "total_page":15,
    "current_page":3,
    "total_size":3
    },
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result
<object>(object name: data)
<list>( object name: orders)
symbol true string symbol
contract_code true string contract code "BTC180914" ...
direction true string "buy":buy"sell": sell
offset true string "open":open "close": close
volume true decimal liquidated order quantity
price true decimal bankruptcy price
created_at true long liquidation time
</list>
total_page true int total page
current_page true int current page
total_size true int total size
</object>
ts true long timestamp

HuobiDM Account Interface

User’s Account Information

Example

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol false string Variety code "BTC","ETH"...if default, return to all types defaulted

Response:

{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "margin_balance": 1,
      "margin_position": 0,
      "margin_frozen": 3.33,
      "margin_available": 0.34,
      "profit_real": 3.45,
      "profit_unreal": 7.45,
      "withdraw_available":4.0989898,
      "risk_rate": 100,
      "liquidation_price": 100,
      "adjust_factor": 0.1,
      "margin_static": 1
     },
    {
      "symbol": "ETH",
      "margin_balance": 1,
      "margin_position": 0,
      "margin_frozen": 3.33,
      "margin_available": 0.34,
      "profit_real": 3.45,
      "profit_unreal": 7.45,
      "withdraw_available":4.7389859,
      "risk_rate": 100,
      "liquidation_price": 100,
      "adjust_factor": 0.1,
      "margin_static": 1
     }
   ],
  "ts":158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: data)
symbol true string Variety code "BTC","ETH"...
margin_balance true decimal Account rights
margin_position true decimal Position Margin
margin_frozen true decimal Freeze margin
margin_available true decimal Available margin
profit_real true decimal Realized profit
profit_unreal true decimal Unrealized profit
risk_rate true decimal risk rate
liquidation_price true decimal Estimated liquidation price
withdraw_available true decimal Available withdrawal
lever_rate true decimal Leverage Rate
adjust_factor true decimal Adjustment Factor
margin_static true decimal Static Margin
</list>
ts number long Time of Respond Generation, Unit: Millisecond

User’s Position Information

Example

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol false string Variety code "BTC","ETH"...if default, return to all types defaulted

Response:

{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "contract_code": "BTC180914",
      "contract_type": "this_week",
      "volume": 1,
      "available": 0,
      "frozen": 0.3,
      "cost_open": 422.78,
      "cost_hold": 422.78,
      "profit_unreal": 0.00007096,
      "profit_rate": 0.07,
      "profit": 0.97,
      "position_margin": 3.4,
      "lever_rate": 10,
      "direction":"buy",
      "last_price":7900.17
     }
    ],
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: data)
symbol true string Variety code "BTC","ETH"...
contract_code true string Contract Code "BTC180914" ...
contract_type true string Contract Type "this_week", "next_week", "quarter"
volume true decimal Position quantity
available true decimal Available position can be closed
frozen true decimal frozen
cost_open true decimal Opening average price
cost_hold true decimal Average price of position
profit_unreal true decimal Unrealized profit and loss
profit_rate true decimal Profit rate
profit true decimal profit
position_margin true decimal Position margin
lever_rate true int Leverage rate
direction true string Transaction direction
last_price true decimal Latest price
</list>
ts true long Time of Respond Generation, Unit: Millisecond

Query assets information of all sub-accounts under the master account

Request Parameters

Parameter name Must fill or not Type Description Default value Value range
symbol false string type code "BTC","ETH"... ,if blank, it will return all contract types by default

Response:

{
  "status": "ok",
  "ts": 1499223904680,
    "data": [
      {
        "sub_uid": 9910049,
        "list": [
        {
             "symbol": "BTC",
           "margin_balance": 1,
           "liquidation_price": 100,
             "risk_rate": 100
          },
          {
             "symbol": "ETH",
           "margin_balance": 1,
           "liquidation_price": 100,
             "risk_rate": 100
          }
        ]
      },
    {
        "sub_uid": 9910048,
        "list": [
        {
             "symbol": "BTC",
           "margin_balance": 1,
           "liquidation_price": 100,
             "risk_rate": 100
          },
          {
             "symbol": "ETH",
           "margin_balance": 1,
           "liquidation_price": 100,
             "risk_rate": 100
          }
        ]
    }
    ]
}

Return parameters

Parameter name Must fill or not Type Description Value range
status true string the handling result of requests "ok" , "error"
ts true long the create time point of response, unit: ms
<data>
sub_uid true long sub-account UID
<list>
symbol true string type code "BTC","ETH"...
margin_balance true decimal account equity
liquidation_price true decimal estimated liquidation price
risk_rate true decimal margin rate
</list>
</data>

Only return data for activated contract sub-account (i.e. sub-accounts that have gained contract trading permission).

Query a single sub-account's assets information

Request Parameters

Parameter name Must fill or not Type Description Default value Value range
symbol false string type code "BTC","ETH"...,if blank, it will return all contract types by default
sub_uid true long sub-account UID

Response:

{
  "status": "ok",
  "data":  [ 
     {
        "symbol": "BTC",
        "margin_balance": 1,
        "margin_position": 0,
        "margin_frozen": 3.33,
        "margin_available": 0.34,
        "profit_real": 3.45,
        "profit_unreal": 7.45,
        "withdraw_available":4.0989898,
        "risk_rate": 100,
        "liquidation_price": 100,
        "adjust_factor": 0.1
      }
    ],
  "ts":158797866555
}

Return parameters

Parameter name Must fill or not Type Description Value range
status true string the handling result of requests "ok" , "error"
ts true long the create time point of response, unit: ms
<data>
symbol true string type code "BTC","ETH"...when the$symbol value is "*", it will subscribe all contract types
margin_balance true decimal account equity
margin_position true decimal position margin (the margin used by current positions)
margin_frozen true decimal frozen margin
margin_available true decimal available margin
profit_real true decimal realized profits and losses
profit_unreal true decimal unrealized profits and losses
risk_rate true decimal margin rate
liquidation_price true decimal estimated liquidation price
withdraw_available true decimal available transfer amount
lever_rate true decimal leverage ratios
adjust_factor true decimal Adjustment Factor
</data>

Only query account information for activated contract sub-account (i.e. sub-accounts that have gained contract trading permission);

No data return for sub-accounts which has logged in hbdm but have not gained trading permission/activated.

Query a single sub-account's position information

Request Parameters

Parameter name Must fill or not Type Description Default value Value range
symbol false string type code "BTC","ETH"...,if blank, it will return all contract types by default
sub_uid true long sub-account UID

Response:

{
  "status": "ok",
  "ts": 158797866555,
  "data":[ 
     {
         "symbol": "BTC",
         "contract_code": "BTC180914",
         "contract_type": "this_week",
         "volume": 1,
         "available": 0,
         "frozen": 0.3,
         "cost_open": 422.78,
         "cost_hold": 422.78,
         "profit_unreal": 0.00007096,
         "profit_rate": 0.07,
         "profit": 0.97,
         "position_margin": 3.4,
         "lever_rate": 10,
         "direction":"buy"
     }
   ]
}

Return parameters

Parameter name Must fill or not Type Description Value range
status true string the handling result of requests "ok" , "error"
ts true long the create time point of response, unit: ms
<data>
symbol true string type code "BTC","ETH"...
contract_code true string contract code "BTC180914" ...
contract_type true string contract type Weekly:"this_week", Biweekly:"next_week", Quarterly:"quarter"
volume true decimal open interest
available true decimal available positions to close
frozen true decimal amount of frozen positions
cost_open true decimal average price of open positions
cost_hold true decimal average price of positions
profit_unreal true decimal unrealized profits and losses
profit_rate true decimal profit rate
profit true decimal profits
position_margin true decimal position margin
lever_rate true int leverage ratios
direction true string transaction direction of positions "buy":long "sell":short
</data>

Query account financial records

Request Parameters

Parameter name Must fill or not Type Description Value range
symbol true string contract type code "BTC","ETH"...
type false string if not fill this parameter, it will query all types 【please use "," to seperate multiple types】 close long:3,close short:4,fees for open positions-taker:5,fees for open positions-maker:6,fees for close positions-taker:7,fees for close positions-maker:8,close long for delivery:9,close short for delivery:10,delivery fee:11,close long for liquidation:12,lose short for liquidation:13,transfer from spot exchange to contract exchange:14,tranfer from contract exchange to spot exchange:15,settle unrealized PnL-long positions:16,settle unrealized PnL-short positions:17,clawback:19,system:26,activity prize rewards:28,rebate:29
create_date false int 7,90 (7days ,90days) ,default value is 7 when not fill this parameter
page_index false int which page, default value is "1st page" when not fill this parameter
page_size false int the default value is "20" when not fill this parameter, should ≤50

Response:

{
      "status": "ok",
  "data":{
    "financial_record" : [
      {
      "id": 192838272,
      "ts": 1408076414000,
      "symbol":"BTC",
      "type":1, 
      "amount":1
      },
      {
        .........
      }
    ],
         "total_page":15,
         "current_page":3,
         "total_size":3
        },
  "ts": 1490759594752
}

Return parameters

Parameter name Must fill or not Type Description Value range
status true string processing result of requests "ok" , "error"
ts true long response create time point,unit:ms
<data> dicitionary type
<financial_record>
id true long
ts true long create time
symbol true string contract type code "BTC","ETH"...
type true int transaction type close long:3,close short:4,fees for open positions-taker:5,fees for open positions-maker:6,fees for close positions-taker:7,fees for close positions-maker:8,close long for delivery:9,close short for delivery:10,delivery fee:11,close long for liquidation:12,lose short for liquidation:13,transfer from spot exchange to contract exchange:14,tranfer from contract exchange to spot exchange:15,settle unrealized PnL-long positions:16,settle unrealized PnL-short positions:17,clawback:19,system:26,activity prize rewards:28,rebate:29
amount true decimal amount
</financial_record>
total_page true int total page
current_page true int current page
total_size true int total size
</data>

Query contract information on order limit

Request Parameter

Parameter Name Mandatory Type Description Value Range
symbol false string contract code "BTC","ETH"...,If no data detected, system will return to all contracts by default
order_price_type true string Order Type "limit": Limit Order,"opponent":BBO,"lightning": Flash Close,"optimal_5": Optimal top 5 price,"optimal_10":Optimal top 10 price,"optimal_20":Optimal top 20 price,"fok":FOK order,"ioc":ioc order

Response:

{
  "status": "ok",
  "data":  {
      "order_price_type": "limit",
      "list":[
      {
          "symbol": "BTC",
          "types": [
             {
              "contract_type": "this_week",
              "open_limit": 3000,
              "close_limit": 3000
             },
             {
              "contract_type": "next_week",
              "open_limit": 3000,
              "close_limit": 3000
             },     
             {
              "contract_type": "quarter",
              "open_limit": 3000,
              "close_limit": 3000
             }
           ]
      }
      ]
   },
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range Í
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Millisecond
<data>
order_price_type true string Order Type "limit": Limit Order,"opponent":BBO,"lightning": Flash Close,"optimal_5": Optimal top 5 price,"optimal_10":Optimal top 10 price,"optimal_20":Optimal top 20 price,"fok":FOK order,"ioc":ioc order
<list>
symbol true string Contract Code "BTC","ETH"...
<types>
contract_type true string Contract Type Weekly:"this_week", Bi-weekly:"next_week", Quarterly:"quarter"
open_limit true long Max open order limit
close_limit true long Max close order limit
</types>
</list>
</data>

Query information on contract trading fee

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol false string Contract Code "BTC","ETH"...,If no data detected, system will return to all contract by default

Response:


{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "open_maker_fee": "-0.00025",
      "open_taker_fee": "0.00075",
      "close_maker_fee": "-0.00025",
      "close_taker_fee": "0.00075",
      "delivery_fee": "0.0005"
    }
 ],
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Millisecond
<data>
symbol true string Contract Code "BTC","ETH"...
open_maker_fee true string Open maker order fee, decimal
open_taker_fee true string Open taker order fee, decimal
close_maker_fee true string Close maker order fee, decimal
close_taker_fee true string Close taker order fee, decimal
delivery_fee true string delivery fee, decimal
</data>

Query information on Transfer Limit

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol false string Contract Code "BTC","ETH"...,If no data detected, system will return to all contracts by default.

Response:

{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "transfer_in_max_each": 5000,
      "transfer_in_min_each": 5000,
      "transfer_out_max_each": 5000,
      "transfer_out_min_each": 5000,
      "transfer_in_max_daily": 5000,
      "transfer_out_max_daily": 5000,
      "net_transfer_in_max_daily": 5000,
      "net_transfer_out_max_daily": 5000
    }
 ],
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Respond Generation, Unit: Milesecond
<data>
symbol true string Contract Code "BTC","ETH"...
transfer_in_max_each true decimal Max limit of a single deposit
transfer_in_min_each true decimal Min limit of a single deposit
transfer_out_max_each true decimal Max limit of a single withdrawal
transfer_out_min_each true decimal Min limit of a single withdrawal
transfer_in_max_daily true decimal Max daily limit of total deposits
transfer_out_max_daily true decimal Max daily limit of totally withdrawals
net_transfer_in_max_daily true decimal Max daily limit of net total deposits
net_transfer_out_max_daily true decimal Max daily limit of net total withdrawals
</data>

Query information on position limit

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol false string Contract Code "BTC","ETH"...,If no data detected, system will return to all contracts by default.

Response:

{
  "status": "ok",
  "data": [
    {
      "symbol": "BTC",
      "list": [
        {
         "contract_type": "all",
         "buy_limit": 5000,
         "sell_limit": 5000
       },
        {
         "contract_type": "this_week",
         "buy_limit": 3000,
         "sell_limit": 3000
       },
        {
         "contract_type": "next_week",
         "buy_limit": 3000,
         "sell_limit": 3000
       },     
        {
         "contract_type": "quarter",
         "buy_limit": 3000,
         "sell_limit": 3000
       }
       ]
    }
 ],
 "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
ts true long Time of Responding Generation, Unit: milesecond
<data>
symbol true string Contract Code "BTC","ETH"...
<list>
contract_type true string Contract Type Weekly :"this_week", Bi-weekly:"next_week", Quarterly:"quarter",All contracts:“all”
buy_limit true decimal Max long position limit, Unit: Cont
sell_limit true decimal Max short position limit, Unit: Cont
</list>
</data>

HuobiDM Trade Interface

Place an Order

Example

Request Parameter

Parameter Name Parameter Type Mandatory Desc
symbol string false "BTC","ETH"...
contract_type string false Contract Type ("this_week": "next_week": "quarter":)
contract_code string false BTC180914
client_order_id long false Clients fill and maintain themselves
price decimal false Price
volume long true Numbers of orders (amount)
direction string true Transaction direction
offset string true "open", "close"
lever_rate int true Leverage rate [if“Open”is multiple orders in 10 rate, there will be not multiple orders in 20 rate
order_price_type string true "limit": Limit Order,"opponent":BBO,"lightning": Flash Close,"optimal_5": Optimal top 5 price,"optimal_10":Optimal top 10 price,"optimal_20":Optimal top 20 price,"fok":FOK order,"ioc":ioc order

Note :

If there is a number in the Contract Code row,inquiry with Contract_Code.

If there is no number,inquiry by Symbol + Contract Type.

Description of post_only: assure that the maker order remains as maker order, it will not be filled immediately with the use of post_only, for the match system will automatically check whether the price of the maker order is higher/lower than the opponent first price, i.e. higher than bid price 1 or lower than the ask price 1. If yes, the maker order will placed on the orderbook, if not, the maker order will be cancelled.

open long: direction - buy、offset - open

close long: direction -sell、offset - close

open short: direction -sell、offset - open

close short: direction -buy、offset - close

No need to transfer BBO order price(ask 1and bid 1) parameter, optimal_5: top 5 optimal BBO price, optimal_10:top 10 optimal BBO price, optimal_20:top 20 optimal BBO price (No need to transfer price data) ,limit": limit order, "post_only": maker order only (price data transfer is needed),IOC :Immediate-Or-Cancel Order,FOK:Fill-Or-Kill Order.

Response:

{
  "status": "ok",
  "order_id": 633766664829804544,
  "client_order_id": 9086,
  "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
order_id true bigint Order ID
client_order_id true long the client ID that is filled in when the order is placed, if it’s not filled, it won’t be returned
ts true long Time of Respond Generation, Unit: Millisecond

Note

The return order_id is 18 bits, it will make mistake when nodejs and JavaScript analysed 18 bits. Because the Json.parse in nodejs and JavaScript is int by default. so the number over 18 bits need be parsed by jaso-bigint package.

Place a Batch of Orders

Example

Request Parameter

Parameter Name Parameter Type Mandatory Desc
<list>(Attribute Name: orders_data)
symbol string false "BTC","ETH"...
contract_type string false Contract Type: "this_week": "next_week": "quarter":
contract_code string false BTC180914
client_order_id long false Clients fill and maintain themselves
price decimal false Price
volume long true Numbers of orders (amount)
direction string true Transaction direction
offset string true "open": "close"
lever_rate int true Leverage rate [if“Open”is multiple orders in 10 rate, there will be not multiple orders in 20 rate
order_price_type string true "limit": Limit Order,"opponent":BBO,"lightning": Flash Close,"optimal_5": Optimal top 5 price,"optimal_10":Optimal top 10 price,"optimal_20":Optimal top 20 price,"fok":FOK order,"ioc":ioc order
</list>

Note :

If there is a number in the Contract Code row,inquiry with Contract_Code.

If there is no number,inquiry by Symbol + Contract Type.

Description of post_only: assure that the maker order remains as maker order, it will not be filled immediately with the use of post_only, for the match system will automatically check whether the price of the maker order is higher/lower than the opponent first price, i.e. higher than bid price 1 or lower than the ask price 1. If yes, the maker order will placed on the orderbook, if not, the maker order will be cancelled.

No need to transfer BBO order price(ask 1and bid 1) parameter, optimal_5: top 5 optimal BBO price, optimal_10:top 10 optimal BBO price, optimal_20:top 20 optimal BBO price (No need to transfer price data) ,limit": limit order, "post_only": maker order only (price data transfer is needed),IOC :Immediate-Or-Cancel Order,FOK:Fill-Or-Kill Order

Response:

{
  "status": "ok",
  "data": {
    "errors":[
      {
        "index":0,
        "err_code": 200417,
        "err_msg": "invalid symbol"
       },
      {
        "index":3,
        "err_code": 200415,
        "err_msg": "invalid symbol"
       }
     ],
    "success":[
      {
        "index":1,
        "order_id":633766664829804544,
        "client_order_id":1344567
       },
      {
        "index":2,
        "order_id":633766664829804544,
        "client_order_id":1344569
       }
     ]
   },
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: errors)
index true int order Index
err_code true int Error code
err_msg true string Error information
</list>
<list>(Attribute Name: success)
index true int order Index
order_id true bigint Order ID
client_order_id true long the client ID that is filled in when the order is placed, if it’s not filled, it won’t be returned
</list>
ts true long Time of Respond Generation, Unit: Millisecond

Note

The return order_id is 18 bits, it will make mistake when nodejs and JavaScript analysed 18 bits. Because the Json.parse in nodejs and JavaScript is int by default. so the number over 18 bits need be parsed by jaso-bigint package.

Cancel an Order

Example

Request Parameter

Parameter Name Mandatory Type Desc
order_id false string Order ID(different IDs are separated by ",", maximum 50 orders can be withdrew at one time)
client_order_id false string Client order ID (different IDs are separated by ",", maximum 50 orders can be withdrew at one time)
symbol true string "BTC","ETH"...

Note :

Both order_id and client_order_id can be used for order withdrawl,one of them needed at one time,if both of them are set,the default will be order id。

The return data from Cancel An Order Interface only means that order cancelation designation is executed successfully. To check cancelation result, please check your order status at Get Information Of An Order interface.

Response: result of multiple order withdrawls (successful withdrew order ID, failed withdrew order ID)

{
  "status": "ok",
  "errors":[
    {
      "order_id":"633766664829804544",
      "err_code": "1002",
      "err_msg": "order doesn’t exist"
     },
    {
      "order_id":"633766664829804544",
      "err_code": "1002",
      "err_msg": "order doesn’t exist"
     }
   ],
  "success":"161256,1344567",
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: errors)
order_id true string Order ID
err_code true int Error code
err_msg true string Error information
</list>
successes true string Successfully withdrew list of order_id or client_order_id
ts true long Time of Respond Generation, Unit: Millisecond

Cancel All Orders

Example

Request: json { "symbol": "BTC" }

Request Parameter

Parameter Name Mandatory Type Desc
symbol true string Variety code,eg "BTC","ETH"...
contract_code false string contract_code
contract_type false string contract_type

Note

  1. Send symbol to cancel all the contracts of that kind of symbol, e.g. send “BTC” to cancel all BTC weekly, biweekly and quarterly contracts.

  2. Send contract_code to cancel the contracts of that code.

  3. Send symbol+contract_type to cancel the certain contracts under the symbol of that contract_type, e.g. send “BTC” and “this week”, then the BTC weekly contracts will be cancelled.

Response:result of multiple order withdrawls (successful withdrew order ID, failed withdrew order ID)

{
  "status": "ok",
  "data": {
    "errors":[
      {
        "order_id":"633766664829804544",
        "err_code": 200417,
        "err_msg": "invalid symbol"
       },
      {
        "order_id":"633766664829804544",
        "err_code": 200415,
        "err_msg": "invalid symbol"
       }
      ],
    "successes":"161256,1344567"
   },
  "ts": 1490759594752
}

Error:

{
  "status": "error",
  "err_code": 20012,
  "err_msg": "invalid symbol",
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
successes true string Successful order
<list>(Attribute Name: errors)
order_id true String Order ID
err_code true int failed order error messageError code
err_msg true int failed order information
</list>
successes true string Successful order
ts true long Time of Respond Generation, Unit: Millisecond

Place Flash Close Order

Request Parameter

Parameter Name Mandatory Type Desc Value Range
symbol false String Contract Code "BTC","ETH"...
contract_type false String Contract Type “this_week”:Weekly,“next_week”:Bi-weekly,“quarter”:Quarterly
contract_code false String Contract Code BTC190903
volume true Number Order Quantity(Cont)
direction true String “buy”:Open,“sell”:Close
client_order_id false Number Client needs to provide unique API and have to maintain the API themselves afterwards

Response:

{
  "status": "ok",
  "data": {
    "order_id": 633766664829804544,
    "client_order_id": 9086
  },
     "ts": 158797866555
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" :Order placed successfully, "error":Order failed
ts true long Time of Respond Generation, Unit: Milesecond
Dictionary
order_id true bigint Order ID [Different users may share the same order ID]
client_order_id false Number user’s own order ID

Error:

{
    "status": "error",
    "err_code": 20012,
    "err_msg": "invalid symbol",
    "ts": 1490759594752
}

Get Information of an Order

Example

Request Parameter

Parameter Name Mandatory Type Desc
order_id false string Order ID(different IDs are separated by ",", maximum 50 orders can be withdrew at one time)
client_order_id false string Client order ID Order ID(different IDs are separated by ",", maximum 50 orders can be withdrew at one time)
symbol true string "BTC","ETH"...

Note :

Both order_id and client_order_id can be used for order withdrawl,one of them needed at one time,if both of them are set,the default will be order id。

client_order_id,order status query is available for orders placed within 24 hours; Otherwise, clients cannot check orders placed beyond 24 hours.

Response:

{
  "status": "ok",
  "data":[
    {
      "symbol": "BTC",
      "contract_type": "this_week",
      "contract_code": "BTC180914",
      "volume": 111,
      "price": 1111,
      "order_price_type": "limit",
      "direction": "buy",
      "offset": "open",
      "lever_rate": 10,
      "order_id": 106837,
      "client_order_id": 10683,
      "order_source": "web",
      "created_at": 1408076414000,
      "trade_volume": 1,
      "trade_turnover": 1200,
      "fee": 0,
      "trade_avg_price": 10,
      "margin_frozen": 10,
      "profit ": 10,
      "status": 0
     },
    {
      "symbol": "ETH",
      "contract_type": "this_week",
      "contract_code": "ETH180921",
      "volume": 111,
      "price": 1111,
      "order_price_type": "limit",
      "direction": "buy",
      "offset": "open",
      "lever_rate": 10,
      "order_id": 106837,
      "client_order_id": 10683,
      "order_source": "web",
      "created_at": 1408076414000,
      "trade_volume": 1,
      "trade_turnover": 1200,
      "fee": 0,
      "trade_avg_price": 10,
      "margin_frozen": 10,
      "profit ": 10,
      "status": 0
     }
    ],
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<list>(Attribute Name: data)
symbol true string Variety code
contract_type true string Contract Type "this_week", "next_week", "quarter"
contract_code true string Contract Code "BTC180914" ...
volume true decimal Numbers of order
price true decimal Price committed
order_price_type true string "limit", "opponent","post_only" Position limit will be applied to post_only while order limit will not.
direction true string Transaction direction
offset true string "open": "close"
lever_rate true int Leverage rate 1\5\10\20
order_id true long Order ID
client_order_id true long Client order ID
created_at true long Creation time
trade_volume true decimal Transaction quantity
trade_turnover true decimal Transaction aggregate amount
fee true decimal Servicefee
trade_avg_price true decimal Transaction average price
margin_frozen true decimal Freeze margin
profit true decimal profit
status true int status: 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling.
order_source true string Order source(1:system、2:web、3:api、4:m 5:risk、6:settlement)
</list>
ts true long Timestamp

Order details acquisition

Example

Request Parameter

Parameter Name Mandatory Type Desc
symbol true string "BTC","ETH"...
order_id true bigint Order ID
created_at false long Timestamp
order_type true int Order type: 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order
page_index false int Page number, default 1st page
page_size false int Default 20,no more than 50

Note

The return order_id is 18 bits, it will make mistake when nodejs and JavaScript analysed 18 bits. Because the Json.parse in nodejs and JavaScript is int by default. so the number over 18 bits need be parsed by jaso-bigint package.

Response:

{
  "status": "ok",
  "data":{
    "symbol": "BTC",
    "contract_type": "this_week",
    "contract_code": "BTC180914",
    "volume": 111,
    "price": 1111,
    "order_price_type": "limit",
    "direction": "buy",
    "offset": "open",
    "status": 1,
    "lever_rate": 10,
    "trade_avg_price": 10,
    "margin_frozen": 10,
    "profit": 10,
    "order_source": "web",
    "created_at": 1408076414000,
    "contract_order_detail": 10000,
    "final_interest": 0,
    "adjust_value": 1,
    "trades":[
      {
        "id":"21315414825-6141291349-1",
        "trade_id":112,
        "trade_volume":1,
        "trade_price":123.4555,
        "trade_fee":0.234,
        "trade_turnover":34.123,
        "role": "maker",
        "created_at": 1490759594752
       }
      ],
    "total_page":15,
    "total_size":3,
    "current_page":3
    },
  "ts": 1490759594752
}

Error:

{
 "status":"error",
 "err_code":20029,
 "err_msg": "invalid symbol",
 "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result "ok" , "error"
<object> (Attribute Name: data)
symbol true string Variety code
contract_type true string Contract Type "this_week","next_week","quarter"
contract_code true string Contract Code "BTC180914" ...
lever_rate true int Leverage Rate 1\5\10\20
direction true string Transaction direction
offset true string "open": "close"
volume true decimal Number of Order
price true decimal Price committed
created_at true long Creation time
order_source true string Order Source
order_price_type true string "limit", "opponent","post_only" Position limit will be applied to post_only while order limit will not.
margin_frozen true decimal Freeze margin
profit true decimal profit
total_page true int Page in total
current_page true int Current Page
total_size true int Total Size
instrument_price true decimal Liquidation price
final_interest true decimal Account Balance After Liquidation
adjust_value true decimal Adjustment Factor of Liquidating Order
<list> (Attribute Name: trades)
id true string Id, You can use trade_id and the new field "id" to combine a unique trade ID.
trade_id true long Match Result id , You can use trade_id and the new field "id" to combine a unique trade ID.
trade_price true decimal Match Price
trade_volume true decimal Transaction quantity
trade_turnover true decimal Transaction price
trade_fee true decimal Transaction Service fee
role true string taker or maker
created_at true long Creation time
</list>
</object >
ts true long Timestamp

Current unfilled commission acquisition

Example

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol true string Variety code "BTC","ETH"...
page_index false int Page, default 1st page 1
page_size false int Default 20,no more than 50 20

Response:

{
  "status": "ok",
  "data":{
    "orders":[
      {
         "symbol": "BTC",
         "contract_type": "this_week",
         "contract_code": "BTC180914",
         "volume": 111,
         "price": 1111,
         "order_price_type": "limit",
         "direction": "buy",
         "offset": "open",
         "lever_rate": 10,
         "order_id": 106837,
         "client_order_id": 10683,
         "order_source": "web",
         "created_at": 1408076414000,
         "trade_volume": 1,
         "trade_turnover": 1200,
         "fee": 0,
         "trade_avg_price": 10,
         "margin_frozen": 10,
         "status": 1
        }
       ],
    "total_page":15,
    "current_page":3,
    "total_size":3
   },
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result
<list>(Attribute Name: data)
symbol true string Variety code
contract_type true string Contract Type "this_week","next_week","quarter"
contract_code true string Contract Code "BTC180914" ...
volume true decimal Number of Order
price true decimal Price committed
order_price_type true string "limit", "opponent","post_only" Position limit will be applied to post_only while order limit will not.
direction true string Transaction direction
offset true string "open": "close"
lever_rate true int Leverage Rate 1\5\10\20
order_id true long Order ID
client_order_id true long Client order ID
created_at true long Order Creation time
trade_volume true decimal Transaction quantity
trade_turnover true decimal Transaction aggregate amount
fee true decimal Servicefee
trade_avg_price true decimal Transaction average price
margin_frozen true decimal Freeze margin
profit true decimal profit
status true int status: 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling.
order_source true string Order Source
</list>
total_page true int Total Pages
current_page true int Current Page
total_size true int Total Size
ts true long Timestamp

Get History Orders

Example

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol true string Variety code "BTC","ETH"...
trade_type true int Transaction type 0:all,1: buy long,2: sell short,3: buy short,4: sell long,5: sell liquidation,6: buy liquidation,7:Delivery long,8: Delivery short
type true int Type 1:All Orders,2:Order in Finished Status
status true int Order Status status: 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling.
create_date true int Date 7,90(7days or 90 days)
page_index false int Page, default 1st page 1
page_size false int Default 20,no more than 50 20

Response:

{
  "status": "ok",
  "data":{
    "orders":[
      {
        "symbol": "BTC",
        "contract_type": "this_week",
        "contract_code": "BTC180914",
        "volume": 111,
        "price": 1111,
        "order_price_type": "limit",
        "direction": "buy",
        "offset": "open",
        "lever_rate": 10,
        "order_id": 633766664829804544,
        "order_source": "web",
        "created_at": 1408076414000,
        "trade_volume": 1,
        "trade_turnover": 1200,
        "fee": 0,
        "trade_avg_price": 10,
        "margin_frozen": 10,
        "profit": 10,
        "status": 1,
        "order_type": 1
      }
     ],
    "total_page":15,
    "current_page":3,
    "total_size":3
    },
  "ts": 1490759594752
}

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Request Processing Result
<object>(Attribute Name: data)
<list>(Attribute Name: orders)
order_id true bigint Order ID
symbol true string Variety code
contract_type true string Contract Type "this_week","next_week","quarter"
contract_code true string Contract Code "BTC180914" ...
lever_rate true int Leverage Rate 1\5\10\20
direction true string Transaction direction
offset true string "open": "close"
volume true decimal Number of Order
price true decimal Price committed
create_date true long Creation time
order_source true string Order Source
order_price_type true string 1. Limit price order; 3. BBO price order (opponent price); 4. Flash close; 5. Trigger order; 6. Post_only order
margin_frozen true decimal Freeze margin
profit true decimal profit
trade_volume true decimal Transaction quantity
trade_turnover true decimal Transaction aggregate amount
fee true decimal Servicefee
trade_avg_price true decimal Transaction average price
status true int status: 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling.
</list>
</object>
total_page true int Total Pages
current_page true int Current Page
total_size true int Total Size
ts true long Timestamp

Note

The return order_id is 18 bits, it will make mistake when nodejs and JavaScript analysed 18 bits. Because the Json.parse in nodejs and JavaScript is int by default. so the number over 18 bits need be parsed by jaso-bigint package.

Acquire History Match Results

Example

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
symbol true string contract types code "BTC","ETH"...
trade_type true int trasanction types 0:All; 1: Open long; 2: Open short; 3: Close short; 4: Close long; 5: Liquidate long positions; 6: Liquidate short positions
create_date true int date 7, 90 (7 or 90 days)
contract_code false string contract code
page_index false int page; if not enter, it will be the default value of the 1st page. 1
page_size false int if not enter, it will be the default value of 20; the number should ≤50 20

Response:

    {
     "data": {
        "current_page": 1,
        "total_page": 1,
        "total_size": 2,
        "trades": [{
            "id": "21315414825-6141291349-1",
            "contract_code": "EOS190419",
            "contract_type": "this_week",
            "create_date": 1555553626736,
            "direction": "sell",
            "match_id": 3635853382,
            "offset": "close",
            "offset_profitloss": 0.15646398812252696,
            "order_id": 633766664829804544,
            "symbol": "EOS",
            "trade_fee": -0.002897500905469032,
            "trade_price": 5.522,
            "trade_turnover": 80,
            "trade_volume": 8,
            "role": "maker",
        }]
    },
    "status": "ok",
    "ts": 1555654870867
    }

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string request handling result
<object>(attribute name: data: data)
<list>(attribute name: data: trades)
id true string traded ID, You can use match_id and the new field "id" to combine a unique trade ID.
match_id true long match ID, You can use match_id and the new field "id" to combine a unique trade ID.
order_id true bigint order ID
symbol true string contract type code
contract_type true string contract type deliver on this Friday then "this_week"; deliver on next Friday then "next_week"; for quarterly contract then "quarter"
contract_code true string contract code "BTC180914" ...
direction true string "buy": to bid/ go long; "sell": to ask/ go short.
offset true string "open": open positions; "close": close positions
trade_volume true decimal the number of traded contract with unit of lot
trade_price true decimal the price at which orders get filled
trade_turnover true decimal the number of total traded amout with number of USD
create_date true long the time when orders get filled
offset_profitloss true decimal profits and losses generated from closing positions
traded_fee true decimal fees charged by platform
role true string taker or maker
</list>
total_page true int total pages
current_page true int current page
total_size true int total size of the list
</object>
ts true long timestamp

Notice

HuobiDM Transferring Interface

Transfer margin between Spot account and Future account

Example

Notice

This interface is used to transfer assets between Spot account and Future account.

The type is “pro-to-futures” when transferring assets from Spot account to Future; “futures-to-pro” when transferring from Future account to Spot account.

API rate limit for this interface is up to 10 times per minute.

Request Parameter

Parameter Name Mandatory Type Desc Default Value Range
currency true string currency e.g. btc
amount true Decimal Transferring amount
type true string type of the transfer Transfer from Future account to Spot account: “futures-to-pro” Transfer from Spot account to Future account: "pro-to-futures"

Response:

    {
    "status": "ok",
    "data":56656,
    }
    Error response
    {
    "status": "error",
    "data":null,
    "err-code":"dw-account-transfer-error",
    "err-msg":"account transfer error"
    }

Returning Parameter

Parameter Name Mandatory Type Desc Value Range
status true string Response status ok, error
data true long Transfer ID If status="error", data will be null.
order_id true long order ID
err-code true string Error code
err-msg true string Error code description

Error Code Table

err-code err-msg Comments
base-msg Other errors, please refer to err-msg list below for details。
base-currency-error The currency is invalid
frequent-invoke the operation is too frequent. Please try again later
banned-by-blacklist Blacklist restriction
dw-insufficient-balance Insufficient balance. You can only transfer {0} at most.
dw-account-transfer-unavailable account transfer unavailable
dw-account-transfer-error account transfer error
dw-account-transfer-failed Failed to transfer. Please try again later.
dw-account-transfer-failed-account-abnormality Account abnormality, failed to transfer。Please try again later.

Error message when err-code is ‘base-msg’.

err-msg Comments
Unable to transfer in currently. Please contact customer service.
Unable to transfer out currently. Please contact customer service.
Abnormal contracts status. Can’t transfer.
Sub-account doesn't own the permissions to transfer in. Please contact customer service.
Sub-account doesn't own the permissions to transfer out. Please contact customer service.
The sub-account does not have transfer permissions. Please login main account to authorize.
Insufficient amount available. Insufficient amount of Future Contract Account
The single transfer-out amount must be no less than {0}{1}.
The single transfer-out amount must be no more than {0}{1}.
The single transfer-in amount must be no less than {0}{1}.
The single transfer-in amount must be no more than {0}{1}.
Your accumulative transfer-out amount is over the daily maximum, {0}{1}. You can't transfer out for the time being.
Your accumulative transfer-in amount is over the daily maximum, {0}{1}. You can't transfer in for the time being.
Your accumulative net transfer-out amount is over the daily maximum, {0}{1}. You can't transfer out for the time being.
Your accumulative net transfer-in amount is over the daily maximum, {0}{1}. You can't transfer in for the time being.
The platform's accumulative transfer-out amount is over the daily maximum. You can't transfer out for the time being.
The platform's accumulative transfer-in amount is over the daily maximum. You can't transfer in for the time being.
The platform's accumulative net transfer-out amount is over the daily maximum. You can't transfer out for the time being.
The platform's accumulative net transfer-in amount is over the daily maximum. You can't transfer in for the time being.
Transfer failed. Please try again later or contact customer service.
Abnormal service, transfer failed. Please try again later.
You don’t have access permission as you have not opened contracts trading.
This contract type doesn't exist.

HuobiDM Websocket Subscription