Introduction
API Documentation Summary
Welcome to the Huobi USDT Margined Contracts API! You can use our API to access all market data, trading, and account management endpoints.
We have code examples in Shell! You can view code examples in the dark area to the right.
Market Maker Program
Market maker program gives clients with good market making strategy an opportunity to have customized trading fee structure.
Eligibility Criteria as a Market Maker on Huobi Futures
Welcome users, who are dedicated to maker strategy and have created large trading volume, to participate in Huobi Futures long-term Market Maker project.If you have more than 3 BTC in your Huobi future account, or more than 3 BTC in your Huobi coin margined swap account, or more than 100000 USDT in your Huobi USDT Margined Contracts account, please send the following information to Vip@global-hgroup.com:
- Huobi UIDs (not linked to any rebate program in any accounts)
- Provide screenshot of trading volume for the past 30 days or VIP/corporate status with other Exchanges
More detail in here: Huobi USDT-Margined Contracts Market Maker Preferential Policy
Colocation
Solution Architecture
Huobi swap API colocation solution is built on AWS infrastructure. Client will connect via AWS “PrivateLink” to access Huobi’s services directly through fast AWS connection without being routed to public networks.
Performance Improvement
The network delay of colocation solution is estimated to be 10ms to 50ms faster than the ordinary connection. This improvement estimated should be used as a guidance only as the actual improvement depends on many factors.
Eligibility
Colocation is only available to higher tier market makers. To check if your account is eligible please talk to your dedicated account manager.
Setting
Detail in here: Huobi Futures Colocation
Risk Mechanism
Partial Liquidation
Margin ratio is an indicator to estimate the risk of users’assets. When the margin ratio is less than or equal to 0%, liquidation will be triggered.
It is recommended that you pay close attention to margin ratio changes, so as to avoid your positions from liquidation.
Huobi contracts implement a partial liquidation mechanism, in which the system will lower the corresponding tier of an adjustment factor to avoid your positions from being liquidated at one time.
More detail to see: Partial Liquidation
Insurance Funds and Clawback Mechanism
Insurance funds are designed to cover the losses from forced liquidation.
In a fluctuating market, users’ positions may be liquidated. When the order cannot be filled at the takeover price, resulting in huge losses that are greater than the part insurance funds can undertake, the platform will implement the “clawback” mechanism. Each profitable account in the current period compensates the over loss of liquidation according to its profit ratio.
More detail in here: Partial Liquidation
Tiered Adjustment Factor
The adjustment factor is designed to prevent users from extended margin call loss. Huobi Contracts use a tiered adjustment factor mechanism, which supports up to five tiers based on the position amount.
For contracts with different expirations under the different account modes, they are separately calculated. The larger the use’s net positions, the higher the tier, and the greater the risk.
More detail in here: Tiered Adjustment Factor of USDT-margined Contract
Matching Mechanism
- Matching System: Order accepted by the Order System will enter the Matching System. Once orders are matched/filled, the settlement service will be executed and the matching result will be returned to the Order System; otherwise, the unfilled orders will go into the order book for matching.
- Price Priority: Higher-priced buy orders have priority over lower-priced buy orders; the reverse is true, lower-priced sell orders have priority over higher-priced sell orders.
- Time Priority: Buy orders at the same price are executed according to the time of entry to the Server.
- When the highest bid price is the same as the lowest ask price of the order book, this price is what we call transaction price.
- When the bid price is higher than the lowest ask price of the order book up to the minute, the lowest ask price will be the transaction price.
- When the ask price is lower than the highest bid price of the order book up to the minute, the highest bid price will be the transaction price.
Changelog
1.1.8 2022-11-10 [Added interface]
1、Added Account type query
- Interface Name: Account type query
- Interface URL: /linear-swap-api/v3/swap_unified_account_type
2、Added Account Type Change
- Interface Name: Account Type Change
- Interface URL: /linear-swap-api/v3/swap_switch_account_type
1.1.8 2022-09-01 [Added V3 interface]
1、Added [General] Query account financial
- Interface Name: [General] Query account financial
- Interface URL: /linear-swap-api/v3/swap_financial_record
- Original Interface URL: /linear-swap-api/v1/swap_financial_record
2、Added [General]Query account financial records via Multiple Fields(New)
- Interface Name: [General]Query account financial records via Multiple Fields(New)
- Interface URL: /linear-swap-api/v3/swap_financial_record_exact
- Original Interface URL: /linear-swap-api/v1/swap_financial_record_exact
3、Added [Cross]Get History Match Results via Multiple Fields(New)
- Interface Name: [Cross]Get History Match Results via Multiple Fields(New)
- Interface URL: /linear-swap-api/v3/swap_cross_matchresults_exact
- Original Interface URL: /linear-swap-api/v1/swap_cross_matchresults_exact
4、Added [Cross] Get History Match Results(New)
- Interface Name: [Cross] Get History Match Results(New)
- Interface URL: /linear-swap-api/v3/swap_cross_matchresults
- Original Interface URL: /linear-swap-api/v1/swap_cross_matchresults
5、Added [Isolated]Get History Match Results via Multiple Fields(New)
- Interface Name: [Isolated]Get History Match Results via Multiple Fields(New)
- Interface URL: /linear-swap-api/v3/swap_matchresults_exact
- Original Interface URL: /linear-swap-api/v1/swap_matchresults_exact
6、Added [Isolated] Acquire History Match Results(New)
- Interface Name: [Isolated] Acquire History Match Results(New)
- Interface URL: /linear-swap-api/v3/swap_matchresults
- Original Interface URL: /linear-swap-api/v1/swap_matchresults
7、Added [Cross]Get History Orders via Multiple Fields(New)
- Interface Name: [Cross]Get History Orders via Multiple Fields(New)
- Interface URL: /linear-swap-api/v3/swap_cross_hisorders_exact
- Original Interface URL: /linear-swap-api/v1/swap_cross_hisorders_exact
8、Added [Cross] Get History Orders(New)
- Interface Name: [Cross] Get History Orders(New)
- Interface URL: /linear-swap-api/v3/swap_cross_hisorders
- Original Interface URL: /linear-swap-api/v1/swap_cross_hisorders
9、Added [Isolated] Get History Orders via Multiple Fields(New)
- Interface Name: [Isolated] Get History Orders via Multiple Fields(New)
- Interface URL: /linear-swap-api/v3/swap_hisorders_exact
- Original Interface URL: /linear-swap-api/v1/swap_hisorders_exact
10、Added [Isolated] Get History Orders(New)
- Interface Name: [Isolated] Get History Orders(New)
- Interface URL: /linear-swap-api/v3/swap_hisorders
- Original Interface URL: /linear-swap-api/v1/swap_hisorders
11、Added [General] Query Liquidation Orders(New)
- Interface Name: [General] Query Liquidation Orders(New)
- Interface URL: /linear-swap-api/v3/swap_liquidation_orders
- Original Interface URL: /linear-swap-api/v1/swap_liquidation_orders
1.1.7 2022-06-24 [Modify the interface restriction content using lever]
1、Modified Place a Batch of Orders (Isolated)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [Isolated]Place a Batch of Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_batchorder
2、Modified Place a Batch of Orders (cross)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [Cross]Place a Batch of Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_batchorder
3、Modified Place an Order (Isolated)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [Isolated]Place an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order
4、Modified Place an Order (Cross)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [Cross]Place an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order
5、Modified Place Trigger Order (Isolated)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [Isolated]Place Trigger Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_trigger_order
6、Modified Place Trigger Order (Cross)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [Cross]Place Trigger Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_order
7、Modified Switch Leverage (General)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [General]Switch Leverage
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_switch_lever_rate
8、Modify Switch Leverage (Isolated)(Request parameter lever_rate field removes the restrictions of the master account high leverage agreement)
- Interface Name: [Isolated]Switch Leverage
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_switch_lever_rate
1.1.6 2022-04-24 [Added Get a Batch of Market Data Overview(V2) interface]
1. Added Get a Batch of Market Data Overview(V2) interface
- Interface Name: [General]Get a Batch of Market Data Overview(V2)
- Interface Type: public
- Interface URL: /v2/linear-swap-ex/market/detail/batch_merged
1.1.5 2022-02-25 [Added interface and other content about One-way Mode]
1. Added Switch Position Mode(isolated) interface
- Interface Name: [Isolated]Switch Position Mode
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_switch_position_mode
2. Added Switch Position Mode(cross) interface
- Interface Name: [Cross]Switch Position Mode
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_switch_position_mode
3. Modified Query User’s Position Information(isolated) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Isolated]Query User’s Position Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_account_info
4. Modified Query User’s Position Information(cross) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Cross]Query User’s Position Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_account_info
5. Modified Query a single sub-account's assets information(isolated) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Isolated]Query a single sub-account's assets information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_sub_account_info
6. Modified Query a single sub-account's assets information(cross) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Cross]Query a single sub-account's assets information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_sub_account_info
7. Modified Query Assets And Positions(isolated) interface(Add position_mode field in the response "data" and "positions", indicating the position mode of the current contract.)
- Interface Name: [Isolated]Query Assets And Positions
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_account_position_info
8. Modified Query Assets And Positions(cross) interface(Add position_mode field in the response "data" and "positions", indicating the position mode of the current contract.)
- Interface Name: [Cross]Query Assets And Positions
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_account_position_info
9. Modified Subscribe Account Equity Updates Data(sub)(isolated) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Isolated]Subscribe Account Equity Updates Data(sub)
- Interface Type: private
- Subscription topic: accounts.$contract_code
10. Modified Subscribe Account Equity Updates Data(sub)(cross) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Cross]Subscribe Account Equity Updates Data(sub)
- Interface Type: private
- Subscription topic: accounts_cross.$margin_account
11. Modified Query User’s Position Information(isolated) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Isolated]Query User’s Position Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_position_info
12. Modified Query User’s Position Information(cross) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Cross]Query User’s Position Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_position_info
13. Modified Query a single sub-account's position information(isolated) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Isolated]Query a single sub-account's position information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_sub_position_info
14. Modified Query a single sub-account's position information(cross) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Cross]Query a single sub-account's position information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_sub_position_info
15. Modified Subscribe Position Updates(sub)(isolated) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Isolated]Subscribe Position Updates(sub)
- Interface Type: private
- Subscription topic: positions.$contract_code
16. Modified Subscribe Position Updates(sub)(cross) interface(Add position_mode field in the response "data", indicating the position mode of the current contract.)
- Interface Name: [Cross]Subscribe Position Updates(sub)
- Interface Type: private
- Subscription topic: positions_cross.$contract_code
17. Modified Place an Order(isolated) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Isolated]Place an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order
18. Modified Place an Order(cross) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Cross]Place an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order
19. Modified Place a Batch of Orders(isolated) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Isolated]Place a Batch of Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_batchorder
20. Modified Place a Batch of Orders(cross) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Cross]Place a Batch of Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_batchorder
21. Modified Place Trigger Order(isolated) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Isolated]Place Trigger Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_trigger_order
22. Modified Place Trigger Order(cross) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Cross]Place Trigger Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_order
23. Modified Place a Trailing Order(isolated) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Isolated]Place a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_order
24. Modified Place a Trailing Order(cross) interface(Added an optional parameter reduce_only, indicating whether it is a reduction-only order, 1 means yes, and 0 means no. In hedge mode it is invalid, and in one-way mode it's value is 0 when not filled. The input parameter offset is changeded to optional. In hedge mode it is a required field, and in the one-way mode it is optional paramater which's value must be both when filled.)
- Interface Name: [Cross]Place a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_order
25. Modified Get Information of an Order(isolated) interface(Added reduce_only in the response "data" parameter, indicating whether it is only reduced position.)
- Interface Name: [Isolated] Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_info
26. Modified Get Information of an Order(cross) interface(Added reduce_only in the response "data" parameter, indicating whether it is only reduced position.)
- Interface Name: [Cross] Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_info
27. Modified Order details acquisition(isolated) interface(Added reduce_only in the response "data" parameter, indicating whether it is only reduced position.)
- Interface Name: [Isolated]Order details acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_detail
28. Modified Order details acquisition(cross) interface(Added reduce_only in the response "data" parameter, indicating whether it is only reduced position.)
- Interface Name: [Cross]Order details acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_detail
29. Modified Current unfilled order acquisition(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Current unfilled order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_openorders
30. Modified Current unfilled order acquisition(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Current unfilled order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_openorders
31. Modified Get History Orders(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Isolated] Get History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_hisorders
32. Modified Get History Orders(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Cross] Get History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_hisorders
33. Modified Get History Orders via Multiple Fields(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Get History Orders via Multiple Fields
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_hisorders_exact
34. Modified Get History Orders via Multiple Fields(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Get History Orders via Multiple Fields
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_hisorders_exact
35. Modified Acquire History Match Results(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "trades", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Acquire History Match Results
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_matchresults
36. Modified Acquire History Match Results(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "trades", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Acquire History Match Results
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_matchresults
37. Modified Get History Match Results via Multiple Fields(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "trades", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Get History Match Results via Multiple Fields
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_matchresults_exact
38. Modified Get History Match Results via Multiple Fields(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "trades", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Get History Match Results via Multiple Fields
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_matchresults_exact
39. Modified Query Trigger Order Open Orders(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Query Trigger Order Open Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_trigger_openorders
40. Modified Query Trigger Order Open Orders(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Query Trigger Order Open Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_openorders
41. Modified Query Trigger Order History(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Query Trigger Order History
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_trigger_hisorders
42. Modified Query Trigger Order History(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Query Trigger Order History
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_hisorders
43. Modified Current unfilled trailing order acquisition(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Current unfilled trailing order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_openorders
44. Modified Current unfilled trailing order acquisition(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Current unfilled trailing order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_openorders
45. Modified Get History Trailing Orders(isolated) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Get History Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_hisorders
46. Modified Get History Trailing Orders(cross) interface(Added two enumeration value for trade_type parameter: 17 buy and 18 sell(one-way mode), and added reduce_only filed in response "orders", indicating whether it is only reducing the position.)
- Interface Name: [Cross]Get History Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_hisorders
47. Modified Subscribe Order Data(sub)(isolated) interface(Added reduce_only parameter in response, indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Subscribe Order Data(sub)
- Interface Type: private
- Subscription topic: orders.$contract_code
48. Modified Subscribe Order Data(sub)(cross) interface(Added reduce_only parameter in response, indicating whether it is only reducing the position.)
- Interface Name: [Cross]Subscribe Order Data(sub)
- Interface Type: private
- Subscription topic: orders_cross.$contract_code
49. Modified Subscribe Match Order Data(sub)(isolated) interface(Added reduce_only parameter in response, indicating whether it is only reducing the position.)
- Interface Name: [Isolated]Subscribe Match Order Data(sub)
- Interface Type: private
- Subscription topic: matchOrders.$contract_code
50. Modified Subscribe Match Order Data(sub)(cross) interface(Added reduce_only parameter in response, indicating whether it is only reducing the position.)
- Interface Name: [Cross]Subscribe Match Order Data(sub)
- Interface Type: private
- Subscription topic: matchOrders_cross.$contract_code
51. Modified Subscribe trigger orders updates(sub)(isolated) interface(Added reduce_only in the response "data" parameter, indicating whether it is only reduced position.)
- Interface Name: [Isolated]Subscribe trigger orders updates(sub)
- Interface Type: private
- Subscription topic: trigger_order.$contract_code
52. Modified Subscribe trigger orders updates(sub)(cross) interface(Added reduce_only in the response "data" parameter, indicating whether it is only reduced position.)
- Interface Name: [Cross]Subscribe trigger orders updates(sub)
- Interface Type: private
- Subscription topic: trigger_order_cross.$contract_code
1.1.4 2021-12-22 【Added the content about USDT Margined Futures interfaces】
1. Modified Query Swap Info interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": contract_type, pair, business_type, delivery_date(contract delivery date, this field is an empty string when it is swap contract))
- Interface Name: [General]Query Swap Info
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_contract_info
2. Modified Query Swap Price Limitation interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": contract_type, business_type, pair)
- Interface Name: [General]Query Swap Price Limitation
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_price_limit
3. Modified Get Swap Open Interest Information interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Get Swap Open Interest Information
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_open_interest
4. Modified Query information on contract insurance fund balance and estimated clawback rate interface(Add optional parameters in request: business_type. Add fields in return parameter "data": business_type, pair)
- Interface Name: [General]Query information on contract insurance fund balance and estimated clawback rate
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_risk_info
5. Modified Query history records of insurance fund balance interface( Add fields in return parameter "data": business_type, pair)
- Interface Name: [General]Query history records of insurance fund balance
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_insurance_fund
6. Modified Query Information On Tiered Adjustment Factor(Cross) interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query Information On Tiered Adjustment Factor
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_cross_adjustfactor
7. Modified Query information on open interest interface(Add optional parameters in request: contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query information on open interest
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_his_open_interest
8. Modified Query Top Trader Sentiment Index Function-Account interface(Add fields in return parameter "data": business_type, pair)
- Interface Name: [General]Query Top Trader Sentiment Index Function-Account
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_elite_account_ratio
9. Modified Query Top Trader Sentiment Index Function-Position interface(Add fields in return parameter "data": business_type, pair)
- Interface Name: [General]Query Top Trader Sentiment Index Function-Position
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_elite_position_ratio
10. Modified Query Liquidation Orders interface(Add optional parameters in request: pair. Add fields in return parameter "data.orders": business_type, pair)
- Interface Name: [General]Query Liquidation Orders
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_liquidation_orders
11. Modified Query historical settlement records of the platform interface(Add fields in return parameter "data.settlement_record": business_type, pair)
- Interface Name: [General]Query historical settlement records of the platform
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_settlement_records
12. Modified Get the estimated settlement price interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Get the estimated settlement price
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_estimated_settlement_price
13. Modified Query Information On Trade State(Cross) interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query Information On Trade State
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_cross_trade_state
14. Modified Get Market Depth interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Get Market Depth
- Interface Type: public
- Interface URL: /linear-swap-ex/market/depth
15. Modified Get KLine Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Get KLine Data
- Interface Type: public
- Interface URL: /linear-swap-ex/market/history/kline
16. Modified Query information on Tiered Margin (Cross) interface(Add optional parameters in request: business_type, contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query information on Tiered Margin
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_cross_ladder_margin
17. Modified Get Market BBO Data interface(Add one optional parameter in request: business_type. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly). Add one field in return parameter "ticks": business_type)
- Interface Name: [General]Get Market BBO Data
- Interface Type: public
- Interface URL: /linear-swap-ex/market/bbo
18. Modified Get Market Data Overview interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Get Market Data Overview
- Interface Type: public
- Interface URL: /linear-swap-ex/market/detail/merged
19. Modified Get a Batch of Market Data Overview interface(Add one optional parameter in request: business_type. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly). Add one field in return parameter "data": business_type)
- Interface Name: [General]Get a Batch of Market Data Overview
- Interface Type: public
- Interface URL: /linear-swap-ex/market/detail/batch_merged
20. Modified Query Basis Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Query Basis Data
- Interface Type: public
- Interface URL: /index/market/history/linear_swap_basis
21. Modified Get Kline Data of Mark Price interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Get Kline Data of Mark Price
- Interface Type: public
- Interface URL: /index/market/history/linear_swap_mark_price_kline
22. Modified Query The Last Trade of a Contract interface(Add one optional parameter in request: business_type. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly). Add one field in return parameter "data": business_type)
- Interface Name: [General]Query The Last Trade of a Contract
- Interface Type: public
- Interface URL: /linear-swap-ex/market/trade
23. Modified Query a Batch of Trade Records of a Contract interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Query a Batch of Trade Records of a Contract
- Interface Type: public
- Interface URL: /linear-swap-ex/market/history/trade
24. Modified Query User's Account Information(Cross) interface( Added a field futures_contract_detail under the data field, indicating the relevant fields of all delivery contracts in the cross margin model. the member fields of futures_contract_detail are as same as the contract_detail. Add fields in return parameter "contract_detail","futures_contract_detail": contract_type, business_type, pair)
- Interface Name: [General]Query User's Account Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_account_info
25. Modified Query User's Position Information(Cross) interface(Add optional parameters in request: contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query User's Position Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_position_info
26. Modified Query A Sub-Account's Assets Information(Cross) interface( Added a field futures_contract_detail under the data field, indicating the relevant fields of all delivery contracts in the cross margin model. the member fields of futures_contract_detail are as same as the contract_detail. Add fields in return parameter "contract_detail","futures_contract_detail": contract_type, business_type, pair)
- Interface Name: [General]Query A Sub-Account's Assets Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_sub_account_info
27. Modified Query A Sub-Account's Position Information(Cross) interface(Add optional parameters in request: contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query A Sub-Account's Position Information
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_sub_position_info
28. Modified Query account financial recordsinterface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-211225)
- Interface Name: [General]Query account financial records
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_financial_record
29. Modified Query account financial records via Multiple Fieldsinterface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-211225)
- Interface Name: [General]Query account financial records via Multiple Fields
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_financial_record_exact
30. Modified Query swap information on order limit interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query swap information on order limit
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_limit
31. Modified Query information on swap trading fee interface(Add optional parameters in request: business_type, contract_type, pair. Add fields in return parameter "data": contract_type, business_type, pair, delivery_fee)
- Interface Name: [General]Query information on swap trading fee
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_fee
32. Modified Query Information On Position Limit (Cross) interface(Add optional parameters in request: business_type, contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101. Add fields in return parameter "data": business_type, contract_type, pair,lever_rate, buy_limit_value, sell_limit_value, mark_price)
- Interface Name: [General]Query Information On Position Limit
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_position_limit
33. Modified Query Assets And Positions(Cross) interface(Added a field futures_contract_detail under the data field, indicating the relevant fields of all delivery contracts in the cross margin model. the member fields of futures_contract_detail are as same as the contract_detail. Add fields in return parameters "positions","contract_detail" and "futures_contract_detail": contract_type, business_type, pair)
- Interface Name: [General]Query Assets And Positions
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_account_position_info
34. Modified Query Settlement Records of Users(Cross) interface(Add one field in return parameters "contract_detail" and "positions": pair)
- Interface Name: [General]Query Settlement Records of Users
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_user_settlement_records
35. Modified Query User’s Available Leverage(Cross) interface(Add optional parameters in request: business_type, contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query User’s Available Leverage
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_available_level_rate
36. Modified Switch Leverage(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101. Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Switch Leverage
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_switch_lever_rate
37. Modified Place An Order(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Place An Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order
38. Modified Place a Batch of Orders(Cross) interface(orders_data Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Place a Batch of Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_batchorder
39. Modified Cancel An Order(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel An Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_cancel
40. Modified Cancel All Orders(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel All Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_cancelall
41. Modified Get Information of order(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Get Information of order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_info
42. Modified Get Detail Information of order(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Get Detail Information of order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_detail
43. Modified Current unfilled order acquisition(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data.orders": contract_type, business_type, pair)
- Interface Name: [General]Current unfilled order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_openorders
44. Modified Get History Orders(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data.orders": contract_type, business_type, pair)
- Interface Name: [General]Get History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_hisorders
45. Modified Get History Match Results(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter. Add fields in return parameter "data.trades": contract_type, business_type, pair)
- Interface Name: [General]Get History Match Results
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_matchresults
46. Modified Get History Orders via Multiple Fields(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data.orders": contract_type, business_type, pair)
- Interface Name: [General]Get History Orders via Multiple Fields
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_hisorders_exact
47. Modified Get History Match Results via Multiple Fields(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter. Add fields in return parameter "data.trades": contract_type, business_type, pair)
- Interface Name: [General]Get History Match Results via Multiple Fields
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_matchresults_exact
48. Modified Place Lightning Close Position(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Place Lightning Close Position
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_lightning_close_position
49. Modified Place Trigger Order(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Place Trigger Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_order
50. Modified Cancel Trigger Order(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel Trigger Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_cancel
51. Modified Cancel All Trigger Orders(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel All Trigger Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_cancelall
52. Modified Query Trigger Order Open Orders(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data.orders": contract_type, business_type, pair)
- Interface Name: [General]Query Trigger Order Open Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_openorders
53. Modified Query Trigger Order History(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data.orders": contract_type, business_type, pair)
- Interface Name: [General]Query Trigger Order History
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_hisorders
54. Modified Set a Take-profit and Stop-loss Order for an Existing Position(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Set a Take-profit and Stop-loss Order for an Existing Position
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_order
55. Modified Cancel a Take-profit and Stop-loss Order(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel a Take-profit and Stop-loss Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_cancel
56. Modified Cancel all Take-profit and Stop-loss Orders(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel all Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_cancelall
57. Modified Query Open Take-profit and Stop-loss Orders(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data.orders": contract_type, business_type, pair)
- Interface Name: [General]Query Open Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_openorders
58. Modified Query Take-profit and Stop-loss History Orders(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data.orders": contract_type, business_type, pair)
- Interface Name: [General]Query Take-profit and Stop-loss History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_hisorders
59. Modified Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_relation_tpsl_order
60. Modified Place a Trailing Order(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Place a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_order
61. Modified Cancel a Trailing Order(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_cancel
62. Modified Cancel All Trailing Orders(Cross) interface(Add optional parameters in request: contract_type, pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter)
- Interface Name: [General]Cancel All Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_cancelall
63. Modified Current unfilled trailing order acquisition(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Current unfilled trailing order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_openorders
64. Modified Get History Trailing Orders(Cross) interface(Add one optional parameter in request: pair. The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101 and it has be changed to be optional parameter.Add fields in return parameter "data": business_type, contract_type, pair)
- Interface Name: [General]Get History Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_hisorders
65. Modified Subscribe Kline data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe Kline data
- Interface Type: public
- Subscription topic: market.$contract_code.kline.$period
66. Modified Request Kline data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Request Kline data
- Interface Type: public
- Subscription topic: market.$contract_code.kline.$period
67. Modified Subscribe Market Depth Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe Market Depth Data
- Interface Type: public
- Subscription topic: market.$contract_code.depth.$type
68. Modified Subscribe Incremental Market Depth Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe Incremental Market Depth Data
- Interface Type: public
- Subscription topic: market.$contract_code.depth.size_${size}.high_freq
69. Modified Subscribe market BBO data push interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe market BBO data push
- Interface Type: public
- Subscription topic: market.$contract_code.bbo
70. Modified Subscribe Market Detail Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe Market Detail Data
- Interface Type: public
- Subscription topic: market.$contract_code.detail
71. Modified Request Trade Detail Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Request Trade Detail Data
- Interface Type: public
- Subscription topic: market.$contract_code.trade.detail
72. Modified Subscribe Trade Detail Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe Trade Detail Data
- Interface Type: public
- Subscription topic: market.$contract_code.trade.detail
73. Modified Subscribe Basis Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe Basis Data
- Interface Type: public
- Subscription topic: market.$contract_code.basis.$period.$basis_price_type
74. Modified Request Basis Data interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Request Basis Data
- Interface Type: public
- Subscription topic: market.$contract_code.basis.$period.$basis_price_type
75. Modified Subscribe Liquidation Orders(no authentication)(sub) interface(Add one optional field in the outer layer of subscription parameters: business_type, which is at the same level as topic. Add fields in the return parameter "data": pair, contract_type, business_type. All of that is at the same level as contract_code. business_type should be filled when unsubscribed)
- Interface Name: [General]Subscribe Liquidation Orders(no authentication)(sub)
- Interface Type: private
- Subscription topic: public.$contract_code.liquidation_orders
76. Modified Subscribe Contract Info(no authentication)(sub) interface(Add one optional field in the outer layer of subscription parameters: business_type, which is at the same level as topic.Add fields in the return parameter "data": pair, contract_type, business_type, delivery_date. All of that is at the same level as contract_code. business_type should be filled when unsubscribed)
- Interface Name: [General]Subscribe Contract Info(no authentication)(sub)
- Interface Type: private
- Subscription topic: public.$contract_code.contract_info
77. Modified Subscribe Kline Data of Mark Priceinterface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Subscribe Kline Data of Mark Price
- Interface Type: public
- Subscription topic: market.$contract_code.mark_price.$period
78. Modified Request Kline Data of Mark Price interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; at the same time, it supports the contract identifier, in that the format is BTC-USDT(swap), BTC-USDT-CW(current week), BTC-USDT-NW(next week), BTC-USDT-CQ(current quarterly), BTC-USDT-NQ(next quarterly))
- Interface Name: [General]Request Kline Data of Mark Price
- Interface Type: public
- Subscription topic: market.$contract_code.mark_price.$period
79. Modified Subscribe Account Equity Updates Data(sub)(Cross) interface( Added a field futures_contract_detail under the data field, indicating the relevant fields of all delivery contracts in the cross margin model. the member fields of futures_contract_detail are as same as the contract_detail. Add fields in return parameter "contract_detail","futures_contract_detail": contract_type, business_type, pair)
- Interface Name: [General]Subscribe Account Equity Updates Data(sub)
- Interface Type: private
- Subscription topic: accounts_cross.$margin_account
80. Modified Subscribe Order Data(sub)(Cross) interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101. Add fields in the return data: pair, contract_type, business_type. All of that is at the same level as contract_code)
- Interface Name: [General]Subscribe Order Data(sub)
- Interface Type: private
- Subscription topic: orders_cross.$contract_code
81. Modified Subscribe Position Updates(sub)(Cross) interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101. Add fields in the return data: pair, contract_type, business_type. All of that is at the same level as contract_code)
- Interface Name: [General]Subscribe Position Updates(sub)
- Interface Type: private
- Subscription topic: positions_cross.$contract_code
82. Modified Subscribe Match Order Data(sub)(Cross) interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101. Add fields in the return data: pair, contract_type, business_type. All of that is at the same level as contract_code)
- Interface Name: [General]Subscribe Match Order Data(sub)
- Interface Type: private
- Subscription topic: matchOrders_cross.$contract_code
83. Modified Subscribe trigger orders updates(sub)(Cross) interface(The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101. Add fields in the return data: pair, contract_type, business_type. All of that is at the same level as contract_code)
- Interface Name: [General]Subscribe trigger orders updates(sub)
- Interface Type: private
- Subscription topic: trigger_order_cross.$contract_code
84, Modified Query Information On Position Limit(isolated) interface(Add returning parameters: lever_rate, buy_limit_value, sell_limit_value, mark_price)
- Interface Name: [Isolated]Query Information On Position Limit
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_position_limit
85, Added Query Users' Position Limit for All Leverages(isolated) interface
- Interface Name: [Isolated]Query Users' Position Limit for All Leverages
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_lever_position_limit
86, Added Query Users' Position Limit for All Leverages(cross) interface
- Interface Name: [Cross]Query Users' Position Limit for All Leverages
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_lever_position_limit
1.1.3 2021-5-17 【Transfer between master and sub account(Added parameters in request: client_order_id)。Transfer between different margin accounts under the same account(Added parameters in request: client_order_id)】
1、Transfer between master and sub account(Added parameters in request: client_order_id)
- Interface Name:[General]Transfer between master and sub account
- Interface Type:private
- Interface URL:/linear-swap-api/v1/swap_master_sub_transfer
2、Transfer between different margin accounts under the same account(Added parameters in request: client_order_id)
- Interface Name:[General]Transfer between different margin accounts under the same account
- Interface Type:private
- Interface URL:/linear-swap-api/v1/swap_transfer_inner
1.1.2 2021-05-12 【Added: Trailing Order interface. 】
1. Added Place a Trailing Order(isolated) interface
- Interface Name: [Isolated]Place a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_order
2. Added Place a Trailing Order(cross) interface
- Interface Name: [Cross]Place a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_order
3. Added Cancel a Trailing Order(isolated) interface
- Interface Name: [Isolated]Cancel a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_cancel
4. Added Cancel a Trailing Order(cross) interface
- Interface Name: [Cross]Cancel a Trailing Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_cancel
5. Added Cancel All Trailing Orders(isolated) interface
- Interface Name: [Isolated]Cancel All Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_cancelall
6. Added Cancel All Trailing Orders(cross) interface
- Interface Name: [Cross]Cancel All Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_cancelall
7. Added Current unfilled trailing order acquisition(isolated) interface
- Interface Name: [Isolated]Current unfilled trailing order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_openorders
8. Added Current unfilled trailing order acquisition(cross) interface
- Interface Name: [Cross]Current unfilled trailing order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_openorders
9. Added Get History Trailing Orders(isolated) interface
- Interface Name: [Isolated]Get History Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_track_hisorders
10. Added Get History Trailing Orders(cross) interface
- Interface Name: [Cross]Get History Trailing Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_track_hisorders
1.1.1 2021-04-29 【Modified Cancel an Order(Change the valid time of the client_order_id from 24 hours to 8 hours. Clients can't get the order info with client_order_id which order placed beyond 8 hours). Modified Get Information of an Order(Change the valid time of the client_order_id from 24 hours to 8 hours. Clients can't get the order info with client_order_id which order placed beyond 8 hours.Client can query the order info which has been cancelled within 2 hours(original is 4 hours))】
1. Modified Cancel an Order(isolated) interface(Change the valid time of the client_order_id from 24 hours to 8 hours. Clients can't get the order info with client_order_id which order placed beyond 8 hours)
- Interface Name: [Isolated]Cancel an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cancel
2. Modified Cancel an Order(cross) interface(Change the valid time of the client_order_id from 24 hours to 8 hours. Clients can't get the order info with client_order_id which order placed beyond 8 hours)
- Interface Name: [Cross]Cancel an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_cancel
3. Modified Get Information of an Order(isolated) interface(Change the valid time of the client_order_id from 24 hours to 8 hours. Clients can't get the order info with client_order_id which order placed beyond 8 hours. Client can query the order info which has been cancelled within 2 hours(original is 4 hours))
- Interface Name: [Isolated]Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_info
4. Modified Get Information of an Order(cross) interface(Change the valid time of the client_order_id from 24 hours to 8 hours. Clients can't get the order info with client_order_id which order placed beyond 8 hours. Client can query the order info which has been cancelled within 2 hours(original is 4 hours))
- Interface Name: [Cross]Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_info
1.1.0 2021-4-28 【Added: Get Market BBO Data interface. 】
1. Added Get Market BBO Data interface
- Interface Name: [General]Get Market BBO Data
- Interface Type: public
- Interface URL: /linear-swap-ex/market/bbo
1.0.9 2021-2-26 【Added: Query Asset Valuation interface, Query a Batch of Funding Rate interface. Modified Query Swap Price Limitation interface(Support users not to fill in all input parameters, and the interface returns the price limit data of all available contracts). Modified Query The Last Trade of a Contract interface(Support users not to fill in all input parameters, the interface returns the latest transaction data of all available contracts; And in that case, the return parameter "ch" value is "market.*trade.detail". Added one field in return "tick" parameter: "contract_code")】
1. Added Query Asset Valuation interface
- Interface Name: [General]Query Asset Valuation
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_balance_valuation
2. Added Query a Batch of Funding Rate interface
- Interface Name: [General]Query a Batch of Funding Rate
- Interface Type: public
- interface URL: /linear-swap-api/v1/swap_batch_funding_rate
3. Modified Query Swap Price Limitation interface(Support users not to fill in all input parameters, and the interface returns the price limit data of all available contracts)
- Interface Name: [General]Query Swap Price Limitation
- Interface Type: public
- interface URL: /linear-swap-api/v1/swap_price_limit
4. Modified Query The Last Trade of a Contract interface(Support users not to fill in all input parameters, the interface returns the latest transaction data of all available contracts; And in that case, the return parameter "ch" value is "market.*trade.detail". Added one field in return "data" parameter: "contract_code")
- Interface Name: [General]Query The Last Trade of a Contract
- Interface Type: public
- interface URL: /linear-swap-ex/market/trade
1.0.8 2021-2-5 【Added: Get History Orders via Multiple Fields(cross margin and isolated margin), Get History Match Results via Multiple Fields(cross margin and isolated margin), Query account financial records via Multiple Fields, Query information on Tiered Margin(cross margin and isolated margin), Set a Batch of Sub-Account Trading Permissions, Query a Batch of Sub-Account's Assets Information(cross margin and isolated margin)。11-14 Modified the existing interfaces and added new parameters】
1. Added Get History Orders via Multiple Fields interface[Isolated]
- Interface Name: [Isolated]Get History Orders via Multiple Fields
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_hisorders_exact
2. Added Get History Orders via Multiple Fields interface[Cross]
- Interface Name: [Cross]Get History Orders via Multiple Fields
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_cross_hisorders_exact
3. Added Get History Match Results via Multiple Fields interface[Isolated]
- Interface Name: [Isolated]Get History Match Results via Multiple Fields
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_matchresults_exact
4. Added Get History Match Results via Multiple Fields interface[Cross]
- Interface Name: [Cross]Get History Match Results via Multiple Fields
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_cross_matchresults_exact
5. Added Query account financial records via Multiple Fields interface
- Interface Name: [General]Query account financial records via Multiple Fields
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_financial_record_exact
6. Added Query information on Tiered Margin interface[Isolated]
- Interface Name: [Isolated]Query information on Tiered Margin
- Interface Type: public
- interface URL: /linear-swap-api/v1/swap_ladder_margin
7. Added Query information on Tiered Margin interface[Cross]
- Interface Name: [Cross]Query information on Tiered Margin
- Interface Type: public
- interface URL: /linear-swap-api/v1/swap_cross_ladder_margin
8. Added Set a Batch of Sub-Account Trading Permissions interface
- Interface Name: [General]Set a Batch of Sub-Account Trading Permissions
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_sub_auth
9. Added Query a Batch of Sub-Account's Assets Information interface[Isolated]
- Interface Name: [Isolated]Query a Batch of Sub-Account's Assets Information
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_sub_account_info_list
10. Added Query a Batch of Sub-Account's Assets Information interface[Cross]
- Interface Name: [Cross]Query a Batch of Sub-Account's Assets Information
- Interface Type: private
- interface URL: /linear-swap-api/v1/swap_cross_sub_account_info_list
11. Modified Query The Last Trade of a Contract interface(Added "quantity" in return parameter "data", which means the trading quantity(coin), Calculation formula: quantity(coin) = trading quantity(cont) * contract size. Added "trade_turnover" in return parameter "data", which represents the trading amount(quoted currency). Calculation formula: trade_turnover(quoted currency) = trading quantity(cont) * contract size * trading price.)
- Interface Name: [General]Query The Last Trade of a Contract
- Interface Type: public
- interface URL: /linear-swap-ex/market/trade
12. Modified Query a Batch of Trade Records of a Contract interface(Added "quantity" in return parameter "data", which means the trading quantity(coin), Calculation formula: quantity(coin) = trading quantity(cont) * contract size. Added "trade_turnover" in return parameter "data", which represents the trading amount(quoted currency). Calculation formula: trade_turnover(quoted currency) = trading quantity(cont) * contract size * trading price.)
- Interface Name: [General]Query a Batch of Trade Records of a Contract
- Interface Type: public
- interface URL: /linear-swap-ex/market/history/trade
13. Modified Subscribe Trade Detail Data interface(Added "quantity" in return parameter "data", which means the trading quantity(coin), Calculation formula: quantity(coin) = trading quantity(cont) * contract size. Added "trade_turnover" in return parameter "data", which represents the trading amount(quoted currency). Calculation formula: trade_turnover(quoted currency) = trading quantity(cont) * contract size * trading price.)
- Interface Name: [General]Subscribe Trade Detail Data
- Interface Type: public
- Subscription topic: market.$contract_code.trade.detail
14. Modified Request Trade Detail Data interface(Added "quantity" in return parameter "data", which means the trading quantity(coin), Calculation formula: quantity(coin) = trading quantity(cont) * contract size. Added "trade_turnover" in return parameter "data", which represents the trading amount(quoted currency). Calculation formula: trade_turnover(quoted currency) = trading quantity(cont) * contract size * trading price.)
- Interface Name: [General]Request Trade Detail Data
- Interface Type: public
- Subscription topic: market.$contract_code.trade.detail
1.0.7 2021-1-29 【Added:Get a Batch of Market Data Overview、Get Kline Data of Mark Price、Subscribe Kline Data of Mark Price、Request Kline Data of Mark Price、Query Settlement Records of Users(Isolated and Cross). 7-28 Added fields to modify interface. The order_id of submitted trigger order response has been changed from the original natural number self-incrementing ID to a unique identification ID with a length of 18 digits. It is recommended to use the order_id_str (order_id in string type) of submitted order response to avoid the occurrence of truncation by the system because excessive length.】
1. Added Get a Batch of Market Data Overview
- Interface Name: [General]Get a Batch of Market Data Overview
- Interface Type: public
- Interface URL: /linear-swap-ex/market/detail/batch_merged
2. Added Get Kline Data of Mark Price
- Interface Name: [General]Get Kline Data of Mark Price
- Interface Type: public
- Interface URL: /index/market/history/linear_swap_mark_price_kline
3. Added Subscribe Kline Data of Mark Price
- Interface Name: [General]Subscribe Kline Data of Mark Price
- Interface Type: public
- Subscription topic: market.$contract_code.mark_price.$period
4. Added Request Kline Data of Mark Price
- Interface Name: [General]Request Kline Data of Mark Price
- Interface Type: public
- Subscription topic: market.$contract_code.mark_price.$period
5. Added [Isolated]Query Settlement Records of Users
- Interface Name: [Isolated]Query Settlement Records of Users
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_user_settlement_records
6. Added [Cross]Query Settlement Records of Users
- Interface Name: [Cross]Query Settlement Records of Users
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_user_settlement_records
7. Modified [Isolated]Cancel All Orders(Added two optional parameters in request: direction, indicates order direction, if not filled in means both with available values: “buy”, “sell”; offset, order offset, if not filled in means both with available values: “open”, “close”.)
- Interface Name: [Isolated]Cancel All Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cancelall
8. Modified [Cross]Cancel All Orders(Added two optional parameters in request: direction, indicates order direction, if not filled in means both with available values: “buy”, “sell”. offset, order offset, if not filled in means both with available values: “open”, “close”.)
- Interface Name: [Cross]Cancel All Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_cancelall
9. Modified [Isolated]Get Information of an Order(Added one field in return "data": real_profit(real profit when close position).)
- Interface Name: [Isolated]Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_info
10. Modified [Cross]Get Information of an Order(Added one field in return "data": real_profit(real profit when close position).)
- Interface Name: [Cross]Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_info
11. Modified [Isolated]Order details acquisition(Added field in return parameters both "data" and "trades": real_profit(real profit when close position). And added one filed in "trades" to indicates each trade profit:profit(profit when close position))
- Interface Name: [Isolated]Order details acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_detail
12. Modified [Cross]Order details acquisition(Added field in return parameters both "data" and "trades": real_profit(real profit when close position). And added one filed in "trades" to indicates each trade profit:profit(profit when close position))
- Interface Name: [Cross]Order details acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_detail
13. Modified [Isolated]Current unfilled order acquisition(Added two optional parameters in request: sort_by, is sort field, if not filled in means order by create_at descending, with available values “created_at”(descending order), “update_time”(descending order); trade_type, indicates trade type, if not filled in means all, with available values: 0:all, 1:open long, 2:open short, 3:close short, 4:close long. Added two fields in return parameter "orders": update_time(order updated time, in milliseconds), real_profit(real profit when close position).)
- Interface Name: [Isolated]Current unfilled order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_openorders
14. Modified [Cross]Current unfilled order acquisition(Added two optional parameters in request: sort_by, is sort field, if not filled in means order by create_at descending, with available values “created_at”(descending order), “update_time”(descending order); trade_type, indicates trade type, if not filled in means all, with available values: 0:all, 1:open long, 2:open short, 3:close short, 4:close long. Added two fields in return parameter "orders": update_time(order updated time, in milliseconds); real_profit(real profit when close position).)
- Interface Name: [Cross]Current unfilled order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_openorders
15. Modified [Isolated]Get History Orders(Added one field in return parameter "orders": real_profit(real profit when close position).)
- Interface Name: [Isolated]Get History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_hisorders
16. Modified [Cross]Get History Orders(Added one field in return parameter "orders": real_profit(real profit when close position).)
- Interface Name: [Cross]Get History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_hisorders
17. Modified [Isolated]Acquire History Match Results(Added one field in return parameter "trades": real_profit(real profit when close position).)
- Interface Name: [Isolated]Acquire History Match Results
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_matchresults
18. Modified [Cross]Acquire History Match Results(Added one field in return parameter "trades": real_profit(real profit when close position).)
- Interface Name: [Cross]Acquire History Match Results
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_matchresults
19. Modified [Isolated]Subscribe Order Data(sub)(Added one field in return data: real_profit(real profit when close position). added field in return parameter "trade": profit(profit when close position), real_profit(real profit when close position))
- Interface Name: [Isolated]Subscribe Order Data(sub)
- Interface Type: private
- Subscription topic: orders.$contract_code
20. Modified [Cross]Subscribe Order Data(sub)(Added one field in return data: real_profit(real profit when close position). added field in return parameter "trade": profit(profit when close position), real_profit(real profit when close position))
- Interface Name: [Cross]Subscribe Order Data(sub)
- Interface Type: private
- Subscription topic: orders_cross.$contract_code
21. Modified [Isolated]Cancel All Trigger Orders(Added two optional parameters in request: direction, indicates order direction, if not filled in means both with available values: “buy”, “sell”; offset, order offset, if not filled in means both with available values: “open”, “close”.)
- Interface Name: [Isolated]Cancel All Trigger Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_trigger_cancelall
22. Modified [Cross]Cancel All Trigger Orders(Added two optional parameters in request: direction, indicates order direction, if not filled in means both with available values: “buy”, “sell”; offset, order offset, if not filled in means both with available values: “open”, “close”.)
- Interface Name: [Cross]Cancel All Trigger Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_cancelall
23. Modified [Isolated]Cancel all Take-profit and Stop-loss Orders(Added one option parameter in request: direction, indicates order direction, if not filled in means cancel all)
- Interface Name: [Isolated]Cancel all Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_tpsl_cancelall
24. Modified [Cross]Cancel all Take-profit and Stop-loss Orders(Added one option parameter in request: direction, indicates order direction, if not filled in means cancle all)
- Interface Name: [Cross]Cancel all Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_cancelall
25. Modified [Isolated]Query Trigger Order Open Orders(Added one optional parameter in request: trade_type, order trade type, if not filled in means all with available values 0:all, 1:open long, 2:open short, 3:close short, 4:close long.)
- Interface Name: [Isolated]Query Trigger Order Open Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_trigger_openorders
26. Modified [Cross]Query Trigger Order Open Orders(Added one optional parameter in request: trade_type, order trade type, if not filled in means all with available values 0:all, 1:open long, 2:open short, 3:close short, 4:close long.)
- Interface Name: [Cross]Query Trigger Order Open Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_openorders
27. Modified [Isolated]Query Open Take-profit and Stop-loss Orders(Added one optional parameter in request: trade_type, order trade type, if not filled in means all with available values 0:all, 3:close short, 4:close long.)
- Interface Name: [Isolated]Query Open Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_tpsl_openorders
28. Modified [Cross]Query Open Take-profit and Stop-loss Orders(Added one optional parameter in request: trade_type, order trade type, if not filled in means all with available values 0:all, 3:close short, 4:close long.)
- Interface Name: [Cross]Query Open Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_openorders
1.0.6 2021-01-12 【1 Added Get the estimated settlement price. 2-13 Added ”Set a Take-profit and Stop-loss Order“ interfaces. 14-35 Added fields to modify interface. Added the first-level menu of [Contract Trigger Order], and add take-profit and stop-loss related interfaces and move the original contract trigger order related interfaces to this menu 】
1. Added Get the estimated settlement price
- Interface Name: [General]Get the estimated settlement price
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_estimated_settlement_price
2. Added Set a Take-profit and Stop-loss Order for an Existing Position(Isolated)
- Interface Name: [Isolated]Set a Take-profit and Stop-loss Order for an Existing Position
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_tpsl_order
3. Added Set a Take-profit and Stop-loss Order for an Existing Position(Cross)
- Interface Name: [Cross]Set a Take-profit and Stop-loss Order for an Existing Position
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_order
4. Added Cancel a Take-profit and Stop-loss Order(Isolated)
- Interface Name: [Isolated]Cancel a Take-profit and Stop-loss Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_tpsl_cancel
5. Added Cancel a Take-profit and Stop-loss Order(Cross)
- Interface Name: [Cross]Cancel a Take-profit and Stop-loss Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_cancel
6. Added Cancel all Take-profit and Stop-loss Orders(Isolated)
- Interface Name: [Isolated]Cancel all Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_tpsl_cancelall
7. Added Cancel all Take-profit and Stop-loss Orders(Cross)
- Interface Name: [Cross]Cancel all Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_cancelall
8. Added Query Open Take-profit and Stop-loss Orders (Isolated)
- Interface Name: [Isolated]Query Open Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_tpsl_openorders
9. Added Query Open Take-profit and Stop-loss Orders(Cross)
- Interface Name: [Cross]Query Open Take-profit and Stop-loss Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_openorders
10. Added Query Take-profit and Stop-loss History Orders(Isolated)
- Interface Name: [Isolated]Query Take-profit and Stop-loss History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_tpsl_hisorders
11. Added Query Take-profit and Stop-loss History Orders(Cross)
- Interface Name: [Cross]Query Take-profit and Stop-loss History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_tpsl_hisorders
12. Added Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order(Isolated)
- Interface Name: [Isolated]Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_relation_tpsl_order
13. Added Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order(Cross)
- Interface Name: [Cross]Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_relation_tpsl_order
14. Modifed "Place an order" Interface(Isolated)(added optional parameters: tp_trigger_price (Trigger price of take-profit order), tp_order_price (Order price of take-profit order), tp_order_price_type (Order type of take-profit order), sl_trigger_price (Trigger price of stop-loss order), sl_order_price (Order price of stop-loss order), sl_order_price_type (Order type of stop-loss order))
- Interface Name: [Isolated]Place an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order
15. Modifed "Place an order" Interface(Cross)(added optional parameters: tp_trigger_price (Trigger price of take-profit order), tp_order_price (Order price of take-profit order), tp_order_price_type (Order type of take-profit order), sl_trigger_price (Trigger price of stop-loss order), sl_order_price (Order price of stop-loss order), sl_order_price_type (Order type of stop-loss order))
- Interface Name: [Cross]Place an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order
16. Modified "Place a batch of orders"Interface(Isolated) (added optional parameters in parameters "orders_data": tp_trigger_price (Trigger price of take-profit order),tp_order_price (Order price of take-profit order), tp_order_price_typeOrder type of take-profit order), sl_trigger_price (Trigger price of stop-loss order), sl_order_price (Order price of stop-loss order), sl_order_price_type (Order type of stop-loss order))
- Interface Name: [Isolated]Place a Batch of Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_batchorder
17. Modified "Place a batch of orders"Interface(Cross) (added optional parameters in parameters "orders_data": tp_trigger_price (Trigger price of take-profit order),tp_order_price (Order price of take-profit order), tp_order_price_typeOrder type of take-profit order), sl_trigger_price (Trigger price of stop-loss order), sl_order_price (Order price of stop-loss order), sl_order_price_type (Order type of stop-loss order))
- Interface Name: [Cross]Place a Batch of Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_batchorder
18. Modified "Get Information of an Order" Interface(Isolated)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Isolated]Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_info
19. Modified "Get Information of an Order" Interface(Cross)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Cross]Get Information of an Order
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_info
20. Modified "Order details acquisition" Interface(Isolated)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Isolated]Order details acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_order_detail
21. Modified "Order details acquisition" Interface(Cross)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Cross]Order details acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_order_detail
22. Modified "Query Open Orders" Interface(Isolated)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values"in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Isolated]Current unfilled order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_openorders
23. Modified "Query Open Orders" Interface(Cross)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values"in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Cross]Current unfilled order acquisition
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_openorders
24. Modified "Get History Orders" Interface(Isolated)(Added paprameter "sort_by" to represent "sort fields" with optional value“create_date” and “update_time"; added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no), and "update_time" to indicate order's update time); and "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit or stop-loss))
- Interface Name: [Isolated]Get History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_hisorders
25. Modified "Get History Orders" Interface(Cross)(Added paprameter "sort_by" to represent "sort fields" with optional value“create_date” and “update_time"; added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no), and "update_time" to indicate order's update time); and "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit or stop-loss))
- Interface Name: [Cross]Get History Orders
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_hisorders
26. Modified "Subscribe Order Data(sub)" Interface(Isolated)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Isolated]Subscribe Order Data(sub)
- Interface Type: private
- Subscription Topic: orders.$contract_code
27. Modified "Subscribe Order Data(sub)" Interface(Cross)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Cross]Subscribe Order Data(sub)
- Interface Type: private
- Subscription Topic: orders_cross.$contract_code
28. Modified "Subscribe Match Order Data(sub)" Interface(Isolated)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Isolated]Subscribe Match Order Data(sub)
- Interface Type: private
- Subscription Topic: matchOrders.$contract_code
29. Modified "Subscribe Match Order Data(sub)" Interface(Cross)(Added return parameter "is_tpsl" to indicate whether to set take-profit and stop-loss order, 1: yes, 0: no); added "enumerated values" in return parameter "order_source"(“tpsl” indicates triggered by take-profit and stop-loss))
- Interface Name: [Cross]Subscribe Match Order Data(sub)
- Interface Type: private
- Subscription Topic: matchOrders_cross.$contract_code
30. Modified "Query Trigger Order History" Interface(Isolated)(Added paprameter "sort_by" to represent "sort fields" with optional values “created_at” and “update_time”). added "update_time" to indicate order's update time))
- Interface Name: [Isolated]Query Trigger Order History
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_trigger_hisorders
31. Modified "Query Trigger Order History" Interface(Cross)(Added paprameter "sort_by" to represent "sort fields" with optional values “created_at” and “update_time”). added "update_time" to indicate order's update time))
- Interface Name: [Cross]Query Trigger Order History
- Interface Type: private
- Interface URL: /linear-swap-api/v1/swap_cross_trigger_hisorders
32. Modified "Get Swap Open Interest Information" Interface (Added "trade_volume" in return parameter "data" to indicate trading volume within the last 24 hours (cont), and "trade_amount" to indicate trading volume within the last 24 hours (coin), and "trade_turnover" to represent trading amount within the last 24 hours.)
- Interface Name: [General]Get Swap Open Interest Information
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_open_interest
33. Modified "Subscribe Market Detail Data" Interface (Added "ask" in return parameter “tick” to represent “sell one” and “bid” to represent "buy one".)
- Interface Name: [General]Subscribe Market Detail Data
- Interface Type: public
- Subscription Topic: market.$contract_code.detail
34. Modified "Query Swap Info" Interface(Added "delivery_time" in return parameter "data" to represent delivery time(millesecond timestamp))
- Interface Name: [General]Query Swap Info
- Interface Type: public
- Interface URL: /linear-swap-api/v1/swap_contract_info
35. Modified "Subscribe Contract Info" Interface(Added "delivery_time" in return parameter "data" to represent delivery time(millesecond timestamp))
- Interface Name: [General] Subscribe Contract Info (no authentication)(sub)
- Interface Type: public
- Subscription Topic: public.$contract_code.contract_info
1.0.5 2020-12-18 【Newly added:Added WS interface for subscribing system status updates push】
1.Added WS interface for subscribing system status updates push
- Interface name: [General]subscribe system status updates
- Interface type: public
- Subscription topic:public.$service.heartbeat
1.0.4 2020-12-11 【1-33 Added interfaces for cross margin mode. 34-60 Added fields to modify interface】
1、Added Cross Margin Mode Query Information On Tiered Adjustment Factor
Interface Name:[Cross]Query Information On Tiered Adjustment Factor
Interface Type:public
Interface URL:/linear-swap-api/v1/swap_cross_adjustfactor
2、Added Cross Margin Mode Query Information On Transfer State
Interface Name:[Cross]Query Information On Transfer State
Interface Type:public
Interface URL:/linear-swap-api/v1/swap_cross_transfer_state
3、Added Cross Margin Mode Query Information On Trade State
Interface Name:[Cross]Query Information On Trade State
Interface Type:public
Interface URL:/linear-swap-api/v1/swap_cross_trade_state
4、Added Cross Margin Mode Query User's Account Information
Interface Name:[Cross]Query User's Account Information
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_account_info
5、Added Cross Margin Mode Query User's Position Information
Interface Name:[Cross]Query User's Position Information
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_position_info
6、Added Cross Margin Mode Query Assets Information Of All Sub-Accounts Under The Master Account
Interface Name:[Cross]Query Assets Information Of All Sub-Accounts Under The Master Account
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_sub_account_list
7、Added Cross Margin Mode Query A Sub-Account's Assets Information
Interface Name:[Cross]Query A Sub-Account's Assets Information
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_sub_account_info
8、Added Cross Margin Mode Query A Sub-Account's Position Information
Interface Name:[Cross]Query A Sub-Account's Position Information
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_sub_position_info
9、Added Cross Margin Mode Query Information On Transfer Limit
Interface Name:[Cross]Query Information On Transfer Limit
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_transfer_limit
10、Added Cross Margin Mode Query Information On Position Limit
Interface Name:[Cross]Query Information On Position Limit
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_position_limit
11、Added Cross Margin Mode Query Assets And Positions
Interface Name:[Cross]Query Assets And Positions
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_account_position_info
12、Added Cross Margin Mode Query User’s Available Leverage
Interface Name:[Cross]Query User’s Available Leverage
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_available_level_rate
13、Added Cross Margin Mode Switch Leverage
Interface Name:[Cross]Switch Leverage
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_switch_lever_rate
14、Added Cross Margin Mode Place An Order
Interface Name:[Cross]Place An Order
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_order
15、Added Cross Margin Mode Place A Batch Of Orders
Interface Name:[Cross]Place A Batch Of Orders
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_batchorder
16、Added Cross Margin Mode Cancel An Order
Interface Name:[Cross]Cancel An Order
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_cancel
17、Added Cross Margin Mode Cancel All Orders
Interface Name:[Cross]Cancel All Orders
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_cancelall
18、Added Cross Margin Mode Get Information of order
Interface Name:[Cross]Get Information of order
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_order_info
19、Added Cross Margin ModeGet Detail Information of order
Interface Name:[Cross]Get Detail Information of order
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_order_detail
20、Added Cross Margin Mode Current unfilled order acquisition
Interface Name:[Cross]Current unfilled order acquisition
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_openorders
21、Added Cross Margin Mode Get History Orders
Interface Name:[Cross]Get History Orders
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_hisorders
22、Added Cross Margin Mode Get History Match Results
Interface Name:[Cross]Get History Match Results
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_matchresults
23、Added Cross Margin Mode Place Lightning Close Position
Interface Name:[Cross]Place Lightning Close Position
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_lightning_close_position
24、Added Cross Margin Mode Place Trigger Order
Interface Name:[Cross]Place Trigger Order
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_trigger_order
25、Added Cross Margin Mode Cancel Trigger Order
Interface Name:[Cross]Cancel Trigger Order
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_trigger_cancel
26、Added Cross Margin Mode Cancel All Trigger Orders
Interface Name:[Cross]Cancel All Trigger Orders
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_trigger_cancelall
27、Added Cross Margin Mode Query Open Trigger Order
Interface Name:[Cross]Query Open Trigger Order
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_trigger_openorders
28、Added Cross Margin Mode Query Trigger Order History
Interface Name:[Cross]Query Trigger Order History
Interface Type:private
Interface URL:/linear-swap-api/v1/swap_cross_trigger_hisorders
29、Added Cross Margin Mode Subscribe Order Data
Interface Name:[Cross]Subscribe Order Data
Interface Type:private
Subscription topic:orders_cross.$contract_code
30、Added Cross Margin Mode Subscribe Account Equity Updates Data
Interface Name:[Cross]Subscribe Account Equity Updates Data
Interface Type:private
Subscription topic:accounts_cross.$margin_account
31、Added Cross Margin Mode Subscribe Position Updates
Interface Name:[Cross]Subscribe Position Updates
Interface Type:private
Subscription topic:positions_cross.$contract_code
32、Added Cross Margin Mode Subscribe Match Order Data
Interface Name:[Cross]Subscribe Match Order Data
Interface Type:private
Subscription topic:matchOrders_cross.$contract_code
33、Added Cross Margin Mode Subscribe trigger orders updates
Interface Name:[Cross]Subscribe trigger orders updates
Interface Type:private
Subscription topic:trigger_order_cross.$contract_code
34、Query Swap Info Added fields (added “support_margin_mode” parameter; added “support_margin_mode” in return parameter “data” to represent the margin mode that a contract supports.)
Interface Name:Query Swap Info
Interface Type:public
Interface URL:linear-swap-api/v1/swap_contract_info
35、Query information on Tiered Adjustment Factor Added fields for return parameters ( added “margin_mode” to represent margin mode)
Interface Name:Query information on Tiered Adjustment Factor
Interface Type:public
Interface URL:/linear-swap-api/v1/swap_adjustfactor
36、Query information on system status Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query information on system status
Interface Type:public
Interface URL:/linear-swap-api/v1/swap_api_state
37、Query User’s Account Information Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query User’s Account Information
Interface Type:private
Interface URL:linear-swap-api/v1/swap_account_info
38、Query a single sub-account's assets information Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query a single sub-account's assets information
Interface Type:private
Interface URL:linear-swap-api/v1/swap_sub_account_info
39、Query Assets And Positions Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query Assets And Positions
Interface Type:private
Interface URL:linear-swap-api/v1/swap_account_position_info
40、Query assets information of all sub-accounts under the master account Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query assets information of all sub-accounts under the master account
Interface Type:private
Interface URL:linear-swap-api/v1/swap_sub_account_list
41、Query User’s Position Information Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query User’s Position Information
Interface Type:private
Interface URL:linear-swap-api/v1/swap_position_info
42、Query a single sub-account's position information Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query a single sub-account's position information
Interface Type:private
Interface URL:linear-swap-api/v1/swap_sub_position_info
43、Query account financial records Added fields (added “contract_code” to represent contract code)
Interface Name:Query account financial records
Interface Type:private
Interface URL:linear-swap-api/v1/swap_financial_record
44、Order details acquisition Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Order details acquisition
Interface Type:private
Interface URL:linear-swap-api/v1/swap_order_detail
45、Current unfilled order acquisition Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Current unfilled order acquisition
Interface Type:private
Interface URL:linear-swap-api/v1/swap_openorders
46、Get History Orders Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Get History Orders
Interface Type:private
Interface URL:linear-swap-api/v1/swap_hisorders
47、Acquire History Match Results Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Acquire History Match Results
Interface Type:private
Interface URL:linear-swap-api/v1/swap_matchresults
48、Query Trigger Order Open Orders Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query Trigger Order Open Orders
Interface Type:private
Interface URL:linear-swap-api/v1/swap_trigger_openorders
49、Query Trigger Order History Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query Trigger Order History
Interface Type:private
Interface URL:linear-swap-api/v1/swap_trigger_hisorders
50、Query information on Transfer Limit Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Query information on Transfer Limit
Interface Type:private
Interface URL:linear-swap-api/v1/swap_transfer_limit
51、Query information on position limit Added fields for return parameters ( added “margin_mode” to represent margin mode)
Interface Name:Query information on position limit
Interface Type:private
Interface URL:linear-swap-api/v1/swap_position_limit
52、Query user’s available leverage Added fields for return parameters ( added “margin_mode” to represent margin mode)
Interface Name:Query user’s available leverage
Interface Type:private
Interface URL:linear-swap-api/v1/swap_available_level_rate
53、Switch Leverage Added fields for return parameters ( added “margin_mode” to represent margin mode)
Interface Name:Switch Leverage
Interface Type:private
Interface URL:linear-swap-api/v1/swap_switch_lever_rate
54、Subscribe Order Data Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Subscribe Order Data
Interface Type:private
Subscription topic:orders.$contract_code
55、Subscribe Match Order Data Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Subscribe Match Order Data
Interface Type:private
Subscription topic:matchOrders.$contract_code
56、Subscribe trigger orders updates Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Subscribe trigger orders updates
Interface Type:private
Subscription topic:trigger_order.$contract_code
57、Subscribe Position Updates Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Subscribe Position Updates
Interface Type:private
Subscription topic:positions.$contract_code
58、Subscribe Account Equity Updates Data Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Subscribe Account Equity Updates Data
Interface Type:private
Subscription topic:accounts.$contract_code
59、Subscribe Contract Info (no authentication) Added fields for return parameters ( added “support_margin_mode” to represent support margin mode)
Interface Name:Subscribe Contract Info (no authentication)
Interface Type:public
Subscription topic:public.$contract_code.contract_info
60、Get Information of an Order Added fields for return parameters (added “margin_account” for return parameters to represent margin account; added “margin_mode” to represent margin mode)
Interface Name:Get Information of an Order
Interface Type:private
Interface URL:linear-swap-api/v1/swap_order_info
1.0.3 2020-12-02 【Modified “Order details acquisition” interface (When querying cancelation data of orders that have not been partially filled, if “created_at” and “order_type” parameters are not uploaded, the data that can be queried reduced from last 12 hours to last 2 hours.); modified “Query history orders” interface (When querying cancelation data of orders that have not been partially filled, the data that can be retained reduced from last 24 hours to last 2 hours.)】
1、Modified “Order details acquisition” interface (When querying cancelation data of orders that have not been partially filled, if “created_at” and “order_type” parameters are not uploaded, the data that can be queried reduced from last 12 hours to last 2 hours.)
Interface Name:Order details acquisition
Interface Type:private
Interface URL:linear-swap-api/v1/swap_order_detail
2、modified “Query history orders” interface (When querying cancelation data of orders that have not been partially filled, the data that can be retained reduced from last 24 hours to last 2 hours.)
Interface Name:Get History Orders
Interface Type:private
Interface URL:linear-swap-api/v1/swap_hisorders
1.0.2 2020-11-24 【 Added: Query historical settlement records of the platform interface. Modified: Added fields of return parameter for "Query Liquidation Orders" interface and "Subscribe Liquidation Order Data" interface】
1、Added “Query historical settlement records of the platform” interface
Interface Name: Query historical settlement records of the platform
Interface Type: public
Interface URL: linear-swap-api/v1/swap_settlement_records
2、Added fields of return parameter for "Query Liquidation Orders" interface(“amount” and “trade_turnover” are added for return parameter orders". )
Interface Name: Query Liquidation Orders
Interface Type: public
Interface URL: linear-swap-api/v1/swap_liquidation_orders
3、Added fields of return parameter for "Subscribe Liquidation Order Data" interface(“amount” and “trade_turnover” are added for return parameter “data".)
Interface Name: Subscribe Liquidation Order Data
Interface Type: public
Subscription topic: public.$contract_code.liquidation_orders
1.0.1 2020-10-29 【Updated: websocket messages of account topic will be pushed when leverage switch succeeds; websocket messages of position topic will be pushed when leverage switch succeeds;】
1、Subscribe Account Equity Updates Data(Return parameters added “switch_lever_rate” event type to represent switching leverages. When the leverage is successfully switched, a latest information on assets will be pushed with event “switch_lever_rate".)
Interface Name:Subscribe Account Equity Updates Data
Interface Type:private
Subscribe topic:accounts.$contract_code
2、Subscribe Position Updates(Return parameters added “switch_lever_rate” event type to represent switching leverages. When the leverage is successfully switched, a latest information on positions will be pushed with event “switch_lever_rate" (the information will not be pushed when the user's position is 0).)
Interface Name:Subscribe Position Updates
Interface Type:private
Subscribe topic:positions.$contract_code
1.0.0 2020-10-26 14:00(GMT+8)
Swap API Access Guide
API List
permission type | Content Type | Interface Mode | Context | Request Type | Desc | Signature Required |
---|---|---|---|---|---|---|
Read | Market Data | general | /linear-swap-api/v1/swap_contract_info | GET | Get Contracts Information | No |
Read | Market Data | general | /linear-swap-api/v1/swap_index | GET | Get contract Index Price Information | No |
Read | Market Data | general | /linear-swap-api/v1/swap_price_limit | GET | Query Swap Price Limitation | No |
Read | Market Data | general | /linear-swap-api/v1/swap_open_interest | GET | Get Contract Open Interest Information | No |
Read | Market Data | general | /linear-swap-api/v1/swap_risk_info | GET | Query information on contract insurance fund balance and estimated clawback rate | No |
Read | Market Data | general | /inear-swap-api/v1/swap_insurance_fund | GET | Query history records of insurance fund balance | No |
Read | Market Data | isolated margin | /linear-swap-api/v1/swap_adjustfactor | GET | Query information on Tiered Adjustment Factor | No |
Read | Market Data | general | /linear-swap-api/v1/swap_his_open_interest | GET | Query information on open interest | No |
Read | Market Data | general | /linear-swap-api/v1/swap_elite_account_ratio | GET | Query Top Trader Sentiment Index Function-Account | No |
Read | Market Data | general | /linear-swap-api/v1/swap_elite_position_ratio | GET | Query Top Trader Sentiment Index Function-Position | No |
Read | Market Data | general | /linear-swap-api/v1/swap_liquidation_orders | GET | Query Liquidation Order Information | No |
Read | Market Data | general | /linear-swap-api/v1/swap_settlement_records | GET | Query historical settlement records of the platform interface | No |
Read | Market Data | isolated margin | /linear-swap-api/v1/swap_api_state | GET | Query information on system status | No |
Read | Market Data | general | /linear-swap-api/v1/swap_funding_rate | GET | Query funding rate | No |
Read | Market Data | general | /linear-swap-api/v1/swap_batch_funding_rate | GET | [General]Query a Batch of Funding Rate | No |
Read | Market Data | general | /linear-swap-api/v1/swap_historical_funding_rate | GET | Query Historical Funding Rate | No |
Read | Market Data | general | /linear-swap-ex/market/depth | GET | Get Market Depth | No |
Read | Market Data | General | /linear-swap-ex/market/bbo | GET | Get Market BBO Data | No |
Read | Market Data | general | /linear-swap-ex/market/history/kline | GET | Get KLine Data | No |
Read | Market Data | general | /index/market/history/linear_swap_mark_price_kline | GET | Get Kline Data of Mark Price | No |
Read | Market Data | general | /linear-swap-ex/market/detail/merged | GET | Get Market Data Overview | No |
Read | Market Data | general | /linear-swap-ex/market/detail/batch_merged | GET | Get a Batch of Market Data Overview | No |
Read | Market Data | general | /v2/linear-swap-ex/market/detail/batch_merged | GET | Get a Batch of Market Data Overview(V2) | No |
Read | Market Data | general | /index/market/history/linear_swap_basis | GET | Query Basis Data | No |
Read | Market Data | general | /index/market/history/linear_swap_premium_index_kline | GET | Query Liquidation Order Information | No |
Read | Market Data | general | /index/market/history/linear_swap_estimated_rate_kline | GET | Query Swap Market Data interface | No |
Read | Market Data | general | /linear-swap-ex/market/trade | GET | Query The Last Trade of a Contract | No |
Read | Market Data | general | /linear-swap-ex/market/history/trade | GET | Query a Batch of Trade Records of a Contract | No |
Read | Market Data | cross margin | /linear-swap-api/v1/swap_cross_adjustfactor | GET | Query Information On Tiered Adjustment Factor | No |
Read | Market Data | cross margin | /linear-swap-api/v1/swap_cross_transfer_state | GET | Query Information On Transfer State | No |
Read | Market Data | cross margin | /linear-swap-api/v1/swap_cross_trade_state | GET | Query Information On Trade State | No |
Read | Market Data | general | /linear-swap-api/v1/swap_estimated_settlement_price | GET | Get the estimated settlement price | No |
Read | Market Data | general | /linear-swap-api/v1/swap_ladder_margin | GET | [Isolated]Query information on Tiered Margin | No |
Read | Market Data | general | /linear-swap-api/v1/swap_cross_ladder_margin | GET | [Cross]Query information on Tiered Margin | No |
Read | Account | isolated margin | /linear-swap-api/v1/swap_balance_valuation | POST | [General]Query Asset Valuation | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_account_info | POST | Query User’s Account Information | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_position_info | POST | Query User’s position Information | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_available_level_rate | POST | Query user’s available leverage | Yes |
Trade | Account | general | /linear-swap-api/v1/swap_sub_auth | POST | [General]Set a Batch of Sub-Account Trading Permissions | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_sub_account_list | POST | Query assets information of all sub-accounts under the master account (Query by coins) | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_sub_account_info_list | POST | [Isolated]Query a Batch of Sub-Account's Assets Information | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_cross_sub_account_info_list | POST | [Cross]Query a Batch of Sub-Account's Assets Information | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_sub_account_info | POST | Query a single sub-account's assets information | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_sub_position_info | POST | Query a single sub-account's position information | Yes |
Read | Account | general | /linear-swap-api/v1/swap_financial_record | POST | Query account financial records | Yes |
Read | Account | general | /linear-swap-api/v1/swap_financial_record_exact | POST | [General]Query account financial records via Multiple Fields | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_user_settlement_records | POST | Query Settlement Records of Users | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_user_settlement_records | POST | Query Settlement Records of Users | Yes |
Read | Account | general | /linear-swap-api/v1/swap_order_limit | POST | Query contract information on order limit | Yes |
Read | Account | general | /linear-swap-api/v1/swap_fee | POST | Query information on contract trading fee | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_transfer_limit | POST | Query information on Transfer Limit | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_position_limit | POST | Query information on position limit | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_lever_position_limit | POST | [Isolated]Query Users' Position Limit for All Leverages | Yes |
Read | Account | isolated margin | /linear-swap-api/v1/swap_account_position_info | POST | Query Assets And Positions | Yes |
Trade | Account | general | /linear-swap-api/v1/swap_master_sub_transfer | POST | Transfer between master account and sub-accounts | Yes |
Read | Account | general | /linear-swap-api/v1/swap_master_sub_transfer_record | POST | Query transfer records of master account | Yes |
Trade | Account | general | /linear-swap-api/v1/swap_transfer_inner | POST | Transfer between different margin accounts under the same account | Yes |
Read | Account | general | /linear-swap-api/v1/swap_api_trading_status | GET | Query user's API indicator disable information | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_account_info | POST | Query User's Account Information | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_position_info | POST | Query User's Position Information | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_sub_account_list | POST | Query Assets Information Of All Sub-Accounts Under The Master Account | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_sub_account_info | POST | Query A Sub-Account's Assets Information | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_sub_position_info | POST | Query A Sub-Account's Position Information | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_transfer_limit | POST | Query Information On Transfer Limit | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_position_limit | POST | Query Information On Position Limit | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_lever_position_limit | POST | [Cross]Query Users' Position Limit for All Leverages | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_account_position_info | POST | Query Assets And Positions | Yes |
Read | Account | cross margin | /linear-swap-api/v1/swap_cross_available_level_rate | POST | Query User’s Available Leverage | Yes |
Trade | Trade | isolated margin | /linear-swap-api/v1/swap_switch_position_mode | POST | [Isolated]Switch Position Mode | Yes |
Trade | Trade | cross margin | /linear-swap-api/v1/swap_cross_switch_position_mode | POST | [Cross]Switch Position Mode | Yes |
Trade | Trade | isolated margin | /linear-swap-api/v1/swap_order | POST | Place an Order | Yes |
Trade | Trade | isolated margin | /linear-swap-api/v1/swap_batchorder | POST | Place a Batch of Orders | Yes |
Trade | Trade | isolated margin | /linear-swap-api/v1/swap_switch_lever_rate | POST | Switch Leverage | Yes |
Trade | Trade | isolated margin | /linear-swap-api/v1/swap_cancel | POST | Cancel an Order | Yes |
Trade | Trade | isolated margin | /linear-swap-api/v1/swap_cancelall | POST | Cancel All Orders | Yes |
Read | Trade | isolated margin | /linear-swap-api/v1/swap_order_info | POST | Get Information of an Order | Yes |
Read | Trade | isolated margin | /linear-swap-api/v1/swap_order_detail | POST | Get Trade Details of an Order | Yes |
Read | Trade | isolated margin | /linear-swap-api/v1/swap_openorders | POST | Get Current Orders | Yes |
Read | Trade | isolated margin | /linear-swap-api/v1/swap_hisorders | POST | Get History Orders | Yes |
Read | Trade | isolated margin | /linear-swap-api/v1/swap_matchresults | POST | Acquire History Match Results | Yes |
Read | Trade | isolated margin | /linear-swap-api/v1/swap_hisorders_exact | POST | [Isolated]Get History Orders via Multiple Fields | Yes |
Read | Trade | Cross margin | /linear-swap-api/v1/swap_cross_hisorders_exact | POST | [Cross]Get History Orders via Multiple Fields | Yes |
Read | Trade | Isolated margin | /linear-swap-api/v1/swap_matchresults_exact | POST | [Isolated]Get History Match Results via Multiple Fields | Yes |
Read | Trade | Cross margin | /linear-swap-api/v1/swap_cross_matchresults_exact | POST | [Cross]Get History Match Results via Multiple Fields | Yes |
Trade | Trade | isolated margin | /linear-swap-api/v1/swap_lightning_close_position | POST | Place Lightning Close Order | Yes |
Trade | Strategy | isolated margin | /linear-swap-api/v1/swap_trigger_order | POST | Place an Trigger Order | Yes |
Trade | Strategy | isolated margin | /linear-swap-api/v1/swap_trigger_cancel | POST | Cancel a Trigger Order | Yes |
Trade | Strategy | isolated margin | /linear-swap-api/v1/swap_trigger_cancelall | POST | Cancel all trigger Orders | Yes |
Read | Strategy | isolated margin | /linear-swap-api/v1/swap_trigger_openorders | POST | Get all open trigger Orders | Yes |
Read | Strategy | isolated margin | /linear-swap-api/v1/swap_trigger_hisorders | POST | Get all history trigger Orders | Yes |
Trade | Trade | cross margin | /linear-swap-api/v1/swap_cross_switch_lever_rate | POST | Switch Leverage | Yes |
Trade | Trade | cross margin | /linear-swap-api/v1/swap_cross_order | POST | Place An Order | Yes |
Trade | Trade | cross margin | /linear-swap-api/v1/swap_cross_batchorder | POST | Place A Batch Of Orders | Yes |
Trade | Trade | cross margin | /linear-swap-api/v1/swap_cross_cancel | POST | Cancel An Order | Yes |
Trade | Trade | cross margin | /linear-swap-api/v1/swap_cross_cancelall | POST | Cancel All Orders | Yes |
Read | Trade | cross margin | /linear-swap-api/v1/swap_cross_order_info | POST | Get Information of order | Yes |
Read | Trade | cross margin | /linear-swap-api/v1/swap_cross_order_detail | POST | Get Detail Information of order | Yes |
Read | Trade | cross margin | /linear-swap-api/v1/swap_cross_openorders | POST | Current unfilled order acquisition | Yes |
Read | Trade | cross margin | /linear-swap-api/v1/swap_cross_hisorders | POST | Get History Orders | Yes |
Read | Trade | cross margin | /linear-swap-api/v1/swap_cross_matchresults | POST | Get History Match Results | Yes |
Trade | Trade | cross margin | /linear-swap-api/v1/swap_cross_lightning_close_position | POST | Place Lightning Close Position | Yes |
Trade | Strategy | cross margin | /linear-swap-api/v1/swap_cross_trigger_order | POST | Place Trigger Order | Yes |
Trade | Strategy | cross margin | /linear-swap-api/v1/swap_cross_trigger_cancel | POST | Cancel Trigger Order | Yes |
Trade | Strategy | cross margin | /linear-swap-api/v1/swap_cross_trigger_cancelall | POST | Cancel All Trigger Orders | Yes |
Read | Strategy | cross margin | /linear-swap-api/v1/swap_cross_trigger_openorders | POST | Query Open Trigger Order | Yes |
Read | Strategy | cross margin | /inear-swap-api/v1/swap_cross_trigger_hisorders | POST | Query Trigger Order History | Yes |
Trade | Strategy | isolated margin | /linear-swap-api/v1/swap_tpsl_order | POST | [Isolated]Set a Take-profit and Stop-loss Order for an Existing Position | Yes |
Trade | Strategy | isolated margin | /linear-swap-api/v1/swap_tpsl_cancel | POST | [Isolated]Cancel a Take-profit and Stop-loss Order | Yes |
Trade | Strategy | isolated margin | /linear-swap-api/v1/swap_tpsl_cancelall | POST | [Isolated]Cancel all Take-profit and Stop-loss Orders | Yes |
Read | Strategy | isolated margin | /linear-swap-api/v1/swap_tpsl_openorders | POST | [Isolated]Open take-profit and stop-loss orders | Yes |
Read | Strategy | isolated margin | /linear-swap-api/v1/swap_tpsl_hisorders | POST | [Isolated]Take-profit and stop-loss histoty orders | yes |
Read | Strategy | isolated margin | /linear-swap-api/v1/swap_relation_tpsl_order | POST | [Isolated]Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order | Yes |
Trade | Strategy | cross margin | /linear-swap-api/v1/swap_cross_tpsl_order | POST | [Cross]Set a Take-profit and Stop-loss Order for an Existing Position | Yes |
Trade | Strategy | cross margin | /linear-swap-api/v1/swap_cross_tpsl_cancel | POST | [Cross]Cancel a Take-profit and Stop-loss Order | Yes |
Trade | Strategy | cross margin | /linear-swap-api/v1/swap_cross_tpsl_cancelall | POST | [Cross]Cancel all Take-profit and Stop-loss Orders | Yes |
Read | Strategy | cross margin | /linear-swap-api/v1/swap_cross_tpsl_openorders | POST | [Cross]Open take-profit and stop-loss orders | Yes |
Read | Strategy | cross margin | /linear-swap-api/v1/swap_cross_tpsl_hisorders | POST | [Cross]Take-profit and stop-loss histoty orders | Yes |
Read | Strategy | cross margin | /linear-swap-api/v1/swap_cross_relation_tpsl_order | POST | [Cross]Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order | Yes |
Trade | Account | general | https://api.huobi.pro/v2/account/transfer | POST | Transfer margin between Spot account and USDT Margined Contracts account | Yes |
Trade | Strategy | Isolated | /linear-swap-api/v1/swap_track_order | POST | 【Isolated】Place a Trailing Order | Yes |
Trade | Strategy | Isolated | /linear-swap-api/v1/swap_track_cancel | POST | 【Isolated】Cancel a Trailing Order Order | Yes |
Trade | Strategy | Isolated | /linear-swap-api/v1/swap_track_cancelall | POST | 【Isolated】Cancel All Trailing Orders | Yes |
Read | Strategy | Isolated | /linear-swap-api/v1/swap_track_openorders | POST | 【Isolated】Current unfilled trailing order acquisition | Yes |
Read | Strategy | Isolated | /linear-swap-api/v1/swap_track_hisorders | POST | 【Isolated】Get History Trailing Orders | Yes |
Trade | Strategy | Cross | /linear-swap-api/v1/swap_cross_track_order | POST | 【Cross】Place a Trailing Order | Yes |
Trade | Strategy | Cross | /linear-swap-api/v1/swap_cross_track_cancel | POST | 【Cross】Cancel a Trailing Order Order | Yes |
Trade | Strategy | Cross | /linear-swap-api/v1/swap_cross_track_cancelall | POST | 【Cross】Cancel All Trailing Orders | Yes |
Read | Strategy | Cross | /linear-swap-api/v1/swap_cross_track_openorders | POST | 【Cross】Current unfilled trailing order acquisition | Yes |
Read | Strategy | Cross | /linear-swap-api/v1/swap_cross_track_hisorders | POST | 【Cross】Get History Trailing Orders | Yes |
Address
Address | Applicable sites | Applicable functions | Applicable trading pairs |
---|---|---|---|
https://api.hbdm.com | Huobi USDT Margined Contracts | API | Trading pairs provided by Huobi USDT Margined Contracts |
Notice
If you can't connect "https://api.hbdm.com", please use "https://api.btcgateway.pro" for debug purpose. If your server is deployed in AWS, we recommend using "https://api.hbdm.vn".
Signature Authentication & Verification
Signature Guide
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:
Request address of method, i.e. visit server address--api.hbdm.com, e.g.: api.hbdm.com/linear-swap-api/v1/swap_order
API Access Key ID (AccessKeyId): Access Key of the API Key that you apply.
Method of Signature (SignatureMethod): Based on the Hash Aggrement, users calculate the signature via HmacSHA256.
Signature Version (SignatureVersion): It adopts version 2 in terms of Signature Version.
Timestamp (Timestamp): The time when you send the request (UTC time zone) : (UTC time zone) : (UTC time zone), e.g.: 2017-05-11T16:22:06
Must-fill parameters & optional parameters: For each method, there are a group of must-fill parameters and optional parameters used to address the API request, which can be found in the illustration of each method as well as their meaning. Please note that, in terms of "Get" requests, it needs to do Signature calculation for all the original parameters in each method ; In terms of "Post" requests, no need to do Signature calculation for the original parameters in each method, which means only four parameters need to do Signature calculation in "Post" requests, i.e. AccessKeyId, SignatureMethod, SignatureVersion, Timestamp with other parameters placed in "body".
Signature: The result of Signature calculation which is used to verify if signature is valid and not tampered.
Create API Key
API Key consists of the following two parts.
"Access Key", the Key used to visit API.
"Secret Key", the Key used to do Signature authentication and verification (visible during application period).
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/linear-swap-api/v1/swap_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"
/linear-swap-api/v1/swap_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
6. Following the sequence above, link parameters with "&"
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
/linear-swap-api/v1/swap_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=
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.
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/linear-swap-api/v1/swap_order?AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&order-id=1234567890&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30&Signature=4F65x5A2bLyMWVQj3Aqp%2BB4w%2BivaA7n5Oi2SuYtCJ9o%3D
Add all the must authentication parameters into the parameters of request path;
Add the digital Signature encoded with URL code into the path parameters with the parameter name of "Signature".
API Rate Limit Illustration
Future, Coin Margined Swap,Option Swap and USDT Margined Contracts are using separate API rate limits.
Please note that, for both public interface and private interface, there are rate limits, more details are as below:
Generally, the private interface rate limit of API key is at most 144 times every 3 seconds for each UID (Trade Interface: at most 72 times every 3 seconds. Read Interface: at most 72 times every 3 seconds) (this rate limit is shared by all the altcoins contracts delivered by different date). API Interface List
For public interface used to get information of index, price limit, settlement, delivery, open positions and so on, the rate limit is 240 times every 3 second at most for each IP (this 240 times every 3 second public interface rate limit is shared by all the requests from that IP of non-marketing information, like above).
For public interface to get market data such as Get Kline data, Get Market Data Overview, Get Contract Information,Get market in-depth data, Get premium index Kline, Get real-time forecast capital rate kline, Get basis data, Get the last Trade of a Contract and so on:
(1)For restful interfaces, products, (future, coin margined swap, usdt margined Contracts)800 times/second for one IP at most
(2)For websocket: The rate limit for “req” request is 50 times at once. No limit for “sub” request as the data will be pushed by sever voluntarily.
WebSocket, the private order push interface, requires API KEY Verification:
Each UID can build at most create 30 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-USDT contracts. Please note that the rate limit of WS order push and RESTFUL private interface are separated from each other, with no relations.
Both read and trade interfaces will return the ratelimit info.You can refer to the following fields of "header" from api response. E.g.,you will get the total Read ratelimit("ratelimit-limit") and the remaining Read ratelimit("ratelimit-remaining") when you query the order info(/linear-swap-api/v1/swap_account_info) , and you will get the total Trade ratelimit("ratelimit-limit") and the remaining Trade ratelimit("ratelimit-remaining") when you place an order(/linear-swap-api/v1/swap_order)). API Interface List
Will response following string for "header" via api
ratelimit-limit: the upper limit of requests per time, unit: times
ratelimit-interval: reset interval (reset the number of request), unit: ms
ratelimit-remaining: the left available request number for this round, unit: times
ratelimit-reset: upper limit of reset time used to reset request number, unit: ms
When API Limitation on Order Cancellation Ratio is triggered,the following string for "header" via api will also be returned:
recovery-time: recovery timestamp, whose unit is millisecond, showing the end time of prohibition, or the access retrieval timestamp;
if you are not in the prohibition period, the field is not included in returned header;
API Limitation on Order Cancellation Ratio
- The system will calculate the order cancellation ratio automatically when the total number of orders placed via certain order price types by the API user goes equal to or larger than 3,000 within 10 minutes. If the order cancellation ratio is greater than 99%, the user will be prohibited for 5 minutes from placing orders via certain API order price types which will be listed below (The response of placing orders will return: 1084 Your contract API is disabled, please try again after {0} (GMT+8).).
- A 30-minute API order placement prohibition will be triggered if the user was prohibited for 3 times within an hour (The response of placing orders will return: 1084 Your contract API is disabled, please try again after {0} (GMT+8).). After resuming access, the total number of prohibited times will be cleared during the previous period and will not be counted into the total prohibited times in the new period.
- Please note that the prohibition from placing orders will cause no effect on order cancellation via API as well as order placement and cancellation via other terminals. We’ll keep you notified on each prohibition via SMS and email.
- Only four API order price types will be prohibited which are Limit order, Post_only, FOK and IOC. Please note that you can still use freely other order price types during the banned period, such as Lightning Close, BBO, Optimal 5, Optimal 10 and Optimal 20, opponent_ioc, lightning_ioc, optimal_5_ioc, optimal_10_ioc,optimal_20_ioc,opponent_fok,lightning_fok,optimal_5_fok,optimal_10_fok,optimal_20_fok,etc.
- The response header returned by HTTP request:
- When placing order by using the four prohibited order price types during the prohibition period, the message header returned by interface will include the field: "recovery-time: recovery timestamp" whose unit is millisecond, showing the end time of prohibition, or the access retrieval timestamp; if you are not in the prohibition period, the field is not included in returned header;
- Please note that our system calculates order cancellation ratio according to UID and therefore, the master account UID and sub-accounts UIDs will be counted separately. The calculation period is 10 min/time(The start time starts at 00:00 and the end time is 00:10. Every 10 minutes is a cycle.).
Definition of Indicators:
- Order Cancellation Ratio =Total number of invalid cancellation / Total number of placed orders (all types of orders placed via API)
- Total number of placed order: Total number of placed orders refers to all orders placed via API which meet these requirements:
- 1.the order type is placing orders (Order Type = 1),
- 2.order price types include Limit Order, Post_only, FOK and IOC.
- 3.order creating time should be within the interval between 3 seconds before the start time of the calculation period and the end time of the calculation period.
- Total number of invalid cancellation:Total number of invalid cancellation refers to all cancellation orders placed via API which meet the requirements.
- the order type is placing orders (order Type=1),
- the order price types are Limit Order, post_only, FOK and IOC.
- the order status is “Orders cancelled” (status=7).
- order with 0 fulfilled.
- the interval between order cancellation and placement should be less than or equal to 3 seconds.
- the order cancellation time should be within the calculation period.
In order to ensure stability and transaction performance of API, please try to reduce order cancellation rate and cancellation amount during peak periods to avoid frequent triggering of API restriction mechanism.Suggestions of reducing order cancellation rate are as below:
- 1. Set orders’ price to BBO prices as close as possible;
- 2. Prolong the interval properly between each order placement and cancellation;
- 3. Try to increase your amount for each order and reduce the frequency of order;
- 4. Try to improve your order fulfillment rate:
- (1)Please try to use order prices types that help more on order fulfillment in preference such as BBO, Optimal 5, Optimal 10, Optimal 20, lightning Close, opponent_ioc, lightning_ioc, optimal_5_ioc, optimal_10_ioc,optimal_20_ioc,opponent_fok,lightning_fok,optimal_5_fok,optimal_10_fok,optimal_20_fok, etc.
- (2)Try to use best bid/ask price when placing IOC orders, FOK orders and Post_only orders.
- 5. Please try to extend your request polling cycle when implementing your strategy.
API Best Practice
1. Query contract history orders interface: /linear-swap-api/v1/swap_hisorders
To ensure timelines and to reduce latency, users are highly recommended to get contract history orders information faster from server memory using interface “query contract order information” (URL: /linear-swap-api/v1/swap_order_info).
For users who use interface “query contract history orders” (URL: /linear-swap-api/v1/swap_hisorders), please enter as many query conditions as possible (including contract_code, trade_type(recommended to send “0” to query all), type, status, create_date). Besides, try not to enter a big integer in parameter “create_date”. You are kindly suggested to query one-day data at a time.
2. Query contract match results interface: /linear-swap-api/v1/swap_matchresults
- To improve query performance and response speed, please enter as many querying conditions as possible (including contract_code, trade_type(recommended to send “0” to query all), create_date). Besides, try not to enter a big integer in parameter “create_date”. You are kindly suggested to query one-day data at a time.
3. Query contract financial record interface: /linear-swap-api/v1/swap_financial_record
- To improve query performance and response speed, please enter as many querying conditions as possible (including symbol, type(recommended to leave it blank to query all), create_date). Besides, try not to enter a big integer in parameter “create_date”. You are kindly suggested to query one-day data at a time.
4. Query contract order detail interface: /linear-swap-api/v1/swap_order_detail
When querying orders without parameter(such as the parameter: created_at), the query result data may be delayed. It is recommended to pass the two parameters of the interface: created_at (order timestamp) and order_type (order type, default 1), the database will be directly queried, and the query results data will be more timely.
Querying condition “created_at” uses 13-bit long type time stamp (including milliseconds). Querying performance will be improved when accurate time stamps are entered.
For example: the converted time stamp of "2019/10/18 10:26:22" is 1571365582123. The returned ts from interface “contract_order” can be used as time stamp to query corresponding order. 0 is not allowed in parameter “created_at”.
5. WebSocket subscription to Market Depth data:
For acquiring market depth data within 150 steps, you are kindly suggested to use step0, step1, step2, step3, step4, step5, step14, step15, step16, step17;
For acquiring market depth data within 20 steps, you are kindly suggested to use step6, step7, step8, step9, step10, step11, step12, step13, step18, step19;
Since the large volume of pushing 150 steps data every 100ms, WebSocket disconnection may occur frequently if client’s network bandwidth is insufficient or the processing is not in time; therefore, we highly recommend users using step6, step7, step8, step9, step10, step11, step12, step13, step18, step19 to acquire 20 steps data. For instance, subscribing 20 steps data.
{
"sub": "market.BTC-USDT.depth.step6",
"id": "id5"
}
- We also suggest that you subscribe incremental market depth data.orderbook event will be checked every 30ms. If there is no orderbook event, you will not receive any orderbook data.you HAVE TO maintain local orderbook data,such as updating your local orderbook bids and asks data.You can subscribe 20 or 150 unmerged data.
{
"sub": "market.BTC-USDT.depth.size_20.high_freq",
"data_type":"incremental",
"id": "id1"
}
6. Place order interface (URL: /linear-swap-api/v1/swap_order) and place a batch of orders interface (URL:/linear-swap-api/v1/swap_batchorder):
We recommend to fill in the parameter “client_order_id”(should be unique from user-side),which can help users to acquire order status and other order information according to the parameter “client_order_id" from
query order information interface (URL: /linear-swap-api/v1/swap_order_info ) when there is no returned information due to network or other problems.
7. The best deployment of program server
- It is recommended that place the server in AWS Tokyo C zone and use the api.hbdm.vn domain, which can effectively reduce network disconnection and network timeout.
Code Demo
PS: USDT Margined Contracts api is similar to Coin margined swap api and future api.
Swap API FAQ
Access and Authentication
Q1: Is the API Key for swap and spot the same ?
Yes. The Swap API key and spot API key are same. You can create API using the following link. click here
Q2: Why are APIs disconnected or timeout?
The network connection is unstable if the server locates in China mainland,it is suggested to invoke APIS from a server located in 1c area of AWS Tokyo.
You can use api.btcgateway.pro or api.hbdm.vn to debug for China mainland network.
Q3: Why is the websocket often disconnected?
It seems that most of the abnormal websocket issues (such as disconnect, websocket close )(websocket: close 1006 (abnormal closure))are caused by different network environment. The following measures can effectively reduce websocket issues.
It would be better if the server is located in 1c area of AWS Tokyo with url api.hbdm.vn and implement websocket re-connection mechanism. Both market heartbeat and order heartbeat should response with Pong with different format, following Websocket market heartbeat and account heartbeat requirement.here
Q4: what is the difference between api.hbdm.com and api.hbdm.vn?
The api.hbdm.vn uses AWS's CDN service. it should be more stable and faster for AWS users. The api.hbdm.com uses Cloudflare's CDN service.
Q5: What is the colocation service ? which attention points should we know ?
Actually ,colo corresponds to a vpc node, which directly connects to private network of huobi's future, so it will reduce the latency between the client and the Huobi future server (bypassing the CDN)
huobi future and huobi swap have the same colo, so the domain name connecting the USDT Margined Contracts api and the future api are the same.
Note : Colo needs to use api.hbdm.com for signature(authentication) to avoid getting 403 error: Verification failure.
Q6: Why does signature verification return failure (403: Verification failure) ?
The signature process of USDT Margined Contracts is similar to huobi future and coin margined swap . In addition to the following precautions,please refer to the swap or future demo to verify whether the signature is successful. Please check your own signature code after demo verification is successful. The coin margined swap code demo is here. The future code demo is here. The USDT Margined Contracts code demo is here.
- Check if the API key is valid and copied correctly.
- Check if the IP is in whitelist
- Check if th timestamp is UTC time
- Check if parameters are sorted alphabetically
- Check if the encoding is UTF-8
- Check if the signature has base64 encoding
- Any method with parameters for GET requests should be signed
- Any method with parameters for POST requests don't need to be signed
- Check if whether the signature is URI encoded and Hexadecimal characters must be capitalized, such as ":" should be encoded as "%3A", and the space shoule be encoded as "%20"
- The authorization of websocket is similar to the authorization of restful interface.Pls note that the json body of the websocket authorization shouldn't be URL encoded
- The host in signature text should be the same as the host in your API request.The proxy may change the request host, you can try without proxy;Some http/websocket library may include port in the host, you can try to append port in signature host, like "api.hbdm.com:443"
- The hidden text in API Key and Secret Key may have impact on the signature.
If the reason for signature failure has not been found through the above methods. And you can confirm that by this demo which is specially explaining the signature.
Q7: Is the ratelimit of public market based on IP ? Is the ratelimit of interface with private key based on UID?
Yes. The ratelimit of interface with private key is based on the UID, not the API key. The master and sub accounts are separately ratelimited and don't affect each other.
Q8: Is there any recommendation for third-party framework which integrates Huobi swap?
There is an open source asynchronous quantization framework which integrates Huobi future and Huobi swap: here. If you have any quetsions, please open a ticket in github issues.
Settlement
Q1: What is the USDT Margined Swap funding rate settlement cycle? Which interface can be used to check the status when the fund rate is settled?
We warmly remind you that Huobi USDT Margined Swap is settled every 8 hours, and the settlement will be at the end of each period. For example, 00:00 - 08:00 is a period, and its settlement time would be at 08:00; 08:00 - 16:00 is a period, and its settlement time would be at 16:00; 16:00 - 00:00 (+1 day) is a period, and its settlement time would be at 00:00. All times mentioned above are Singapore Standard time (GMT+8).
(1)Orders can't be placed or cancelled during settlement period, error code "1056" will be returned if users place or cancel orders.
You are recommended to request contract information by this two ways:
- restful, every few seconds during settlement period to access: /linear-swap-api/v1/swap_contract_info
- websocket, Subscribe Contract Info (no authentication): public.$symbol.contract_info
It's in settlement time if there is any number of 5, 6, 7, 8 included in the returned status code of contract_status, while it indicates that settlement completed and users could place and cancel orders as usual if the returned status code is 1.
(2)When querying fund or position information during the settlement period, error codes will be returned. Error code and their meaning are as following:
- Error code "1077" indicates that "the fund query of current perpetual swap trading pair failed during the settlement";
- Error code "1078" indicates that "the fund query of part of perpetual swap trading pairs failed during the settlement";
- Error code "1079" indicates that "the position query of current perpetual swap trading pair failed during the settlement";
- Error code "1080" indicates that "the position query of part of perpetual swap trading pairs failed during the settlement";
You are recommended to read the status code from the returned message. If the above four types of status code appear, the returned data is not accurate and couldn't be used as reference.
Q2: How to query the system status of the exchange?
There are two common statuses of the exchange systems: settlement/delivery in progress; suspended for maintenance; when the system is in these two kinds of statuses, the system will return the response error code and error information when calling the related API interfaces.
a. How to judge whether the settlement/delivery has been done?
Users can judge from the value “contract_status” returned by the “Get Information of an Order” interface (/linear-swap-api/v1/swap_contract_info);
or Subscribe Contract Info (no authentication): public.$symbol.contract_info
If the return parameter contract_status is 1, it means that the settlement/delivery has been done and the trading has been resumed now.
b. How to judge whether the system is suspended for maintenance or not?
Users can judge from the value “heartbeat” pushed by the “Queried if system interface is available” interface (https://api.hbdm.com/heartbeat/)
or the “Subscribe system status updates” interface ("topic: public.$service.heartbeat");
If the return parameter heartbeat is 1, it means that the system is available now and can be connected normally.
Details of Each Error Code
Error Code | Error Details Description |
---|---|
403 | invalid ID |
1000 | System error. |
1001 | System is unprepared. |
1002 | Query error. |
1003 | Abnormal redis operation. |
1004 | System busy. Please try again later. |
1010 | Account doesn't exist. |
1011 | The user's session doesn't exist. |
1012 | The user's account doesn't exist. |
1013 | This contract symbol doesn't exist. |
1014 | This contract doesn't exist. |
1015 | The index price does not exist. |
1016 | The bid offer does not exist. Please input the price. |
1017 | Order doesn't exist. |
1018 | Main account doesn't exist. |
1019 | Main account doesn't exist in the sub-account white list. |
1020 | The number of your sub-account exceeds the maximum. Please contact customer service. |
1021 | Account open failed. Main account hasn’t opened contract trading account yet. |
1030 | Input error. |
1031 | Incorrect form source. |
1032 | The number of access exceeded the limit. |
1033 | Incorrect field of contract period. |
1034 | Incorrect field of order price type. |
1035 | Incorrect field of form direction. |
1036 | Incorrect field of open long form. |
1037 | The leverage is invalid. Please contact the customer service. |
1038 | The order price exceeds the precision limit, please modify and order again. |
1039 | Buy price must be lower than {0}{1}. Sell price must exceed {2}{3}. |
1040 | Invalid amount, please modify and order again. |
1041 | The order amount exceeds the limit ({0}Cont), please modify and order again. |
1042 | Current positions have triggered position limits ({0}Cont). Please order after changing the amount. |
1043 | Current positions have triggered position limits ({0}Cont). Please order after changing the amount. |
1044 | Current positions have triggered position limits of our platform. Please order after changing the amount. |
1045 | Unable to switch leverage due to open orders. |
1046 | Abnormal service. Please try again later. |
1047 | Insufficient margin available. |
1048 | Insufficient close amount available. |
1049 | Open a position with market price is not available.contracts |
1050 | Customer's order number is repeated. Please try again later. |
1051 | No orders to cancel. |
1052 | The number exceeds the batch limit. |
1053 | Unable to get the latest price range. |
1054 | Unable to get the latest price. |
1055 | The price is not reasonable, and the account equity will be less than 0 after placing this order. Please modify the price and place the order. |
1056 | In settlement. Your order can’t be placed/withdrew currently. |
1057 | Your order can’t be placed due to trading halt. |
1058 | Your order can’t be placed due to trade suspension. |
1059 | In delivery. Your order can’t be placed/withdrew currently. |
1060 | Your order can’t be placed currently due to abnormal contracts status. |
1061 | This order doesn't exist. |
1062 | Cancelling. Please be patient. |
1063 | The order has been executed. |
1064 | The main key of order conflicts. |
1065 | The form number of client isn't an integer. |
1066 | {0} cannot be empty. |
1067 | Illegal parameter {0}. |
1068 | Export error. |
1069 | The price is not reasonable. |
1070 | Empty data, cannot be exported. |
1071 | Repeated cancellation. Your order has been canceled. |
1072 | Sell price must be lower than {0}{1}. |
1073 | Position abnormal. Please contact the customer service. |
1074 | Unable to order currently. Please contact the customer service. |
1075 | The price is not reasonable, and the margin rate will be less than 0 after placing this order. Please modify the price and place the order. |
1076 | No orders, please try again later. |
1077 | In settlement or delivery. Unable to get assets of current contract. |
1078 | In settlement or delivery. Unable to get assets of some contracts. |
1079 | In settlement or delivery. Unable to get positions of current contract. |
1080 | In settlement or delivery. Unable to get positions of some contracts. |
1081 | The number of your {0} contract trigger orders exceeds the limit {1}. |
1082 | Trigger type parameter error. |
1083 | Your position is in the process of forced liquidation. Unable to place order temporarily. |
1084 | Your contract API is disabled, please try again after {0} (GMT+8). |
1085 | Trigger order failed, please modify the price and place the order again or contact the customer service. |
1086 | {0} contract is restricted of opening positions on {1}. Please contact customer service. |
1087 | {0} contract is restricted of closing positions on {1}. Please contact customer service. |
1088 | {0} contract is restricted of withdraw order on {1}. Please contact customer service. |
1089 | Transfer is temporarily restricted for {0} account, please contact customer service support. |
1090 | Margin rate is lower than 0. Order can’t be placed. |
1091 | Equity is less than 0. Order can’t be placed. |
1092 | The Flash Closing Order takes the {0}th price at the order book. After placing an order, the account equity will be less than 0. Please manually enter the price or place an order with the counterparty price. |
1093 | The Flash Closing Order takes the {0}th price at the order book. The margin rate will be less than 0 after placing an order. Please manually enter the price or place an order with the counterparty price. |
1094 | The leverage cannot be empty, please switch the leverage or contact customer service |
1095 | Non-trading state, unable to switch the leverage temporarily |
1100 | Unable to open a position currently. Please contact the customer service. |
1101 | Unable to close a position currently. Please contact the customer service. |
1102 | Unable to transfer in currently. Please contact customer service. |
1103 | Unable to transfer out currently. Please contact customer service. |
1104 | Trading is prohibited due to contracts trading constraints. |
1105 | Only Close is available due to contracts trading constraints. |
1106 | Delivery or settlement in progress, unable to transfer. |
1108 | Abnormal service. Please try again later. |
1109 | Sub-account doesn't own the permissions to open positions. Please contact customer service. |
1110 | Sub-account doesn't own the permissions to close positions. Please contact customer service. |
1111 | Sub-account doesn't own the permissions to transfer in. Please contact customer service. |
1112 | Sub-account doesn't own the permissions to transfer out. Please contact customer service. |
1113 | The sub-account does not have transaction permissions. Please login main account to authorize. |
1114 | The sub-account does not have transfer permissions. Please login main account to authorize. |
1115 | You have no access permissions of this sub-account. |
1200 | Login error. Please try again. |
1220 | You don’t have access permission as you have not opened contracts trading. |
1221 | The total balances of Exchange Account can't meet the requirements for opening contracts. |
1222 | The days of opening account can't meet the requirements for opening contracts. |
1223 | The VIP level can't meet the requirements for opening contracts. |
1224 | Your country/region can't meet the requirements for opening contracts. |
1225 | Failed to open contracts. |
1226 | Repeated account. |
1227 | Huobi Contract does not support sub-accounts. Please log out sub-account and log in again with primary account. |
1228 | You have not activated contract trading currently, please activate first. |
1229 | Cannot agree twice. |
1230 | You haven't finished the risk verification. |
1231 | You haven't finished the ID Verification. |
1232 | The format/size of the image you uploaded does not meet the requirements. Please re-upload. |
1233 | High leverage is not enabled (Please sign in the APP or web with your main account to agree to the High-Leverage Agreement) |
1234 | For {0} contracts, the number of the position-opening orders which are not fully filled cannot exceed {1}. |
1235 | For {0} contracts, the number of the position-closing orders which are not fully filled cannot exceed {1}. |
1250 | Unable to get the HT_token. |
1251 | Unable to get BTC assets. Please try again later. |
1252 | Unable to get currency account assets. Please try again later. |
1253 | Error in signature verification. |
1254 | The sub-account has no permission to open futures, please go to the web side to log in the main account and open. |
1300 | Transfer failed. |
1301 | Insufficient amount available. |
1302 | Transfer failed. |
1303 | The single transfer-out amount must be no less than {0}{1}. |
1304 | The single transfer-out amount must be no more than {0}{1}. |
1305 | The single transfer-in amount must be no less than {0}{1}. |
1306 | The single transfer-in amount must be no more than {0}{1}. |
1307 | Your accumulative transfer-out amount is over the daily maximum, {0}{1}. You can't transfer out for the time being. |
1308 | Your accumulative transfer-in amount is over the daily maximum, {0}{1}. You can't transfer in for the time being. |
1309 | Your accumulative net transfer-out amount is over the daily maximum, {0}{1}. You can't transfer out for the time being. |
1310 | Your accumulative net transfer-in amount is over the daily maximum, {0}{1}. You can't transfer in for the time being. |
1311 | The platform's accumulative transfer-out amount is over the daily maximum. You can't transfer out for the time being. |
1312 | The platform's accumulative transfer-in amount is over the daily maximum. You can't transfer in for the time being. |
1313 | The platform's accumulative net transfer-out amount is over the daily maximum. You can't transfer out for the time being. |
1314 | The platform's accumulative net transfer-in amount is over the daily maximum. You can't transfer in for the time being. |
1315 | Wrong transfer type. |
1316 | Failed to freeze the transfer. |
1317 | Failed to unfreeze the transfer. |
1318 | Failed to confirm the transfer. |
1319 | Failed to acquire the available transfer amount. |
1320 | The contract status is abnormal. Transfer is unavailable temporarily. |
1321 | Transfer failed. Please try again later or contact customer service. |
1322 | Invalid amount. Must be more than 0. |
1323 | Abnormal service, transfer failed. Please try again later. |
1325 | Failed to set trading unit |
1326 | Failed to obtain trading units |
1327 | No transfer permission, transfer failed, please contact customer service |
1328 | No transfer permission, transfer failed, please contact customer service |
1329 | No transfer permission, transfer failed, please contact customer service |
1330 | No transfer permission, transfer failed, please contact customer service |
1331 | Exceeds limit of transfer accuracy (8 digits). Please modify it |
1332 | The contract doesn't exist. |
1333 | Failed to open the Maker&Taker agreement |
1334 | Failed to check the Maker&Taker agreement |
1335 | Failed to check the second confirmation setting of Maker&Taker |
1336 | Failed to update the second confirmation setting of Maker&Taker |
1337 | Failed to check the settings of Maker&Taker |
1338 | Failed to update the settings of Maker&Taker |
1339 | Nickname contains illegal words, please modify it |
1340 | Nickname has been used, please modify it |
1341 | The enrollment has ended |
1342 | You cannot set nickname for sub-account |
1343 | Invalid indicator, please reset |
1344 | Sorry, {0} contracts can add market reminders currently at most |
1345 | Sorry, currently {0} can set up to {1} reminders |
1346 | The indicator already exists, please do not set it repeatedly |
1347 | {0} parameter is incorrect, please modify. |
1348 | This contract does not support cross margin mode. |
1349 | The leverage of the order does not match the leverage of the current position, please switch the leverage first. |
1401 | order price shall be lower than the strike price. |
1403 | The number of take-profit and stop-loss orders for {0} contract shall not exceed {1} |
1404 | Take-profit and stop-loss orders can only be bound with orders for opening a position |
1405 | The take-profit price shall not be {0}{1}{2} |
1406 | Your chances of lucky draw have been used up |
1407 | The stop-loss price shall not be {0}{1}{2} |
1408 | Unable to cancel because the take-profit and stop-loss order does not take effect. |
1409 | You have no access to set a take-profit and stop-loss order, please contact our customer service. |
1410 | The number of sub-accounts for batch operation cannot exceed {0} |
1411 | Settlement in progress, unable to query order information. |
1412 | {0} does not meet with the price precision limit {1}. |
1413 | You have no access to set a Trailing Stop order, please contact our customer service. |
1414 | You have not activated the grid trading. Please log in to the Web or APP with your main account, and agree with the protocol to activate the grid trading. |
1415 | Terminate price (Take-profit/Stop-loss price) cannot be within the range of grid price, please modify! |
1416 | Exceeds the maximum running time, which is{0} days and {1} hours, please modify! |
1417 | Exceeds the range of grid quantity, which is ({0} ~ {1}), please modify! |
1418 | At most {0} grids trading orders can be running at the same time, please cancel other grid trading orders first. |
1419 | Exceeds the range of initial margin ({0} ~ {1}} {2}). |
1420 | You have no access to grid trading on Huobi Futures, please contact our customer service. |
1421 | There are open orders or positions of the current contract, please cancel these orders or close these positions first. |
1422 | The PnL per grid is expected to be less than 0, please modify! |
1423 | The spread between the lowest and the highest grid price is unreasonable, please modify! |
1424 | This grid trading has been terminated for other reasons. Therefore, it cannot be modified or manually terminated now. |
1425 | The callback rate should be {0}{1}, please modify! |
1426 | The activation price should be {0} the latest price. |
1427 | The number of your {0} contract trailing stop order orders exceeds the limit {1}. |
1428 | The coupon for the same type of contract can only be collected once by each user. |
1429 | Already received; please do not collect again! |
1430 | Invalid coupon; please refresh! |
1431 | The system is in maintenance and is expected to resume at {0} (GMT+8). |
1432 | A grid trading is being initialized or terminated; unable to place an order currently. |
1433 | The grid trading is terminated caused by placing/canceling order manually; please check “Order History” for details. |
1434 | Less than the minimum initial margin ({0}{1}), which causes the quantity per grid less than the minimum order quantity, please modify! |
1435 | The grid has been terminated by you. |
1436 | The grid trading exceeds the effective duration; terminated automatically. |
1437 | The grid trading has been terminated for system reasons, please contact our customer service. |
1438 | The grid trading has been terminated due to the termination condition being triggered. |
1439 | The grid trading has been terminated due to a liquidation being triggered. |
1440 | {0} contracts fail to be cancelled. |
1441 | The trigger price must be lower than the highest termination price and higher than the lowest termination price, please modify! |
1442 | The effective duration must be a minute longer than the running time, please modify! |
1443 | Delivery of {0} contract causes grid trading termination. |
1450 | The risk level you ranked does not support the use of current leverage. |
1451 | The risk level you ranked does not support the use of current leverage, please log in the main account for checking. |
1452 | The number of grid orders exceeds the order quantity limits; Unable to place any order temporarily. |
1453 | The number of all your trigger orders exceeds the limit set by the platform; Unable to place any orders temporarily. |
1454 | The number of all your take profit and stop loss orders exceeds the limit set by the platform; Unable to place any orders temporarily. |
1455 | The number of all your trailing stop orders exceeds the limit set by the platform; Unable to place any orders temporarily. |
1484 | Reverse order involves Reduce Only order. |
1485 | One-way mode is unavailable for grid trading. |
1486 | One-way mode is unavailable temporarily. |
1487 | We are sorry you have no access to one-way mode. |
1488 | Opening positions is unavailable in one-way mode temporarily. |
1489 | Closing positions is unavailable in one-way mode temporarily. |
1490 | Opening after closing exceeds the limit (conts). |
1491 | Reduce Only order parameter error! |
1492 | Amount of Reduce Only order exceeds the amount available to close. |
1493 | Position mode cannot be adjusted for open orders. |
1494 | Position mode cannot be adjusted for existing positions. |
1495 | Position mode cannot be adjusted for open grid orders. |
1496 | Position mode cannot be adjusted due to the contract’s non-trading status. |
1497 | Position mode parameter passing error! |
1498 | Margin account incorrect! |
1499 | Hedge mode currently; Unavailable to place orders in one-way mode. |
1500 | One-way mode currently; Unavailable to place orders in hedge mode. |
12001 | Invalid submission time. |
12002 | Incorrect signature version. |
12003 | Incorrect signature method. |
12004 | Private key is expired. |
12005 | Incorrect IP address. |
12006 | The submission time can't be empty. |
12007 | Incorrect public key. |
12008 | Verification failed. |
12009 | The user is locked or doesn't exist. |
Market and Websocket
Q1: How often are the snapshot orderbook subscription and incremental orderbook subscription pushed?
The snapshot orderbook subscription(market.$contract_code.depth.$type) is checked once every 100MS.If there is an update,it will be pushed. It will be pushed at least 1 second.The incremental orderbook subscription is checked once every 30MS.If there is an update,it will be pushed.If there is no update, it will not be pushed.
Q2: How often is the market trade subscription pushed?
The market trade subscription will be pushed when there is a transaction.
Q3: Are there historical Kline data or historical market trade data?
The historical kline data can be obtained via API interface /market/history/kline with the request params from, to (the time period cannot exceed two years). And the qty of data records cannot be exceeding 2000 in each time.
The historical trade data can be obtained by subscribing the websocket topic: market.$symbol.trade.detail
or can be downloaded from download historical market data
But also, you can download that data using The demo of downloading historical market data
Q4: How to get MACD and other technical indicators on Kline?
The API does not have interfaces to get technical indicators such as MACD. You can refer to TradingView and other websites to calculate them.
Q5: What is the definition of timestamp in the document?
The timestamp in the document refers to the total number of seconds or total milliseconds from Greenwich Mean Time, January 1, 1970, 00:00:00 (Beijing Time, January 1, 1970, 08:00:00) to the present.
Q6: What is the definition of the 150 level and 20 level of MBP?
The Subscription of MBP data: market.$contract_code.depth.$type.150 price level means the current bids and asks splited into 150 level by price.20 price level means the current bids and asks splited into 20 level by price.
Q7: What is the meaning of merged depth when subscribing MBP data?
The subscrpition of MBP data:market.$contract_code.depth.$type:
step16 and step18 are merged by 7 decimal places.bids down,asks up. step17 and step19 are merged by 6 decimal places.bids down,asks up. step1 and step7 are merged by 5 decimal places.bids down,asks up. step2 and step8 are merged by 4 decimal places.bids down,asks up. step3 and step9 are merged by 3 decimal places.bids down,asks up. step4 and step10 are merged by 2 decimal places.bids down,asks up. step5 and step11 are merged by 1 decimal places.bids down,asks up. step12 and step14 are combined by single digit.bids down,asks up. step13 and step15 are combined by tens.bids down,asks up.
Example:
step4(0.01):
bids price: 100.123, 100.245. The merged bids price are 100.12, 100.24.
asks price: 100.123, 100.245 The merged asks price are 100.13, 100.25.
("Down" and "Up" are rounded up or down, if the price is down, the asks price is not rounded down, and the bids price is rounded up.)
150 price level: step0 to step5, step14 to step17;
20 price level: step6 to step13, step18, step19;
More examples:
step1(0.00001):
price: 1.123456 The merged bid price is 1.12345. The merged ask price is 1.12346.
step7(0.00001):
price: 1.123456 The merged bid price is 1.12345. The merged ask price is 1.12346.
step6(0.000001)
price: 1.123456 The merged bid price is 1.123456. The merged ask price is 1.123456.
step11(0.1):
price: 1.123456 The merged bid price is 1.1. The merged ask price is 1.1.
Q8:Does websocket's position channel push full data or incrementall data each time?
Subscription of position event: "positions.BTC-USDT".The latest position is pushed,including the volumes, available volumes, frozen volumes.If there is no update,it will not be pushed.
Q9: Does websocket's position channel push data when the unrealized profit is updated?
Subscription of position event: "positions.BTC-USDT".It will not be pushed if only unrealized profit is updated. It will be pushed only when position event is updated.
Q10: What is the difference between market detail and trade detail in WS?
Market Detail(market.$contract_code.detail) is the merged market data. It will be checked every 0.5s,pushed once trade event updates,including the OHLCV data,etc.Trade Detail(market.$contract_code.trade.detail) is pushed once trade event updates,including trade price, trade volume, trade direction,etc.
Q11: What is the meaning of the two ts pushed by subscription of incremental MBP ?
Subscription of incremental MBP:market.$contract_code.depth.size_${size}.high_freq,The outer ts is the timestamp when the market server sends the data.The inner ts is the timestamp when the orderbook is checked.
Q12: What is the difference between websocket subscription of MBP and incremental MBP? How often is the incremental MBP pushed?
market.$contract_code.depth.$type is snapshot MBP data,market.$contract_code.depth.size_${size}.high_freq is incremental MBP data.Snapshot MBP data is checked every 100ms,pushed at least every 1s.Incremental MBP data is checked every 30ms.It will not be pushed,if MBP has no update.
Q13: How to maintain local MBP data subscribing incremental MBP:market.$contract_code.depth.size_${size}.high_freq?
Snapshot MBP data will be pushed for the first time, and the incremental MBP data will be pushed afterwards.
(1) Compare the incremental price with the previous full MBP data, and replace the order amount with the same price;
(2) If the price is not in the local MBP data,add the price to the local MBP data;
(3) If a price level is gone, data such as [8100, 0] will be pushed.You have to remove the same price of local MBP data;
(4) For the same websocket connection, the incremental data version is incremented; if the version is not incremented, you need to re-subscribe and re-maintain the local full MBP data;
Q14: What's the difference between "funding_rate" and "realized_rate" in the response of /linear-swap-api/v1/swap_historical_funding_rate interface?
Generally, "funding_rate" is equal to "realized_rate".Only when the payment of funding fee will cause the liquidation of the user's position, the funding fee is under or not charged(And the fee is the actual funding fee:"realized_rate").The current funding rate:"funding_rate" remains unchanged.
Q15: When subscribing the same topic of several contract codes, will several ws be needed?
Since Futures, Coin Margined swaps, USDT Margined Contracts and Options are different contracts with different interface addresses, different ws will be needed.
In Futures, Coin Margined swaps, USDT Margined Contracts and Options thereof, as long as the interface address is the same, one ws is enough.
Q16: Is it available to place/cancel an order via WS??
Currently, it is not supported.
Q17: How to subscribe order status?
a. Successfully trade: “Subscribe Match Order Data (matchOrders.$contract_code)” or “Subscribe Order Data (orders.$contract_code)”
b. Successfully cancel: Subscribe Account Equity Updates Data (accounts.$contract_code)
Q18: What is the difference between the “Subscribe Match Order Data (matchOrders.$contract_code)” and “Subscribe Order Data (orders.$contract_code)”?
The pushed data of these two interfaces are different. Compared to “Subscribe Match Order Data (matchOrders.$contract_code)”, there are more fields for “Subscribe Order Data (orders.$contract_code)”
In general, the match order data (Subscribe Match Order Data “matchOrders.$contract_code”) may be pushed faster than the settled order data (Subscribe Order Data “orders.$contract_code”).
The orders of forced liquidation and netting will not be pushed in “Subscribe Match Order Data (matchOrders.$contract_code)”
Q19: How often is the “Subscribe Kline Data (market.$contract_code.kline.$period)” pushed?
If any transaction is completed, it will push every 500ms. If not, it will push according to the subscribe period
Q20: How to judge whether the push is delayed?
Please first synchronize the time of the server through https://api.hbdm.com/api/v1/timestamp), and the “ts” in the returned data is timestamp (ms) and the corresponding time zone is UTC+8.
The outer layer of each pushed data has a “ts”, which represents the time stamp (ms) when the server pushes the data to the client and the corresponding time zone is UTC+8.
When the data pushed arrive, the procedure will record the local time “ts”. When the local time “ts” is much later than the pushing data “ts”, you can use the following methods to improve the delay:
a. Reduce the data pushed by reducing the number of WS subscriptions.
b. Check the stability and speed of the network between procedure and the servers (please replace api.btcgateway.pro with the domain name used by the program)
curl -o /dev/null -s -w time_namelookup"(s)":%{time_namelookup}"\n"time_connect"(s)":%{time_connect}"\n"time_starttransfer"(s)":%{time_starttransfer}"\n"time_total"(s)":%{time_total}"\n"speed_download"(B/s)":%{speed_download}"\n" api.btcgateway.pro
and you will receive data as below:
time_namelookup(s):0.001378
time_connect(s):0.128641
time_starttransfer(s):0.276588
time_total(s):0.276804
speed_download(B/s):2010.000
If you run the above command multiple times in a row, and the results obtained each time are very different, you can: a. Select an appropriate Huobi domain name, b. Optimize or reselect the network where the program is located.
Order and Trade
Q1: What's the reason for 1004 error code?
We notice that the system is sometimes overloaded when the market suddenly turns to be highly volatile. If the system is busy recently or the following prompts appear:
{“status”: “error”, “err_code”: 1004, “err_msg”: “System busy. Please try again later.”, “ts”:}
please be patient, and do not place or cancel order repeatedly during the process to avoid repeated orders and additional pressure on system performance. In the meanwhile, it is recommended to place and cancel orders through Web and APP.
Q2: The same order ID and match ID can have multiple trades. for example: if a user take a large amount of maker orders, there will be multiple corresponding trades . How to identify these different trades ?
The field ID returned by the information interface /linear-swap-api/v1/swap_order_detail is a globally unique transaction identifier. if a maker order is matched multiple times, a trade will be pushed once there is a transaction matched.
Q3: What is the delay for the round trip of huobi USDT Margined swap?
At present,it normally takes about 30-50ms from placing the order to getting the status of the order.
Q4: Why does the API return connection reset or Max retris or Timeout error?
Most of the network connectivity problems ,(such as Connection reset or network timeout ) are caused by network instability , you can use the server in AWS Tokyo C area with api.hbdm.vn , which can effectively reduce network timeout errors.
Q5: How to check the order status without order_id not returned?
If the order_id couldn't be returned due to network problems, you can query the status of the order by adding the custom order number(client_order_id ).
Q6: What to do if it's diconnected after the websocket subscription of account, order and positions for a while?
When subscribing private accounts, orders and positions, the heartbeat should also be maintained regularly ,which is different from the market heartbeat format . Please refer to the "websocket Heartbeat and Authentication Interface" . if it is disconnected ,please try to reconnect.
Q7: What is the difference between order status 1 and 2 ? what is the status 3 ?
Status 1 is the preparation for submission. status 2 is the sequential submission of internal process, which can be considered that it has been accepted by the system. Status 3 indicated that the order has been already submitted to market.
Q8: Is there an interface to get the total assets in BTC of my account ?
No.
Q9: Why is the order filled after the order is withdrawed successfully by placing API cancellation ?
The success return of order cancellation or placement only represents that the command is excuted successfully and doesn't mean that the order has been cancelled . You can check the order status through the interface /linear-swap-api/v1/swap_order_info.
Q10: Does the order status of 10 mean the order is failed?
Query the order status by /linear-swap-api/v1/swap_order_info.If the status is 10,the order is failed。
Q11: How long does it generally take for an API from withdrawing to cancelling successfully ?
The order cancellation command generally takes several tens of ms. The actual status of order cancellation can be obtained by invoking an interface: /linear-swap-api/v1/swap_order_info
Q12: How to get historical liquidation orders?
To obtain historical liquidation orders, you can access the one of two api interfaces: Get History Orders (/linear-swap-api/v1/swap_hisorders【Isolated】or /linear-swap-api/v1/swap_cross_hisorders【Cross】), Get History Match Results (/linear-swap-api/v1/swap_matchresults【Isolated】or /linear-swap-api/v1/swap_cross_matchresults【Cross】) with the return field order_source (order source) to judge. When order_source returns "risk", it means that this order is a liquidated order.
Q13: Does Huob Futures support holding bi-directional position?
Yes, Huobi Futures supports long and short positions being held at the same time.
Q14: How to ensure the order to be rapidly filled?
At present, Huobi Futures does not support market price when placing an order. To increase the probability of a transaction, users can choose to place an order based on BBO price (opponent), optimal 5 (optimal_5), optimal 10 (optimal_10), optimal 20 (optimal_20), among which the success probability of optimal 20 is the largest, while the slippage always is the largest as well.
It is important to note that the above methods will not guarantee the order to be filled in 100%. The system will obtain the optimal N price at that moment and place the order.
Q15: How can API procedure be connected to the exchange more rapidly?
It’s recommended to use a AWS Tokyo c-zone server and the domain name “api.hbdm.vn” to connect to the system.
Q16: It occurs an “abnormal service” error when transferring assets between spots and derivatives.
a. Check whether the request address is the address of Huobi: api.huobi.pro?
b. Check whether the precision of the coin does not exceed 8 decimal places?
Q17: How to confirm whether the position is opened or closed successfully?
Placing an order successfully through “Place an Order” interface (/linear-swap-api/v1/swap_order) or “Place a batch of orders” interface (/linear-swap-api/v1/swap_batchorder) just means the server has received your order placing instructions rather than you have opened/closed a position successfully.
You can check the order status by filling the returned “order_id” in the “Get Information of an Order” interface (/linear-swap-api/v1/swap_order_info) or the “Order Details Acquisition” interface (/linear-swap-api/v1/swap_order_detail); If the order has been filled, the “status” value in the return parameter will turn out 6 (wholly filled)
It is important to note:
a. For “Get Information of an order” interface (/linear-swap-api/v1/swap_order_info), after the settlement or delivery, the system will delete all the orders in ended status (5: partially filled orders have been cancelled; 6: wholly filled; 7: cancelled);
b. There is a delay in “Order Details Acquisition” interface (/linear-swap-api/v1/swap_order_detail), so it is better to fill in “created_at” (order timestamp) and “order_type” (order type, fill in 1 by default). In this way, it will directly query the database, so the query results will be more timely.
Q18: Why are orders canceled by the system automatically?
The order_price_type which can be chosen are IOC, FOK and Maker (Post Only). When the order book cannot meet with the corresponding conditions, the system will cancel the orders automatically:
Post_only: If the order placed is filled with an existing order on the order book immediately, the order will be cancelled to ensure the user is always a maker.
IOC order: If the order cannot be filled immediately, the unfilled part will be cancelled at once;
FOK order: If the order cannot be filled in its entirety, it will be wholly cancelled. No partial fulfillments are allowed.
Q19: How to query the maximum amount (cont) available to open by using users’ current assets?
At present, we do not have an interface by which users can directly query the maximum amount (cont) available to open by using users’ the current asset.
Q20: Are the “order_id” and “order_id_str” the same?
The “order_id_str” is the string format of “order_id”, whose values are the same.
For the “order_id” with 18 bits, the “JSON.parse” in “nodejs” and “javascript” will be “int” by default, and mistakes will occur when analyzing. Thus, we advise using “order_id_str”.
Q21: How to get the active buying/selling quantity in transaction data?
Users can get the data via “Query The Last Trade of a Contract” (/linear-swap-ex/market/trade) interface or by subscribing "sub": "market.$contract_code.trade.detail", thereinto
Amount refers to the trading volume (cont), which is the sum of the buying/selling volume;
Direction refers to the active trading direction.
Q22: The interval between “from” and “to” is “2000*period” when acquiring KLine data, then why the data obtained is []?
When acquiring the Kline data, the two time points “from” and “to” are contained, therefore it includes 2001 pieces of data. However, this exceeds the maximum limit 2000. Therefore, the system will return [].
Besides, the returned data will be [] as well if the interval between “from” and “to” exceeds 2 years.
Q23: How to get the latest price?
There are two methods to get the latest price:
a. Invoking the “Get KLine Data(/linear-swap-ex/market/history/kline)” interface and filling in any “period”, the “close” of the last data in return data will be the latest price;
b. Invoking the “Query The Last Trade of a Contract(/linear-swap-ex/market/trade)” interface, the returned “price” will be the latest price.
Q24: How to get the latest index price?
There are two methods to get the latest index price:
a. Calling the “Get Contract Index Price Information” interface (/linear-swap-api/v1/swap_index), the returned “index_price” will be the latest index price.
b. Calling the “Subscribe Index Kline Data” websocket (market.$contract_code.index.$period), the “close” of the last Kline data in returned data will be the latest index price.
Q25: Will API upgrade affect the operation of the program?
In general, API upgrade will partly influence the ws disconnection. To avoid this, you can set up a ws-reconnect mechanism in advance; Please subscribe to the upgrade announcements for more details:
Coin-margined futures: https://status-dm.huobigroup.com/
Coin-margined swaps: https://status-swap.huobigroup.com/
USDT-margined Contracts: https://status-linear-swap.huobigroup.com/
Q26: What does mean the “margin_balance” in “Query User’s Account Information” interface (api/v1/contract_account_info)?
”margin_balance” refers to the account equity
margin_balance = margin_static + profit_unreal
margin_balance = Account balance + profit_real + profit_unreal
Note: Account balance = margin_static - profit_real, there is only margin_static in the return data of api interface
Each of the two calculation methods above can get the margin_balance
Q27: Is the “risk_rate” (margin rate) in “Query User’s Account Information” interface (/linear-swap-api/v1/swap_account_info) the same as the margin rate on WEB?
Yes, it is
When the “risk_rate” is less than or equal to 0, the position will be liquidated.
Error Codes
Q1: What is the reason for 1030 error code?
If you encounter errors such as {"status":"error","err_code":1030,"err_msg":"Abnormal service. Please try again later.","ts":1588093883199},indicating that your input request parameter is not correct, please print your request body and complete URL parameters, and please check the corresponding API document interface one by one.The common example is that the volume must be an integer.
Q2: What is the reason for 1048 error code?
If you encounter errors such as {'index': 1, 'err_code': 1048, 'err_msg': 'Insufficient close amount available.'}, indicating that your available position is not enough.You need to query the api /linear-swap-api/v1/swap_position_info to get your available position.
Check whether the amount (cont) of position-closing order exceeds the limit? (When there is limit order for closing a position, the quantity that available to be closed will be occupied; hence we kindly remind you to cancel these orders and try again.)
Check whether direction and offset are wrong as follows:
close long: sell to close a long position (direction: sell; offset: close);
close short: buy to close a short position (direction: buy; offset: close);
Only “direction” need to be uploaded when placing a flash close order (close long: sell; close short: buy).
- The pending take-profit and stop-loss (tp/sl) orders and trigger orders will not occupy the quantity of the position.
Q3: What is the reason for 1032 error code?
1032 means that your request exceeds the ratelimit. The coin margined swap, future and USDT margined Contracts limit the rate separately. Please check the ratelimit in the api ratelimit instructions, and you can print the current ratelimit in the header of the API response to check whether the ratelimit is exceeded. It is recommended to increase the request interval delay to avoid exceeding the ratelimit.
The usage of and the difference between cross margin mode and isolated margin mode
Under the cross margin mode, all swaps share the USDT in the cross margin account as the margin, which indicates that all positions under the cross margin mode share the same account equity, and their PnL, occupied margin and margin ratio are calculated jointly. Under the isolated margin mode, the account equity for each swaps are calculated separately, and the position margin and PnL of each swaps will not affect each other.
The cross margin mode and the isolated margin mode use different margin accounts, and the assets are independent of each other. Users can trade, or hold positions under the two modes at the same time. For example, in BTC/USDT swaps trading, the margin account for cross margin trading is USDT, while the margin account for isolated margin trading is BTC-USDT.
API users can use the support_margin_mode field (margin mode supported by the contract) of the API interface [Query Swap Info: linear-swap-api/v1/swap_contract_info] to check which mode (cross/isolated) the contract supports.
The API interface is divided into three modes, [Cross], [Isolated] and [General]. These three modes are marked on the API interface name and the interface list. [Cross] indicates that the API interface only supports cross margin mode. [Isolated] indicates that the API interface only supports isolated margin mode, and [General] indicates that the API interface supports both two modes, indicating that it can be called by both the cross margin mode and isolated margin mode.
How to solve problems more effectively?
When you report an API error, you need to attach your request URL, the original complete body of the request and the complete request URL parameters, and the original complete log of the server's response. If it is a websocket subscription, you need to provide the address of the subscription, the topic of the subscription, and the original complete log pushed by the server.
If it is an order-related issue, use the API order query interface /linear-swap-api/v1/swap_order_info to keep the complete log returned and provide your UID and order number.
Reference Data
Account type query
- GET
/linear-swap-api/v3/swap_unified_account_type
Remarks
This interface is used for the account type inquired by the client. Currently, U-margined contracts have unified account and non-unified account (cross-margin and isolated-margin account). The assets of the unified account type are placed in one USDT account, and the assets of the cross-margin isolated account type are placed in different currency pairs.
The unified account type is the latest upgrade and currently does not support API ordering. If you need to use the API to place an order, please switch the account type to a non-unified account via /linear-swap-api/v3/swap_switch_account_type.
Request Parameter
NO
Response:
{
"code":200,
"msg":"ok",
"data":{
"account_type":1
},
"ts":1668057324200
}
Return Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
code | true | int | State code | |
msg | true | string | The code description | |
ts | true | long | Timestamp | |
<data> | true | |||
account_type | true | int | account type | 1:Non-unified account (cross-margin and isolated-margin account) 2:Unified account |
</data> | true |
Account Type Change
- POST
/linear-swap-api/v3/swap_switch_account_type
Remarks
- Before calling this interface, it is necessary to ensure that there are no positions and pending orders in the U-margined contract. When the account is changed from a non-uniform account (cross-margin isolated account) to a uniform account, the assets must be transferred from the isolated account to the cross-margin account.
Request Parameter
Request:
{
"account_type": 1
}
请求参数
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
account_type | true | int | account type | 1:Non-unified account (cross-margin and isolated-margin account) |
Response:
{
"code":200,
"msg":"ok",
"data":{
"account_type":1
},
"ts":1668057324200
}
Return Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
code | true | int | State code | |
msg | true | string | The code description | |
ts | true | long | Timestamp | |
<data> | true | |||
account_type | true | int | account type | 1:Non-unified account (cross-margin and isolated-margin account) |
</data> | true |
[General] Query historical settlement records of the platform interface
- GET
/linear-swap-api/v1/swap_settlement_records
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | Contract Code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
start_time | false | long | Start time(timestamp,unit: millisecond) | Value range: [(Current time minus 90 days), Current time] ,default current time minus 90 days |
end_time | false | long | End time(timestamp,unit: millisecond) | Value range: (start_time, current time),default current time |
page_index | false | int | Page, default page 1 if not filled | |
page_size | false | int | Page items, default 20, shall not exceed 50 |
Response:
{
"status": "ok",
"data": {
"total_page": 1,
"current_page": 1,
"total_size": 12,
"settlement_record": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211203",
"settlement_time": 1638518400000,
"clawback_ratio": 0E-18,
"settlement_price": 56792.300000000000000000,
"settlement_type": "delivery",
"business_type": "futures",
"pair": "BTC-USDT"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211203",
"settlement_time": 1638489600000,
"clawback_ratio": 0E-18,
"settlement_price": 57028.600000000000000000,
"settlement_type": "settlement",
"business_type": "futures",
"pair": "BTC-USDT"
}
]
},
"ts": 1638756873768
}
Return Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Response generation time point, unit: millisecond | |
<data> | true | object array | ||
<settlement_record> | true | object array | ||
symbol | true | string | Token Code | |
contract_code | true | string | Contract Code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
settlement_time | true | long | Settlement Time(timestamp,unit: millisecond)(when the settlement_type is delivery, the time is delivery time; when the settlement_type is settlement, the time is settlement time) | |
clawback_ratio | true | decimal | Clawback Ratio | |
settlement_price | true | decimal | Settlement Price(when the settlement_type is delivery, the price is delivery price; when the settlement_type is settlement, the price is settlement price;) | |
settlement_type | true | string | Settlement Type | “delivery”:Delivery,“settlement”:Settlement |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</settlement_record> | ||||
total_page | true | int | Total Pages | |
current_page | true | int | Current Page | |
total_size | true | int | Total page items | |
</data> |
[General] Query Liquidation Orders(New)
- POST
/linear-swap-api/v3/swap_liquidation_orders
Remarks
- The interface supports cross margin mode and isolated margin mode.
- The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
- one of pair and contract_code must be filled in; and all filled in, the contract_code is the preferred.
Request:
/linear-swap-api/v3/swap_liquidation_orders?trade_type=5&contract=BTC-USDT
Request Parameter
Parameter Name | Required | Type | Desc | Default | Value Range | OriginalParameter |
---|---|---|---|---|---|---|
contract | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" | contract_code | |
pair | false(more see remarks) | string | pair | BTC-USDT | ||
trade_type | true | int | trade type | 0:All; 1: Open long; 2: Open short; 3: Close short; 4: Close long; 5: Liquidate long positions; 6: Liquidate short positions, 17:buy(one-way mode), 18:sell(one-way mode) | ||
start_time | false | long | Query start time, query by data creation time | Value range [((end-time) – 2h), (end-time)] , maximum query window size is 2 hours, query window shift should be within past 90 days. |
||
end_time | false | long | Query end time, query data by creation time | now | Value range [(present-90d), present] , maximum query window size is 48 hours, query window shift should be within past 90 days. |
|
direct | false | string | Search direct, If the direction is NEXT, the data is returned in positive chronological order; if the direction is PREV, the data is returned in reverse chronological order | next | next, prev default is prev | |
from_id | false | long | If the query direction is prev, from_id should be the min query_id in the last query result. If the query direction is next, from_id should be the max query_id in the last query result | Search query_id to begin with |
Response:
{
"code": 200,
"msg": "",
"data": [
{
"query_id": 452057,
"contract_code": "BTC-USDT-211210",
"symbol": "USDT",
"direction": "sell",
"offset": "close",
"volume": 479.000000000000000000,
"price": 51441.700000000000000000,
"created_at": 1638593647864,
"amount": 0.479000000000000000,
"trade_turnover": 24640.574300000000000000,
"business_type": "futures",
"pair": "BTC-USDT"
}
],
"ts": 1604312615051
}
Response Content
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
code | true | int | State code | |
msg | true | string | The code description | |
ts | true | long | Timestamp | |
<data> | true | object array | ||
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | e.g. swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
created_at | true | long | liquidation time | |
direction | true | string | "buy":buy"sell": sell | |
offset | true | string | "open":open "close": close, "both" | |
volume | true | decimal | liquidation volume (cont) | |
amount | true | decimal | liquidation amount (token) | |
price | true | decimal | bankruptcy price | |
trade_turnover | true | decimal | liquidation amount (quotation token) | |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</data> |
[General] Query historical funding rate
- GET
/linear-swap-api/v1/swap_historical_funding_rate
curl "https://api.hbdm.com/linear-swap-api/v1/swap_historical_funding_rate?contract_code=BTC-USDT"
Remarks
- The interface supports cross margin mode and isolated margin mode.
Request Parameters
parameter name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.eg:"BTC-USDT" ... |
page_index | false | int | page index. 1 by default | |
page_size | false | int | page size.20 by default. 50 at most | [1-50] |
Response:
{
"status": "ok",
"data": {
"total_page": 14,
"current_page": 1,
"total_size": 14,
"data": [
{
"avg_premium_index": "0.000049895833333333",
"funding_rate": "0.000100000000000000",
"realized_rate": "0.000100000000000000",
"funding_time": "1603670400000",
"contract_code": "BTC-USDT",
"symbol": "BTC",
"fee_asset": "USDT"
}
]
},
"ts": 1603696680599
}
Response Parameters
parameter name | type | desc | value range |
---|---|---|---|
status | string | response status | "ok" , "error" |
ts | long | response timestamp.unit:millionSeconds. | |
<data> | |||
<data> | |||
symbol | string | symbol | eg:"BTC","ETH"... |
contract_code | string | contract code | eg: "BTC-USDT |
fee_asset | string | fee asset | eg:"USDT" |
funding_time | string | funding time | |
funding_rate | string | funding rate | |
realized_rate | string | realized funding rate | |
avg_premium_index | string | average premium index | |
</data> | |||
total_page | int | total page | |
current_page | int | current page | |
total_size | int | total size | |
</data> |
[General]Query a Batch of Funding Rate
- GET
/linear-swap-api/v1/swap_batch_funding_rate
Note
- The interface supports cross margin mode and isolated margin mode
Request Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code,if not filled in, default as all | "BTC-USDT" ... |
Response
{
"status": "ok",
"data": [
{
"estimated_rate": "-0.007500000000000000",
"funding_rate": "-0.007500000000000000",
"contract_code": "ETC-USDT",
"symbol": "ETC",
"fee_asset": "USDT",
"funding_time": "1613976000000",
"next_funding_time": "1614004800000"
},
{
"estimated_rate": "-0.007500000000000000",
"funding_rate": "-0.007500000000000000",
"contract_code": "ADA-USDT",
"symbol": "ADA",
"fee_asset": "USDT",
"funding_time": "1613976000000",
"next_funding_time": "1614004800000"
}
],
"ts": 1614045373795
}
Returning Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handles for the request | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | "BTC-USDT" ... |
fee_asset | true | string | fee asset | "USDT... |
funding_time | true | string | current funding time(Millisecond) | |
funding_rate | true | string | current funding rate | |
estimated_rate | true | string | estimated funding rate of current period | |
next_funding_time | true | string | estimated funding rate of next period(Millisecond) | |
</data> |
[General] Query funding rate
- GET
/linear-swap-api/v1/swap_funding_rate
curl "https://api.hbdm.com/linear-swap-api/v1/swap_funding_rate?contract_code=BTC-USDT"
Remarks
- The interface supports cross margin mode and isolated margin mode.
Request Parameters
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive."BTC-USDT" ... |
Response:
{
"status": "ok",
"data": {
"estimated_rate": "0.000100000000000000",
"funding_rate": "0.000100000000000000",
"contract_code": "BTC-USDT",
"symbol": "BTC",
"fee_asset": "USDT",
"funding_time": "1603699200000",
"next_funding_time": "1603728000000"
},
"ts": 1603696494714
}
Response Parameters
field name | type | desc | value range |
---|---|---|---|
status | string | response status | "ok" , "error" |
ts | long | response timestamp.unit:millionSeconds. | |
<data> | |||
symbol | string | symbol | "BTC","ETH"... |
contract_code | string | contract code,eg:"BTC-USDT" | |
fee_asset | string | fee asset | eg:"BTC","ETH"... |
funding_time | string | current funding time | |
funding_rate | string | current funding rate | |
estimated_rate | string | estimated funding rate of current period(Updated once a minute) | |
next_funding_time | string | estimated funding rate of next period | |
</data> |
[Isolated] Query information on system status
- GET
/linear-swap-api/v1/swap_api_state
curl "https://api.hbdm.com/linear-swap-api/v1/swap_api_state"
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code | Case-Insenstive.e.g. "BTC-USDT" |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"open": 1,
"close": 1,
"cancel": 1,
"transfer_in": 1,
"transfer_out": 1,
"master_transfer_sub": 1,
"sub_transfer_master": 1,
"master_transfer_sub_inner_in": 1,
"master_transfer_sub_inner_out": 1,
"sub_transfer_master_inner_in": 1,
"sub_transfer_master_inner_out": 1,
"transfer_inner_in": 1,
"transfer_inner_out": 1
}
],
"ts": 1603696366019
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | Contract Code | "BTC-USDT"... |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
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" | |
master_transfer_sub | true | int | transfer from master to sub account:"1" is available,“0” is unavailable | |
sub_transfer_master | true | int | transfer from sub to master account:"1" is available,“0” is unavailable | |
master_transfer_sub_inner_in | true | int | Transfer_in access for transfer from main account to sub-account - crossing account: "1" represents "available", "0" represents "unavailable" | |
master_transfer_sub_inner_out | true | int | Transfer_out access for transfer from main account to sub-account - crossing account: "1" represents "available", "0" represents "unavailable" | |
sub_transfer_master_inner_in | true | int | Transfer_in access for transfer from sub-account to main account - crossing account: "1" represents "available", "0" represents "unavailable" | |
sub_transfer_master_inner_out | true | int | Transfer_out access for transfer from sub-account to main account - crossing account: "1" represents "available", "0" represents "unavailable" | |
transfer_inner_in | true | int | Transfer_in access for transfer between different margin accounts under the same account:"1" represents "available", "0" represents "unavailable" | |
transfer_inner_out | true | int | Transfer_out access for transfer between different margin accounts under the same account:"1" represents "available", "0" represents "unavailable" | |
</data> |
[General] Query Top Trader Sentiment Index Function-Position
- GET
/linear-swap-api/v1/swap_elite_position_ratio
curl "https://api.hbdm.com/linear-swap-api/v1/swap_elite_position_ratio?contract_code=BTC-USDT&period=60min"
Remarks
The interface supports cross margin mode and isolated margin mode.
contract_code supports all contract code of futures, and its value is: BTC-USDT-FUTURES.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
period | true | string | period | 5min, 15min, 30min, 60min,4hour,1day |
Response:
{
"status":"ok",
"data":{
"list":[
{
"buy_ratio":0.5,
"sell_ratio":0.5,
"ts":1638460800000
}
],
"symbol":"BTC",
"contract_code":"BTC-USDT-FUTURES",
"business_type":"futures",
"pair":"BTC-USDT"
},
"ts":1638756121395
}
Returning Parameter
Parameter Name | Required | 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 | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | e.g. swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
<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> |
[General] Query Top Trader Sentiment Index Function-Account
- GET
/linear-swap-api/v1/swap_elite_account_ratio
curl "https://api.hbdm.com/linear-swap-api/v1/swap_elite_account_ratio?contract_code=BTC-USDT&period=60min"
Remarks
The interface supports cross margin mode and isolated margin mode.
contract_code supports all contract code of future, and its value is: BTC-USDT-FUTURES.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
period | true | string | period | 5min, 15min, 30min, 60min,4hour,1day |
Response:
{
"status":"ok",
"data":{
"list":[
{
"buy_ratio":0.5,
"sell_ratio":0.5,
"locked_ratio":0,
"ts":1638115200000
}
],
"symbol":"BTC",
"contract_code":"BTC-USDT",
"business_type":"swap",
"pair":"BTC-USDT"
},
"ts":1638169688105
}
Returning Parameter
Parameter Name | Required | Type | Desc | Vaue Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | ||||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | e.g. swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
<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> |
[Cross]Query information on Tiered Margin
- GET
/linear-swap-api/v1/swap_cross_ladder_margin
Note
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code, if not filled in return all contract infomation | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response
{
"status":"ok",
"data":[
{
"margin_account":"USDT",
"symbol":"BTC",
"contract_code":"BTC-USDT",
"margin_mode":"cross",
"list":[
{
"lever_rate":2,
"ladders":[
{
"min_margin_balance":0,
"max_margin_balance":null,
"min_margin_available":0,
"max_margin_available":null
}
]
}
],
"business_type":"swap",
"pair":"BTC-USDT",
"contract_type":"swap"
}
],
"ts":1638755685337
}
Returning Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | "ok" , "error" |
<data> | true | object array | ||
symbol | true | string | symbol | such as: "BTC" |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross |
margin_account | true | string | margin account | such as:USDT” |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
<list> | true | object array | ||
lever_rate | true | int | lever rate | |
<ladders> | true | object array | ladders for margin | |
min_margin_balance | true | decimal | min margin balance(the starting point in this ladder, included in this ladder) | |
max_margin_balance | true | decimal | max margin balance(the end point in this ladder, excluded in this ladder, is next ladder's min_margin_balance) | |
min_margin_available | true | decimal | min margin available(in the range of this ladder margin balance) | |
max_margin_available | true | decimal | max margin available(not in the range of this ladder margin balance, is next ladder's min_margin_available) | |
</ladders> | ||||
</list> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit:Millisecond |
[Isolated]Query information on Tiered Margin
- GET
/linear-swap-api/v1/swap_ladder_margin
Note
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code, if not filled in return all contract infomation | such as: “BTC-USDT”, “ETH-USDT”。。。 |
Response
{
"status": "ok",
"data": [
{
"margin_account": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"list": [
{
"lever_rate": 20,
"ladders": [
{
"min_margin_balance": 0,
"max_margin_balance": 250000,
"min_margin_available": 0,
"max_margin_available": 250000
},
{
"min_margin_balance": 250000,
"max_margin_balance": 2500000,
"min_margin_available": 250000,
"max_margin_available": 1000000
},
{
"min_margin_balance": 2500000,
"max_margin_balance": 10000000,
"min_margin_available": 1000000,
"max_margin_available": 2500000
},
{
"min_margin_balance": 10000000,
"max_margin_balance": 85000000,
"min_margin_available": 2500000,
"max_margin_available": 10000000
},
{
"min_margin_balance": 85000000,
"max_margin_balance": null,
"min_margin_available": 10000000,
"max_margin_available": null
}
]
}
]
}
],
"ts": 1612504906880
}
Returning Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
<data> | true | object array | ||
symbol | true | string | symbol | such as: "BTC" |
contract_code | true | string | contract code | such as: "BTC-USDT" |
margin_mode | true | string | margin mode | isolated: isolated |
margin_account | true | string | margin account | such as: “BTC-USDT” |
<list> | true | object array | ||
lever_rate | true | int | lever rate | |
<ladders> | true | object array | ladders for margin | |
min_margin_balance | true | decimal | min margin balance(the starting point in this ladder, included in this ladder) | |
max_margin_balance | true | decimal | max margin balance(the end point in this ladder, excluded in this ladder, is next ladder's min_margin_balance) | |
min_margin_available | true | decimal | min margin available(in the range of this ladder margin balance) | |
max_margin_available | true | decimal | max margin available(not in the range of this ladder margin balance, is next ladder's min_margin_available) | |
</ladders> | ||||
</list> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit:Millisecond |
[General]Get the estimated settlement price
- GET
/linear-swap-api/v1/swap_estimated_settlement_price
Note
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code, return all without filling in | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response
{
"status": "ok",
"data": [
{
"contract_code": "BTC-USDT-211210",
"estimated_settlement_price": null,
"settlement_type": "settlement",
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "this_week"
},
{
"contract_code": "BTC-USDT-211217",
"estimated_settlement_price": null,
"settlement_type": "settlement",
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "next_week"
},
{
"contract_code": "BTC-USDT-211231",
"estimated_settlement_price": null,
"settlement_type": "settlement",
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "quarter"
},
{
"contract_code": "BTC-USDT",
"estimated_settlement_price": null,
"settlement_type": "settlement",
"business_type": "swap",
"pair": "BTC-USDT",
"contract_type": "swap"
}
],
"ts": 1638755400222
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | |
<data> | true | object array | ||
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
estimated_settlement_price | true | decimal | Current-period estimated settlement price /Current-period estimated delivery price (When the settlement type is "delivery", it is estimated delivery price; Otherwise, it is estimated settlement price) | |
settlement_type | true | string | settlement type | “delivery”,“settlement” |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
Note
- When the "settlement_type" is "settlement", the "estimated_settlement_price" will be calculated and updated from 10 minutes before settlement and until the settlement. In the other moment(including settlement), "estimated_settlement_price" is empty, but the other fields will be displayed normally.
- When the "settlement_type" is "delivery", the "estimated_settlement_price" will be calculated and updated from 10 minutes before settlement and until the delivery. In the other moment(including delivery), "estimated_settlement_price" is empty, but the other fields will be displayed normally.
- Estimated settlement price will be calculated and updated every 6 seconds.
[Cross] Query Information On Tiered Adjustment Factor
- GET
/linear-swap-api/v1/swap_cross_adjustfactor
Remarks
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response:
{
"status":"ok",
"data":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT-211210",
"margin_mode":"cross",
"list":[
{
"lever_rate":1,
"ladders":[
{
"ladder":0,
"min_size":0,
"max_size":3999,
"adjust_factor":0.005
},
{
"ladder":1,
"min_size":4000,
"max_size":39999,
"adjust_factor":0.01
},
{
"ladder":2,
"min_size":40000,
"max_size":79999,
"adjust_factor":0.015
},
{
"ladder":3,
"min_size":80000,
"max_size":119999,
"adjust_factor":0.02
},
{
"ladder":4,
"min_size":120000,
"max_size":null,
"adjust_factor":0.025
}
]
}
],
"business_type":"futures",
"pair":"BTC-USDT",
"contract_type":"this_week"
}
],
"ts":1638754992327
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross: cross margin mode |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
<list> | true | object array | ||
lever_rate | true | decimal | lever rate | |
<ladders> | true | object array | ||
min_size | true | decimal | min net position limit | |
max_size | true | decimal | max net position limit | |
ladder | true | int | tier | from 0 |
adjust_factor | true | decimal | adjustment factor | |
</ladders> | ||||
</list> | ||||
</data> |
[Isolated] Query information on Tiered Adjustment Factor
- GET
/linear-swap-api/v1/swap_adjustfactor
curl "https://api.hbdm.com/linear-swap-api/v1/swap_adjustfactor"
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false | string | contract code | Case-Insenstive.e.g. "BTC-USDT" |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"list": [
{
"lever_rate": 125,
"ladders": [
{
"ladder": 0,
"min_size": 0,
"max_size": 8999,
"adjust_factor": 0.650000000000000000
},
{
"ladder": 1,
"min_size": 9000,
"max_size": 89999,
"adjust_factor": 0.800000000000000000
},
{
"ladder": 2,
"min_size": 90000,
"max_size": null,
"adjust_factor": 0.850000000000000000
}
]
}
]
}
],
"ts": 1603695606565
}
Returning Parameter
Parameter Name | Required | 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 | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | e.g. "BTC-USDT" |
margin_mode | true | string | margin mode | isolated : "isolated" |
<list> | ||||
lever_rate | true | decimal | Leverage | |
<ladders> | ||||
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 | |
</ladders> | ||||
</list> | ||||
</data> |
[General] Query history records of insurance fund balance
- GET
/swap-api/v1/linear-swap-api/v1/swap_insurance_fund
curl "https://api.hbdm.com/linear-swap-api/v1/swap_insurance_fund?contract_code=ETH-USDT"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-FUTURES.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
page_index | false | int | page index. 1 by default | |
page_size | false | int | page size.100 by default. 100 at most | [1-100] |
Response:
{
"status": "ok",
"data": {
"total_page": 1,
"current_page": 1,
"total_size": 4,
"symbol": "BTC",
"contract_code": "BTC-USDT-FUTURES",
"tick": [
{
"insurance_fund": 16174.621898868113476721,
"ts": 1638691200000
},
{
"insurance_fund": 130.912398868113476721,
"ts": 1638604800000
},
{
"insurance_fund": 0.002860554220000000,
"ts": 1638518400000
},
{
"insurance_fund": 0,
"ts": 1638432000000
}
],
"business_type": "futures",
"pair": "BTC-USDT"
},
"ts": 1638754881217
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | Dictionary Data | |||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | e.g. swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
<tick> | ||||
insurance_fund | true | decimal | Insurance Fund Balance | |
ts | true | long | Timestamp, Unit: Millisecond | |
</tick> | ||||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
</data> |
[General] Query information on contract insurance fund balance and estimated clawback rate
- GET
/linear-swap-api/v1/swap_risk_info
curl "https://api.hbdm.com/linear-swap-api/v1/swap_risk_info"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-FUTURES.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
business_type | false | string | business type, default is swap | futures, swap, all |
Response:
{
"status": "ok",
"data": [
{
"contract_code": "BTC-USDT",
"insurance_fund": 16174.621898868113476721,
"estimated_clawback": 0E-18,
"business_type": "swap",
"pair": "BTC-USDT"
},
{
"contract_code": "BTC-USDT-FUTURES",
"insurance_fund": 16174.621898868113476721,
"estimated_clawback": 0E-18,
"business_type": "futures",
"pair": "BTC-USDT"
},
{
"contract_code": "ETH-USDT",
"insurance_fund": 16174.621898868113476721,
"estimated_clawback": 0E-18,
"business_type": "swap",
"pair": "ETH-USDT"
},
{
"contract_code": "ETH-USDT-FUTURES",
"insurance_fund": 16174.621898868113476721,
"estimated_clawback": 0E-18,
"business_type": "futures",
"pair": "ETH-USDT"
}
],
"ts": 1638754774555
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | ||||
contract_code | true | string | contract code | e.g. swap: "BTC-USDT"... , future: "BTC-USDT-FUTURES" ... |
insurance_fund | true | decimal | Insurance Fund Balance | |
estimated_clawback | true | decimal | Estimated Clawback Rate | |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</data> |
[General] Get Swap Open Interest Information
Example
- GET
/linear-swap-api/v1/swap_open_interest
curl "https://api.hbdm.com/linear-swap-api/v1/swap_open_interest?contract_code=BTC-USDT"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Parameter Type | Required | Desc |
---|---|---|---|
contract_code | string | false | eg swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | string | false | pair, BTC-USDT |
contract_type | string | false | contract type: swap, this_week, next_week, quarter, next_quarter |
business_type | string | false(more see remarks) | business type, default is swap: futures, swap, all |
Response:
{
"status": "ok",
"data": [
{
"volume": 78696.000000000000000000,
"amount": 78.696000000000000000,
"symbol": "BTC",
"value": 3823138.245600000000000000,
"contract_code": "BTC-USDT",
"trade_amount": 0,
"trade_volume": 0,
"trade_turnover": 0,
"business_type": "swap",
"pair": "BTC-USDT",
"contract_type": "swap"
},
{
"volume": 10925.000000000000000000,
"amount": 10.925000000000000000,
"symbol": "BTC",
"value": 530662.210000000000000000,
"contract_code": "BTC-USDT-211217",
"trade_amount": 0,
"trade_volume": 0,
"trade_turnover": 0,
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "next_week"
},
{
"volume": 27104.000000000000000000,
"amount": 27.104000000000000000,
"symbol": "BTC",
"value": 1316937.283200000000000000,
"contract_code": "BTC-USDT-211210",
"trade_amount": 0,
"trade_volume": 0,
"trade_turnover": 0,
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "this_week"
},
{
"volume": 201143.000000000000000000,
"amount": 201.143000000000000000,
"symbol": "BTC",
"value": 9775067.056800000000000000,
"contract_code": "BTC-USDT-211231",
"trade_amount": 0,
"trade_volume": 0,
"trade_turnover": 0,
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "quarter"
}
],
"ts": 1638754059540
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
symbol | true | string | Variety code | "BTC", "ETH" ... |
volume | true | decimal | Position quantity(volume). Sum of both buy and sell sides | |
amount | true | decimal | Position quantity(Currency). Sum of both buy and sell sides | |
contract_code | true | string | Contract Code | eg swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
value | true | decimal | Total position volume(The unit is the denominated currency of the contract. e.g:USDT) | |
trade_amount | true | decimal | trading volume within the last 24 hours (coin). Sum of both buy and sell sides | |
trade_volume | true | decimal | trading volume within the last 24 hours (cont). Sum of both buy and sell sides | |
trade_turnover | true | decimal | trading amount within the last 24 hours. Sum of both buy and sell sides | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
Note
- Position volume (coin) = position quantity (cont) * contract face value
- Total position amount = position quantity (cont)* contract face value * latest price
[General] Query Swap Price Limitation
Example
- GET
/linear-swap-api/v1/swap_price_limit
curl "https://api.hbdm.com/linear-swap-api/v1/swap_price_limit?contract_code=BTC-USDT"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Parameter Type | Required | Desc |
---|---|---|---|
contract_code | string | false | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | string | false | pair, BTC-USDT |
contract_type | string | false | contract type: swap, this_week, next_week, quarter, next_quarter |
business_type | string | false(more see remarks) | business type, default is swap: futures, swap, all |
Response
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"high_limit": 38766.300000000000000000000000000000000000,
"low_limit": 37250.700000000000000000000000000000000000,
"business_type": "swap",
"pair": "BTC-USDT",
"contract_type": "swap"
}
],
"ts": 1621936043576
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" ,"error" |
<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 swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
<data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General] Query Swap Index Price Information
Example
- GET
/linear-swap-api/v1/swap_index
curl "https://api.hbdm.com/linear-swap-api/v1/swap_index?contract_code=BTC-USDT"
Remarks
- The interface supports cross margin mode and isolated margin mode.
Request Parameter
Parameter Name | Parameter Type | Required | Desc |
---|---|---|---|
contract_code | string | false | Case-insenstive."BTC-USDT","ETH-USDT"... |
Response
{
"status": "ok",
"data": [
{
"index_price": 13076.329865680000000000,
"index_ts": 1603694592011,
"contract_code": "BTC-USDT"
}
],
"ts": 1603694596400
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
contract_code | true | string | contract code | "BTC-USDT","ETH-USDT"... |
index_price | true | decimal | Index Price | |
index_ts | true | Long | Index time | |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit:Millisecond |
[General] Query Swap Info
Example
- GET
/linear-swap-api/v1/swap_contract_info
curl "https://api.hbdm.com/linear-swap-api/v1/swap_contract_info"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "support_margin_mode" should be "all" when querying the contract information which supports the cross margin mode and the isolated margin mode both. The value of "cross" or "isolated" just can query the contract information which only supports the cross margin mode or the isolated margin mode. Please keep attention.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-201101; When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
When support_margin_mode is isolated,contract_type, business_type should not be futures type. And when support_margin_mode is cross, the return data is future's data
Request Parameter
Parameter Name | Type | Required | Description |
---|---|---|---|
contract_code | string | false | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
support_margin_mode | string | false | support margin mode cross:"cross";isolated:"isolated";all:"all" |
pair | string | false | BTC-USDT |
contract_type | string | false | swap, this_week, next_week, quarter, next_quarter |
business_type | string | false(more see remarks) | futures, swap, all(default is swap) |
Response
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211203",
"contract_size": 0.001000000000000000,
"price_tick": 0.100000000000000000,
"delivery_date": "20211203",
"delivery_time": "1638518400000",
"create_date": "20211202",
"contract_status": 1,
"settlement_date": "1638518400000",
"support_margin_mode": "cross",
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "this_week"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"contract_size": 0.001000000000000000,
"price_tick": 0.100000000000000000,
"delivery_date": "20211210",
"delivery_time": "1639123200000",
"create_date": "20211202",
"contract_status": 1,
"settlement_date": "1638518400000",
"support_margin_mode": "cross",
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "next_week"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"contract_size": 0.001000000000000000,
"price_tick": 0.100000000000000000,
"delivery_date": "20211231",
"delivery_time": "1640937600000",
"create_date": "20211202",
"contract_status": 1,
"settlement_date": "1638518400000",
"support_margin_mode": "cross",
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "quarter"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"contract_size": 0.001000000000000000,
"price_tick": 0.100000000000000000,
"delivery_date": "",
"delivery_time": "",
"create_date": "20211202",
"contract_status": 1,
"settlement_date": "1638518400000",
"support_margin_mode": "all",
"business_type": "swap",
"pair": "BTC-USDT",
"contract_type": "swap"
}
],
"ts": 1638517765776
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | Contract Code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
contract_size | true | decimal | Contract Value (USDT of one contract) | 10, 100... |
price_tick | true | decimal | Minimum Variation of Contract Price | 0.001, 0.01... |
settlement_date | true | string | Settlement Date | eg "1490759594752" |
create_date | true | string | Listing Date | eg "20190808" |
delivery_time | true | string | delivery time(When the contract does not need to be delivered, the field value is an empty string),millesecond timestamp | |
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 |
support_margin_mode | false | string | support margin mode | cross:"cross";isolated:"isolated";all:"all" |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
delivery_date | true | string | delivery date, empty string when swap | such as: "20180720" |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit:Millisecond |
Maintenance with service suspended
During the maintenance of the business system, in addition to the below two interfaces(Get system status, Query whether the system is available) for users to query the system status, all “rest” interfaces of the API business will return this in a fixed manner:{"status": "maintain"}
. During maintenance with service suspended,all websocket notify interfaces except subscribing system status updates(Subscribe system status updates)can't work,and will push 1006 error code to clients.
Response
{
"status": "maintain"
}
- Query whether the system is available: https://api.hbdm.com/heartbeat/
for getting the infomation that system maintenance with service suspended, could by subscrib system status updates websocket interface.
Get current system timestamp
get https://api.hbdm.com/api/v1/timestamp
request
null
response
{
"status": "ok",
"ts": 1578124684692
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | |
ts | true | long | current system timestamp |
Note:
- It can be used for system time calibration.
Query whether the system is available
- Interface
https://api.hbdm.com/heartbeat/
Returning Parameter
Parameter Name | Parameter Type | Desc |
---|---|---|
status | string | "ok" or "error"... |
<data> | dict object | |
heartbeat | int | future 1: avaiable 0: not available(maintenance with service suspended) |
swap_heartbeat | int | coin margined swap 1: avaiable 0: not available(maintenance with service suspended) |
estimated_recovery_time | long | null: normal. estimated recovery time :millionseconds. |
swap_estimated_recovery_time | long | null: normal. coin margined swap estimated recovery time millionseconds. |
linear_swap_heartbeat | long | USDT margined Contracts 1: avaiable 0: not available(maintenance with service suspended) |
linear_swap_estimated_recovery_time | long | null: normal. USDT margined Contracts estimated recovery time millionseconds. |
</data> |
Response:
{
"status":"ok",
"data":{
"heartbeat":1,
"estimated_recovery_time":null,
"swap_heartbeat":1,
"swap_estimated_recovery_time":null,
"linear_swap_heartbeat":1,
"linear_swap_estimated_recovery_time":null
},
"ts":1557714418033
}
- Notice: Heartbeat is 1 is available, 0 is not available.
Get system status
This endpoint allows users to get system status, Incidents and planned maintenance.
The system status can also be obtained through email, SMS, webhook, RSS/Atom feed. Users can You can click here to subscribe. The subscription function depends on Google services. Before you subscribe, please ensure that you can access Google services normally.
curl "https://status-linear-swap.huobigroup.com/api/v2/summary.json"
HTTP Request
- GET
https://status-linear-swap.huobigroup.com/api/v2/summary.json
Request Parameters
No parameter is available for this endpoint.
Response:
{
"page": { // Basic information of status page
"id": "p0qjfl24znv5", // page id
"name": "Huobi Futures-USDT-margined Swaps", // page name
"url": "https://status-linear-swap.huobigroup.com", // page url
"time_zone": "Asia/Singapore", // time zone
"updated_at": "2020-02-07T10:25:14.717Z" // page update time
},
"components": [ // System components and their status
{
"id": "h028tnzw1n5l", // component id
"name": "Deposit", // component name
"status": "operational", // component status
"created_at": "2019-12-05T02:07:12.372Z", // component create time
"updated_at": "2020-02-07T09:27:15.563Z", // component update time
"position": 1,
"description": null,
"showcase": true,
"group_id": "gtd0nyr3pf0k",
"page_id": "p0qjfl24znv5",
"group": false,
"only_show_if_degraded": false
}
],
"incidents": [ // System fault incidents and their status
{
"id": "rclfxz2g21ly", // incident id
"name": "Market data is delayed", // incident name
"status": "investigating", // incident stutus
"created_at": "2020-02-11T03:15:01.913Z", // incident create time
"updated_at": "2020-02-11T03:15:02.003Z", // incident update time
"monitoring_at": null,
"resolved_at": null,
"impact": "minor", // incident impact
"shortlink": "http://stspg.io/pkvbwp8jppf9",
"started_at": "2020-02-11T03:15:01.906Z",
"page_id": "p0qjfl24znv5",
"incident_updates": [
{
"id": "dwfsk5ttyvtb",
"status": "investigating",
"body": "Market data is delayed",
"incident_id": "rclfxz2g21ly",
"created_at": "2020-02-11T03:15:02.000Z",
"updated_at": "2020-02-11T03:15:02.000Z",
"display_at": "2020-02-11T03:15:02.000Z",
"affected_components": [
{
"code": "nctwm9tghxh6",
"name": "Market data",
"old_status": "operational",
"new_status": "degraded_performance"
}
],
"deliver_notifications": true,
"custom_tweet": null,
"tweet_id": null
}
],
"components": [
{
"id": "nctwm9tghxh6",
"name": "Market data",
"status": "degraded_performance",
"created_at": "2020-01-13T09:34:48.284Z",
"updated_at": "2020-02-11T03:15:01.951Z",
"position": 8,
"description": null,
"showcase": false,
"group_id": null,
"page_id": "p0qjfl24znv5",
"group": false,
"only_show_if_degraded": false
}
]
}
],
"scheduled_maintenances": [ // System scheduled maintenance events and their status
{
"id": "k7g299zl765l", // incident id
"name": "Schedule maintenance", // incident name
"status": "scheduled", // incident status
"created_at": "2020-02-11T03:16:31.481Z", // incident create time
"updated_at": "2020-02-11T03:16:31.530Z", // incident update time
"monitoring_at": null,
"resolved_at": null,
"impact": "maintenance", // incident impact
"shortlink": "http://stspg.io/md4t4ym7nytd",
"started_at": "2020-02-11T03:16:31.474Z",
"page_id": "p0qjfl24znv5",
"incident_updates": [
{
"id": "8whgr3rlbld8",
"status": "scheduled",
"body": "We will be undergoing scheduled maintenance during this time.",
"incident_id": "k7g299zl765l",
"created_at": "2020-02-11T03:16:31.527Z",
"updated_at": "2020-02-11T03:16:31.527Z",
"display_at": "2020-02-11T03:16:31.527Z",
"affected_components": [
{
"code": "h028tnzw1n5l",
"name": "Deposit And Withdraw - Deposit",
"old_status": "operational",
"new_status": "operational"
}
],
"deliver_notifications": true,
"custom_tweet": null,
"tweet_id": null
}
],
"components": [
{
"id": "h028tnzw1n5l",
"name": "Deposit",
"status": "operational",
"created_at": "2019-12-05T02:07:12.372Z",
"updated_at": "2020-02-10T12:34:52.970Z",
"position": 1,
"description": null,
"showcase": false,
"group_id": "gtd0nyr3pf0k",
"page_id": "p0qjfl24znv5",
"group": false,
"only_show_if_degraded": false
}
],
"scheduled_for": "2020-02-15T00:00:00.000Z", // scheduled maintenance start time
"scheduled_until": "2020-02-15T01:00:00.000Z" // scheduled maintenance end time
}
],
"status": { // The overall current status of the system
"indicator": "minor", // system indicator
"description": "Partially Degraded Service" // system description
}
}
Response Content
Field | Data Type | Description |
---|---|---|
page | basic information of status page | |
{id | string | page id |
name | string | page name |
url | string | page url |
time_zone | string | time zone |
updated_at} | string | page update time |
components | System components and their status | |
[{id | string | component id |
name | string | component name, including Order submission, Order cancellation, Deposit etc. |
status | string | component status, value range: operational, degraded_performance, partial_outage, major_outage, under maintenance |
created_at | string | component create time |
updated_at | string | component update time |
.......}] | for details of other fields, please refer to the return example | |
incidents | System fault incident and their status. If there is no fault at present, it will return to null | |
[{id | string | incident id |
name | string | incident name |
status | string | incident staus, value range: investigating, identified, monitoring, resolved |
created_at | string | incident creat time |
updated_at | string | incident update time |
.......}] | for details of other fields, please refer to the return example | |
scheduled_maintenances | System scheduled maintenance incident and status. If there is no scheduled maintenance at present, it will return to null | |
[{id | string | incident id |
name | string | incident name |
status | string | incident staus, value range: scheduled, in progress, verifying, completed |
created_at | string | incident creat time |
updated_at | string | incident update time |
scheduled_for | string | scheduled maintenance start time |
scheduled_until | string | scheduled maintenance end time |
.......}] | for details of other fields, please refer to the return example | |
status | The overall current status of the system | |
{indicator | string | system indicator, value range: none, minor, major, critical, maintenance |
description} | string | system description, value range: All Systems Operational, Minor Service Outager, Partial System Outage, Partially Degraded Service, Service Under Maintenance |
Swap Market Data interface
[General] Get Market Depth
Example
- GET
/linear-swap-ex/market/depth
curl "https://api.hbdm.com/linear-swap-ex/market/depth?contract_code=BTC-USDT&type=step5"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
Request Parameter
Parameter Name | Parameter Type | Required | Desc |
---|---|---|---|
contract_code | string | true | swap: "BTC-USDT"... , future: "BTC-USDT-220325" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
type | string | true | Get depth data within step 150, use step0, step1, step2, step3, step4, step5, step14, step15, step16, step17(merged depth data 0-5,14-17);when step is 0,depth data will not be merged; Get depth data within step 20, use step6, step7, step8, step9, step10, step11, step12, step13, step18, step19(merged depth data 7-13,18-19); when step is 6, depth data will not be merged. |
Node
- step16, step17, step18, and step19 are only for SHIB-USDT contract, and the other contracts is not supported now.
Response:
{
"ch": "market.BTC-USDT-CQ.depth.step6",
"status": "ok",
"tick": {
"asks": [
[
48611.5,
741
],
[
48635.2,
792
]
],
"bids": [
[
48596.4,
90
],
[
48585.7,
180
]
],
"ch": "market.BTC-USDT-CQ.depth.step6",
"id": 1638754215,
"mrid": 1250406,
"ts": 1638754215640,
"version": 1638754215
},
"ts": 1638754216092
}
Returning Parameter
Parameter Name | Required | Data Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | Data belonged channel,Format: market.period | |
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation,Unit:Millisecond | |
<tick> | ||||
mrid | true | long | Order ID | |
id | true | long | tick ID | |
asks | false | object | Sell,[price(Ask price), vol(Ask orders (cont.) )], price in ascending sequence | |
bids | false | object | Buy,[price(Bid price), vol(Bid orders(Cont.))], Price in descending sequence | |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
version | true | long | version ID | |
ch | true | string | Data channel, Format: market.period | |
</tick> |
[General]Get Market BBO Data
- GET
/linear-swap-ex/market/bbo
Note
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-220325" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response
{
"status": "ok",
"ticks": [
{
"business_type": "futures",
"contract_code": "BTC-USDT-CW",
"ask": [
48637.3,
746
],
"bid": [
48482.5,
385
],
"mrid": 1251224,
"ts": 1638754357868
},
{
"business_type": "futures",
"contract_code": "BTC-USDT-NW",
"ask": [
48620.1,
1000
],
"bid": [
48461,
524
],
"mrid": 1251162,
"ts": 1638754344746
},
{
"business_type": "futures",
"contract_code": "BTC-USDT-CQ",
"ask": [
48630.9,
868
],
"bid": [
48577.1,
63
],
"mrid": 1251236,
"ts": 1638754359301
},
{
"business_type": "swap",
"contract_code": "BTC-USDT",
"ask": [
48511.6,
91
],
"bid": [
48508.9,
95
],
"mrid": 334931,
"ts": 1638754361719
}
],
"ts": 1638754363648
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" , "error" |
<ticks> | true | object array | ||
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-220325" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | true | string | business type | futures, swap |
mrid | true | long | Match ID, unique identification | |
ask | false | array | [Ask 1 price, Ask 1 qty (cont)] | |
bid | false | array | [Bid 1 price, Bid 1 qty (cont)] | |
ts | true | long | The system detects the orderbook time point, unit: milliseconds | |
</ticks> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General] Get KLine Data
Example
- GET
/linear-swap-ex/market/history/kline
curl "https://api.hbdm.com/linear-swap-ex/market/history/kline?period=1min&size=200&contract_code=BTC-USDT"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
Request Parameter
Parameter Name | Required | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-220325" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ | |
period | true | string | KLine Type | 1min, 5min, 15min, 30min, 60min, 1hour,4hour,1day, 1mon | |
size | false | int | Acquisition Quantity | 150 | [1,2000] |
from | false | long | start timestamp seconds. | ||
to | false | long | end timestamp seconds |
Note
- Either
size
field orfrom
andto
fields need to be filled. - If
size
field andfrom
/to
fields are not filled, It will return error messages. - If
from
field is filled,to
field need to filled too. - The api can mostly return the klines of last two years.
- If
from
to
size
are all filled,'from' and 'to' will be ignored.
Response:
{
"ch": "market.BTC-USDT.kline.1min",
"data": [
{
"amount": 0.004,
"close": 13076.8,
"count": 1,
"high": 13076.8,
"id": 1603695060,
"low": 13076.8,
"open": 13076.8,
"trade_turnover": 52.3072,
"vol": 4
}
],
"status": "ok",
"ts": 1603695099234
}
Returning Parameter
Parameter Name | Required | Data Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | Data belonged channel,Format: market.period | |
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | kline data | |||
id | true | long | kline id,the same as kline timestamp, kline start timestamp | |
vol | true | decimal | Trade Volume(Cont.) . Sum of both buy and sell sides | |
count | true | decimal | Order Quantity. Sum of both buy and sell sides | |
open | true | decimal | Open Price | |
close | true | decimal | Clos Price, the price in the last kline is the latest order price | |
low | true | decimal | Low Price | |
high | true | decimal | High Price | |
amount | true | decimal | Trade Amount(Coin), trade amount(coin)=sum(order quantity of a single order * face value of the coin/order price). Sum of both buy and sell sides | |
trade_turnover | true | decimal | Transaction amount, that is, sum (transaction quantity * contract face value * transaction price). Sum of both buy and sell sides | |
</data> |
[General]Get Kline Data of Mark Price
- GET
/index/market/history/linear_swap_mark_price_kline
Note:
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
Request Parameter:
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
period | true | string | period | 1min, 5min, 15min, 30min, 60min,4hour,1day, 1week,1mon |
size | true | int | size | [1,2000] |
Note:
- At one time 2000 at most
- The input parameters are not case sensitive and all support
Response:
{
"ch": "market.BTC-USDT.mark_price.5min",
"data": [
{
"amount": "0",
"close": "31078.68",
"count": "0",
"high": "31078.68",
"id": 1611105300,
"low": "31078.68",
"open": "31078.68",
"trade_turnover": "0",
"vol": "0"
},
{
"amount": "0",
"close": "31078.68",
"count": "0",
"high": "31078.68",
"id": 1611105600,
"low": "31078.68",
"open": "31078.68",
"trade_turnover": "0",
"vol": "0"
}
],
"ts": 1611106791703
}
Returning Parameter:
Parameter Name | Required | Type | Description | Default Value | Value Range |
---|---|---|---|---|---|
ch | true | string | channel, format: market.period | ||
<data> | true | object array | |||
id | true | long | id | ||
vol | true | string | trade vol(cont), value is 0 | ||
count | true | string | trade count, value is 0 | ||
open | true | string | open price | ||
close | true | string | close price | ||
low | true | string | low price | ||
high | true | string | high price | ||
amount | true | string | trade amount, value is 0 | ||
trade_turnover | true | string | trade turnover, value is 0 | ||
</data> | |||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General] Get Market Data Overview
Example
- GET
/linear-swap-ex/market/detail/merged
curl "https://api.hbdm.com/linear-swap-ex/market/detail/merged?contract_code=BTC-USDT"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-220325" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
Response:
{
"ch": "market.BTC-USDT.detail.merged",
"status": "ok",
"tick": {
"amount": "12.526",
"ask": [
13084.2,
131
],
"bid": [
13082.9,
38
],
"close": "13076.8",
"count": 2920,
"high": "13205.3",
"id": 1603695162,
"low": "12877.5",
"open": "12916.2",
"trade_turnover": "163247.3982",
"ts": 1603695162580,
"vol": "12526"
},
"ts": 1603695162580
}
Returning Parameter
Parameter Name | Required | Data Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | Data belonged channel,format: market.$contract_code.detail.merged | |
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<tick> | true | object | kline data (Start at 00:00(UTC+8) of the day) | |
id | true | long | kline id,the same as kline timestamp | |
vol | true | string | Trade Volume(Cont.), from nowtime - 24 hours. Sum of both buy and sell sides | |
count | true | decimal | Order Quantity, from nowtime - 24 hours. Sum of both buy and sell sides | |
open | true | string | Opening Price | |
close | true | string | Closing Price, the price in the last kline is the latest order price | |
low | true | string | Low | |
high | true | string | High | |
amount | true | string | Trade Amount(Coin), trade amount(coin)=sum(order quantity of a single order * face value of the coin/order price),from nowtime - 24 hours. Sum of both buy and sell sides | |
ask | true | object | Sell,[price(Ask price), vol(Ask orders (cont.) )], price in ascending sequence | |
bid | true | object | Buy,[price(Bid price), vol(Bid orders(Cont.))], Price in descending sequence | |
trade_turnover | true | string | Transaction amount, that is, sum (transaction quantity * contract face value * transaction price),from nowtime - 24 hours. Sum of both buy and sell sides | |
ts | true | long | Timestamp | |
</tick> |
[General]Get a Batch of Market Data Overview
- GET
/linear-swap-ex/market/detail/batch_merged
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Note
- The interface supports cross margin mode and isolated margin mode.
- The interface data updated frequency is 50ms
- The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
- business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Response:
{
"status": "ok",
"ticks": [
{
"id": 1622102803,
"ts": 1622102804786,
"ask": [
18000,
11
],
"bid": [
1167.89012345,
12
],
"business_type": "futures",
"contract_code": "BTC-USDT-CQ",
"open": "18000",
"close": "18000",
"low": "18000",
"high": "18000",
"amount": "0.004",
"count": 2,
"vol": "4",
"trade_turnover": "38.3488642"
}
],
"ts": 1622102804786
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
<ticks> | true | object array | ||
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | true | string | business type | futures, swap |
id | true | long | id | |
amount | true | string | Trade Amount(Coin) ,from nowtime - 24 hours. Sum of both buy and sell sides | |
ask | true | array | [ask one price, ask one vol(cont)] | |
bid | true | array | [bid one price, bid one vol(cont)] | |
open | true | string | open price | |
close | true | string | close price | |
count | true | decimal | Order Quantity, from nowtime - 24 hours. Sum of both buy and sell sides | |
high | true | string | high price | |
low | true | string | low price | |
vol | true | string | Trade Volume(Cont.), from nowtime - 24 hours. Sum of both buy and sell sides | |
trade_turnover | true | string | Transaction amount, from nowtime - 24 hours. Sum of both buy and sell sides | |
ts | true | long | timestamp | |
</ticks> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General]Get a Batch of Market Data Overview(V2)
- GET
/v2/linear-swap-ex/market/detail/batch_merged
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Note
- The interface supports cross margin mode and isolated margin mode.
- The interface data updated frequency is 50ms
- The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
- business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Response:
{
"status": "ok",
"ticks": [
{
"id": 1650792083,
"ts": 1650792083179,
"ask": [
39736.6,
1285
],
"bid": [
39736.5,
6070
],
"business_type": "swap",
"contract_code": "BTC-USDT",
"open": "39760",
"close": "39736.6",
"low": "39316.3",
"high": "39971.2",
"amount": "6891.566",
"count": 48262,
"vol": "273472535.834",
"number_of": "6891566"
}
],
"ts": 1650792083179
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
<ticks> | true | object array | ||
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | true | string | business type | futures, swap |
id | true | long | id | |
amount | true | string | Trade Amount(Coin) ,from nowtime - 24 hours. Sum of both buy and sell sides | |
ask | true | array | [ask one price, ask one vol(cont)] | |
bid | true | array | [bid one price, bid one vol(cont)] | |
open | true | string | open price | |
close | true | string | close price | |
count | true | decimal | Order Quantity, from nowtime - 24 hours. Sum of both buy and sell sides | |
high | true | string | high price | |
low | true | string | low price | |
vol | true | string | Transaction amount, from nowtime - 24 hours. Sum of both buy and sell sides | |
number_of | true | string | number of(cont), from nowtime - 24 hours. Sum of both buy and sell sides | |
ts | true | long | timestamp | |
</ticks> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General] Query The Last Trade of a Contract
Example
- GET
/linear-swap-ex/market/trade
curl "https://api.hbdm.com/linear-swap-ex/market/trade?contract_code=BTC-USDT"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
contract_code | false | string | contract code or contract type, swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | false(more see remarks) | string | business type, default is swap: futures, swap, all |
Response:
{
"ch": "market.*.trade.detail",
"status": "ok",
"tick": {
"data": [
{
"amount": "6",
"ts": 1603695230083,
"id": 1314755250000,
"price": "13083",
"direction": "buy",
"quantity": 0.006,
"contract_code": "BTC-USDT",
"business_type":"swap",
"trade_turnover": 78.498
}
],
"id": 1603695235127,
"ts": 1603695235127
},
"ts": 1603695235127
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | Data belonged channel,Format: market.$contract_code.trade.detail | |
status | true | string | "ok","error" | |
ts | true | long | Sending time | |
<tick> | ||||
id | true | long | Unique Order Id(symbol level). | |
ts | true | long | Latest Creation Time | |
<data> | ||||
id | true | long | Unique Transaction Id(symbol level) | |
price | true | string | Price | |
amount | true | string | Quantity(Cont.). Sum of both buy and sell sides | |
direction | true | string | The direction to buy or sell is the direction of the taker (active transaction) | |
ts | true | long | Order Creation Time | |
quantity | true | string | trading quantity(coin) | |
contract_code | true | string | Contract Code or Contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
business_type | true | string | business type | futures, swap |
trade_turnover | true | string | trade turnover(quoted currency) | |
</data> | ||||
</tick> |
[General] Query a Batch of Trade Records of a Contract
Example
- GET
/linear-swap-ex/market/history/trade
curl "https://api.hbdm.com/linear-swap-ex/market/history/trade?contract_code=BTC-USDT&size=100"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
Request Parameter
Parameter Name | Required | Data Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ |
size | true | int | Number of Trading Records Acquisition | [1, 2000] |
Response:
Response:
{
"ch": "market.BTC-USDT.trade.detail",
"data": [
{
"data": [
{
"amount": 2,
"direction": "buy",
"id": 1314767870000,
"price": 13081.3,
"ts": 1603695383124,
"quantity": 0.002,
"trade_turnover": 26.1626
}
],
"id": 131476787,
"ts": 1603695383124
}
],
"status": "ok",
"ts": 1603695388965
}
Returning Parameter
Parameter Name | Required | Data Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | Data belonged channel,Format: market.$contract_code.trade.detail | |
<data> | true | object array | ||
<data> | true | object array | ||
amount | true | decimal | Quantity(Cont.). Sum of both buy and sell sides | |
direction | true | string | The direction to buy or sell is the direction of the taker (active transaction) | |
id | true | long | Unique Transaction Id(symbol level) | |
price | true | decimal | Price | |
ts | true | long | Order Creation Time | |
quantity | true | decimal | trading quantity(coin) | |
trade_turnover | true | decimal | trade turnover(quoted currency) | |
</data> | ||||
id | true | long | Unique Order Id(symbol level). | |
ts | true | long | Latest transaction time | |
</data> | ||||
status | true | string | "ok","error" | |
ts | true | long | Time of Respond Generation, Unit: Millisecond |
Notice
- There are "quantity" parameter in return data only after 21:00:00 on February 3, 2021
[General] Query information on open interest
- GET
/linear-swap-api/v1/swap_his_open_interest
curl "https://api.hbdm.com/linear-swap-api/v1/swap_his_open_interest?contract_code=BTC-USDT&period=60min&amount_type=1"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
one of (pair+contract_type) and contract_code must be filled in(if all of them not filled in, will get 1014 error code); and all filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Desc | Data Range |
---|---|---|---|---|
contract_code | false(more see remarks) | string | contract_code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false(more see remarks) | string | pair | BTC-USDT |
contract_type | false(more see remarks) | string | contract type | swap, this_week, next_week, quarter, next_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",
"tick": [
{
"volume": 27112.0000000000000000,
"amount_type": 1,
"ts": 1638720000000,
"value": 1321498.52640000000000000000000000000000000
}
],
"contract_code": "BTC-USDT-211210",
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "this_week"
},
"ts": 1638755582116
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | Dictionary Data | |||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | e.g. swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
<tick> | ||||
volume | true | decimal | Open Interest. | |
amount_type | true | int | Open Interest Unit | 1:-cont,2:- cryptocurrency |
value | true | decimal | Total position volume (the unit shall be the denominated currency of the contract, eg, USDT) | |
ts | true | long | Recording Time | |
</tick> | ||||
</data> |
Notice
- tick field:Tick data is arranged in reverse chronological order;
[Cross] Query Information On Transfer State
- GET
/linear-swap-api/v1/swap_cross_transfer_state
Remarks
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
margin_account | false | string | margin account, return all margin when null | "USDT",only support USDT now |
Response
{
"status": "ok",
"data": [
{
"margin_mode": "cross",
"margin_account": "USDT",
"transfer_in": 1,
"transfer_out": 1,
"master_transfer_sub": 1,
"sub_transfer_master": 1,
"master_transfer_sub_inner_in": 1,
"master_transfer_sub_inner_out": 1,
"sub_transfer_master_inner_in": 1,
"sub_transfer_master_inner_out": 1,
"transfer_inner_in": 1,
"transfer_inner_out": 1
}
],
"ts": 1606905619516
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
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" | |
master_transfer_sub | true | int | transfer from master to sub account:"1" is available,“0” is unavailable | |
sub_transfer_master | true | int | transfer from sub to master account:"1" is available,“0” is unavailable | |
master_transfer_sub_inner_in | true | int | Transfer_in access for transfer from main account to sub-account - crossing account: "1" represents "available", "0" represents "unavailable" | |
master_transfer_sub_inner_out | true | int | Transfer_out access for transfer from main account to sub-account - crossing account: "1" represents "available", "0" represents "unavailable" | |
sub_transfer_master_inner_in | true | int | Transfer_in access for transfer from sub-account to main account - crossing account: "1" represents "available", "0" represents "unavailable" | |
sub_transfer_master_inner_out | true | int | Transfer_out access for transfer from sub-account to main account - crossing account: "1" represents "available", "0" represents "unavailable" | |
transfer_inner_in | true | int | Transfer_in access for transfer between different margin accounts under the same account:"1" represents "available", "0" represents "unavailable" | |
transfer_inner_out | true | int | Transfer_out access for transfer between different margin accounts under the same account:"1" represents "available", "0" represents "unavailable" | |
</data> |
[Cross] Query Information On Trade State
- GET
/linear-swap-api/v1/swap_cross_trade_state
Remarks
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625. When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_mode": "cross",
"margin_account": "USDT",
"open": 1,
"close": 1,
"cancel": 1,
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "this_week"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"margin_mode": "cross",
"margin_account": "USDT",
"open": 1,
"close": 1,
"cancel": 1,
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "next_week"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"margin_mode": "cross",
"margin_account": "USDT",
"open": 1,
"close": 1,
"cancel": 1,
"business_type": "futures",
"pair": "BTC-USDT",
"contract_type": "quarter"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"open": 1,
"close": 1,
"cancel": 1,
"business_type": "swap",
"pair": "BTC-USDT",
"contract_type": "swap"
}
],
"ts": 1638756343093
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
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" | |
</data> |
[General] Query Premium Index Kline Data
example
- GET
/index/market/history/linear_swap_premium_index_kline
curl "https://api.hbdm.com/index/market/history/linear_swap_premium_index_kline?contract_code=BTC-USDT&period=1min&size=1"
Remarks
- The interface supports cross margin mode and isolated margin mode.
request parameters
Parameter name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT","ETH-USDT". |
period | true | string | kline period | 1min,5min, 15min, 30min, 60min,4hour,1day,1week,1mon |
size | true | int | kline size | [1,2000] |
Response Example:
{
"ch": "market.BTC-USDT.premium_index.1min",
"data": [
{
"amount": "0",
"close": "0.0000079166666666",
"count": "0",
"high": "0.0000079166666666",
"id": 1603696920,
"low": "0.0000079166666666",
"open": "0.0000079166666666",
"trade_turnover": "0",
"vol": "0"
}
],
"status": "ok",
"ts": 1603696958348
}
response parameters:
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | data channel | eg: market.period |
<data> | object | |||
id | true | long | index kline id,the same as kline timestamp, kline start timestamp | |
vol | true | string | Trade Volume(Cont.) The value is 0 | |
count | true | string | Order Quantity The value is 0 | |
open | true | string | Opening Price | |
close | true | string | Closing Price, the price in the last kline is the latest order price | |
low | true | string | Lowest Price | |
high | true | string | Highest Price | |
amount | true | string | Trade Amount(Coin), The value is 0. ) | |
trade_turnover | true | string | Transaction amount, the value is 0. | |
</data> | ||||
status | true | string | process status | "ok" , "error" |
ts | true | long | timestamp of the response of the server, unit:millionseconds |
[General] Query Estimated Funding Rate Kline Data
example
- GET
/index/market/history/linear_swap_estimated_rate_kline
curl "https://api.hbdm.com/index/market/history/linear_swap_estimated_rate_kline?contract_code=BTC-USDT&period=1min&size=1"
Remarks
- The interface supports cross margin mode and isolated margin mode.
request parameters
Parameter name | Required | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT","ETH-USDT". | |
period | true | string | kline period | 1min,5min, 15min, 30min, 60min,4hour,1day,1week,1mon | |
size | true | int | kline size | [1,2000] |
Response Example:
{
"ch": "market.BTC-USDT.estimated_rate.1min",
"data": [
{
"amount": "0",
"close": "0.0001",
"count": "0",
"high": "0.0001",
"id": 1603697100,
"low": "0.0001",
"open": "0.0001",
"trade_turnover": "0",
"vol": "0"
}
],
"status": "ok",
"ts": 1603697104902
}
response parameters:
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | data channel | eg: market.period |
<data> | object | |||
id | true | long | kline ID | |
vol | true | string | Trade Volume(Cont.) The value is 0 | |
count | true | string | Order Quantity The value is 0 | |
open | true | string | Opening Price | |
close | true | string | Closing Price, the price in the last kline is the latest order price | |
low | true | string | Lowest Price | |
high | true | string | Highest Price | |
amount | true | string | Trade Amount(Coin), The value is 0. ) | |
trade_turnover | true | string | Transaction amount, the value is 0. | |
</data> | ||||
status | true | string | process status | "ok" , "error" |
ts | true | long | timestamp of the response of the server | unit:millionseconds |
[General] Query Basis Data
example
- GET
/index/market/history/linear_swap_basis
curl "https://api.hbdm.com/index/market/history/linear_swap_basis?contract_code=BTC-USDT&period=1min&size=150&basis_price_type=open"
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
request parameters
Parameter name | Required | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code or contract type | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ | |
period | true | string | kline period | 1min,5min, 15min, 30min, 60min,4hour,1day,1mon | |
basis_price_type | false | string | use basis price type to calculate the basis data | Using open price default | open price:"open",close price:"close",highest price:"high",lowest price:"low",avg=(high price +low price)/2:"average" |
size | true | int | data size | 150 | [1,2000] |
Response example:
{
"ch": "market.BTC-USDT.basis.1min.open",
"data": [
{
"basis": "15.29074235666667",
"basis_rate": "0.001170582317307796",
"contract_price": "13077.8",
"id": 1603697160,
"index_price": "13062.509257643333"
}
],
"status": "ok",
"ts": 1603697170804
}
response parameters
parameter name | Required | Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | data channel,eg: market.basis | |
<data> | object array | |||
id | true | long | unique id | |
contract_price | true | string | contract last price | |
index_price | true | string | index price | |
basis | true | string | basis=contract_price - index_price | |
basis_rate | true | string | basis_rate=basis/index_price | |
</data> | ||||
status | true | string | status | "ok" , "error" |
ts | true | long | created time |
Swap Account Interface
[General]Query Asset Valuation
- POST
/linear-swap-api/v1/swap_balance_valuation
Note
- The interface supports cross margin mode and isolated margin mode
Request Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
valuation_asset | false | string | The valuation according to the certain fiat currency. If not fill in, default as BTC | "BTC", "USD", "USDT", "CNY", "EUR", "GBP", "VND", "HKD", "TWD", "MYR", "SGD", "KRW", "RUB", "TRY" |
Response:
{
"status": "ok",
"data": [
{
"valuation_asset": "BTC",
"balance": "0.378256726579799383"
}
],
"ts": 1614045417046
}
Returning Parameter
Parameter Name | Required | Parameter Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handles for the request | |
<data> | true | object array | ||
valuation_asset | true | string | The valuation according to the certain fiat currency | "BTC", "USD", "USDT", "CNY", "EUR", "GBP", "VND", "HKD", "TWD", "MYR", "SGD", "KRW", "RUB", "TRY" |
balance | true | string | Asset Valuation | |
</data> | ||||
ts | true | long | timestamp |
[Isolated] Query User’s Account Information
Example
- POST /linear-swap-api/v1/swap_account_info
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
contract_code | false | string | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"margin_balance": 99.755058840000000000,
"margin_position": 0,
"margin_frozen": 12.730000000000000000,
"margin_available": 87.025058840000000000,
"profit_real": 0,
"profit_unreal": 0,
"risk_rate": 7.761218290652003142,
"withdraw_available": 87.025058840000000000000000000000000000,
"liquidation_price": null,
"lever_rate": 10,
"adjust_factor": 0.075000000000000000,
"margin_static": 99.755058840000000000,
"contract_code": "BTC-USDT",
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"ts": 1603697381238
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
symbol | true | string | Variety code | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_asset | true | string | Margin Asset | |
margin_balance | true | decimal | Account rights | |
margin_position | true | decimal | Position Margin | |
margin_frozen | true | decimal | Frozen 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 | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
position_mode | true | string | position mode | single_side,dual_side |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross] Query User's Account Information
- POST
/linear-swap-api/v1/swap_cross_account_info
Remarks
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
margin_account | false | string | margin account,return all margin account info when null | "USDT"...,but now only USDT |
Response
{
"status": "ok",
"data": [
{
"futures_contract_detail": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 10000.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "next_week",
"pair": "BTC-USDT",
"business_type": "futures"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 10000.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 10000.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "quarter",
"pair": "BTC-USDT",
"business_type": "futures"
}
],
"margin_mode": "cross",
"margin_account": "USDT",
"margin_asset": "USDT",
"margin_balance": 10000.000000000000000000,
"margin_static": 10000.000000000000000000,
"margin_position": 0,
"margin_frozen": 0,
"profit_real": 0E-18,
"profit_unreal": 0,
"withdraw_available": 1E+4,
"risk_rate": null,
"position_mode": "dual_side",
"contract_detail": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 10000.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "swap",
"pair": "BTC-USDT",
"business_type": "swap"
}
]
}
],
"ts": 1638757139907
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | long | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
margin_asset | true | string | margin asset | |
margin_balance | true | decimal | account equity | |
margin_static | true | decimal | static margin | |
margin_position | true | decimal | position margin (summary of all contract) | |
margin_frozen | true | decimal | frozen margin (summary of all contract) | |
profit_real | true | decimal | realized profits and losses (summary of all contract) | |
profit_unreal | true | decimal | unrealized profits and losses (summary of all contract) | |
withdraw_available | true | decimal | available transfer amount | |
risk_rate | true | decimal | margin rate | |
position_mode | true | string | position mode | single_side,dual_side |
<contract_detail> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... |
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_unreal | true | decimal | unrealized profits and losses | |
liquidation_price | true | decimal | estimated liquidation price | |
lever_rate | true | decimal | lever rate | |
adjust_factor | true | decimal | adjustment factor | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</contract_detail> | ||||
<futures_contract_detail> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | future: "BTC-USDT-210625" ... |
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_unreal | true | decimal | unrealized profits and losses | |
liquidation_price | true | decimal | estimated liquidation price | |
lever_rate | true | decimal | lever rate | |
adjust_factor | true | decimal | adjustment factor | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</futures_contract_detail> | ||||
</data> |
[Isolated] Query User’s Position Information
Example
- POST
/linear-swap-api/v1/swap_position_info
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
contract_code | false | string | Case-Insenstive.Both uppercase and lowercase are supported..e.g. "BTC-USDT" |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0,
"cost_open": 13068.000000000000000000,
"cost_hold": 13068.000000000000000000,
"profit_unreal": 0,
"profit_rate": 0,
"lever_rate": 10,
"position_margin": 1.306800000000000000,
"direction": "buy",
"profit": 0,
"last_price": 13068,
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"ts": 1603697821846
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
symbol | true | string | Variety code | "BTC","ETH"... |
contract_code | true | string | contract code | e.g. "BTC-USDT" |
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 | |
margin_asset | true | string | Margin Asset | |
position_margin | true | decimal | Position margin | |
lever_rate | true | int | Leverage rate | |
direction | true | string | transaction direction of positions | "buy":long "sell":short |
last_price | true | decimal | Latest price | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
position_mode | true | string | position mode | single_side,dual_side |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
Note
- If there are symbols in the settlement or delivery period,error code 1080(1080 In settlement or delivery. Unable to get positions of some contracts.) will return without request parameters. It's suggested to query the position info with request parameters to avoid raising the error code and not being able to query the position.
[Cross] Query User's Position Information
- POST
/linear-swap-api/v1/swap_cross_position_info
Remarks
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-211225.
When both of pair、contract_type and contract_code filled in, the contract_code is the preferred. when no one filled in, return all contract type's data(swap and futures)
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-211225" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0E-18,
"cost_open": 48945.900000000000000000,
"cost_hold": 48945.900000000000000000,
"profit_unreal": -0.003800000000000000,
"profit_rate": -0.000388183688521410,
"lever_rate": 5,
"position_margin": 9.788420000000000000,
"direction": "buy",
"profit": -0.003800000000000000,
"last_price": 48942.1,
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"contract_type": "swap",
"pair": "BTC-USDT",
"business_type": "swap",
"position_mode": "dual_side"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0E-18,
"cost_open": 48929.700000000000000000,
"cost_hold": 48929.700000000000000000,
"profit_unreal": -0.049800000000000000,
"profit_rate": -0.005088933715105550,
"lever_rate": 5,
"position_margin": 9.775980000000000000,
"direction": "buy",
"profit": -0.049800000000000000,
"last_price": 48879.9,
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"position_mode": "dual_side"
}
],
"ts": 1638758525147
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
volume | true | decimal | position quantity | |
available | true | decimal | available position can be closed | |
frozen | true | decimal | frozen quantity | |
cost_open | true | decimal | opening average price | |
cost_hold | true | decimal | average price of position | |
profit_unreal | true | decimal | unrealized profits and losses | |
profit_rate | true | decimal | profit rate | |
profit | true | decimal | profit | |
margin_asset | true | string | margin asset | |
position_margin | true | decimal | position margin | |
lever_rate | true | int | lever rate | |
direction | true | string | transaction direction of positions | "buy":long "sell":short |
last_price | true | decimal | latest price | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
position_mode | true | string | position mode | single_side,dual_side |
</data> |
[Isolated] Query Assets And Positions
- post
/linear-swap-api/v1/swap_account_position_info
Remarks
- This interface only supports isolated margin mode.
params
field | Required | type | desc | range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported. "BTC-USDT","ETH-USDT".... |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_balance": 99.751731640000000000,
"margin_position": 1.306990000000000000,
"margin_frozen": 12.730000000000000000,
"margin_available": 85.714741640000000000,
"profit_real": -0.005227200000000000,
"profit_unreal": 0.001900000000000000,
"risk_rate": 7.031347702748238760,
"withdraw_available": 85.712841640000000000000000000000000000,
"liquidation_price": null,
"lever_rate": 10,
"adjust_factor": 0.075000000000000000,
"margin_static": 99.749831640000000000,
"positions": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0,
"cost_open": 13068.000000000000000000,
"cost_hold": 13068.000000000000000000,
"profit_unreal": 0.001900000000000000,
"profit_rate": 0.001453933272115090,
"lever_rate": 10,
"position_margin": 1.306990000000000000,
"direction": "buy",
"profit": 0.001900000000000000,
"last_price": 13069.9,
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"ts": 1603697944138
}
response
attr | type | Required | desc | Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | contract symbol | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_asset | true | string | Margin Asset | |
margin_balance | true | decimal | Balance Margin | |
margin_static | true | decimal | Balance static | |
margin_position | true | decimal | Postion Margin | |
margin_frozen | true | decimal | Frozen Margin | |
margin_available | true | decimal | Available Margin | |
profit_real | true | decimal | Realized Profit | |
profit_unreal | true | decimal | Unreadlized Profit | |
risk_rate | true | decimal | risk rate | |
liquidation_price | true | decimal | Estimated Liquidation Price | |
withdraw_available | true | decimal | Available Withdraw | |
lever_rate | true | decimal | Leverage Rate | |
adjust_factor | true | decimal | Adjustment Factor | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
position_mode | true | string | position mode | single_side,dual_side |
<positions> | true | object array | ||
symbol | true | string | Variety Code | "BTC","ETH"... |
contract_code | true | string | Contract Code | "BTC-USDT" ... |
volume | true | decimal | Position Quantity | |
available | true | decimal | Available position quatity can be closed | |
frozen | true | decimal | forzen postion Quantity | |
cost_open | true | decimal | Opening Average Price | |
cost_hold | true | decimal | Average position price | |
profit_unreal | true | decimal | Unrealized profit | |
profit_rate | true | decimal | Profit Rate | |
profit | true | decimal | Profit | |
margin_asset | true | string | Margin Asset | |
position_margin | true | decimal | Position Margin | |
lever_rate | true | int | Leverage Rate | |
direction | true | string | transaction direction of positions | "buy":long "sell":short |
last_price | true | decimal | Last Price | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
position_mode | true | string | position mode | single_side,dual_side |
</positions> | ||||
</data> |
[Cross] Query Assets And Positions
- POST
/linear-swap-api/v1/swap_cross_account_position_info
Remarks
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
margin_account | true | string | margin account | "USDT"...,but now only USDT |
Response
{
"status": "ok",
"data": {
"positions": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0E-18,
"cost_open": 48945.900000000000000000,
"cost_hold": 48945.900000000000000000,
"profit_unreal": 0.034200000000000000,
"profit_rate": 0.003493653196692670,
"lever_rate": 5,
"position_margin": 9.796020000000000000,
"direction": "buy",
"profit": 0.034200000000000000,
"last_price": 48980.1,
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"contract_type": "swap",
"pair": "BTC-USDT",
"business_type": "swap",
"position_mode": "dual_side"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0E-18,
"cost_open": 48929.700000000000000000,
"cost_hold": 48929.700000000000000000,
"profit_unreal": 0.036900000000000000,
"profit_rate": 0.003770715945530015,
"lever_rate": 5,
"position_margin": 9.793320000000000000,
"direction": "buy",
"profit": 0.036900000000000000,
"last_price": 48966.6,
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"position_mode": "dual_side"
}
],
"futures_contract_detail": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 9716.437716790000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "next_week",
"pair": "BTC-USDT",
"business_type": "futures"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_position": 9.793320000000000000,
"margin_frozen": 0E-18,
"margin_available": 9716.437716790000000000,
"profit_unreal": 0.036900000000000000,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"margin_position": 0,
"margin_frozen": 264.000000000000000000,
"margin_available": 9716.437716790000000000000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 1,
"adjust_factor": 0.005000000000000000,
"contract_type": "quarter",
"pair": "BTC-USDT",
"business_type": "futures"
}
],
"margin_mode": "cross",
"margin_account": "USDT",
"margin_asset": "USDT",
"margin_balance": 10000.027056790000000000,
"margin_static": 9999.955956790000000000,
"margin_position": 19.589340000000000000,
"margin_frozen": 264.000000000000000000,
"profit_real": -0.044043210000000000,
"profit_unreal": 0.071100000000000000,
"withdraw_available": 9716.36661679,
"risk_rate": 4752.827989089613978802,
"position_mode": "dual_side",
"contract_detail": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_position": 9.796020000000000000,
"margin_frozen": 0E-18,
"margin_available": 9716.437716790000000000,
"profit_unreal": 0.034200000000000000,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "swap",
"pair": "BTC-USDT",
"business_type": "swap"
}
]
},
"ts": 1638758699818
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | long | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
margin_asset | true | string | margin asset | |
margin_balance | true | decimal | account equity | |
margin_static | true | decimal | static margin | |
margin_position | true | decimal | position margin (summary of all contract) | |
margin_frozen | true | decimal | frozen margin (summary of all contract) | |
profit_real | true | decimal | realized profits and losses | |
profit_unreal | true | decimal | unrealized profits and losses (summary of all contract) | |
withdraw_available | true | decimal | available transfer amount | |
risk_rate | true | decimal | margin rate | |
position_mode | true | string | position mode | single_side,dual_side |
<contract_detail> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... |
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_unreal | true | decimal | unrealized profits and losses | |
liquidation_price | true | decimal | estimated liquidation price | |
lever_rate | true | decimal | lever rate | |
adjust_factor | true | decimal | adjustment factor | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</contract_detail> | ||||
<futures_contract_detail> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | future: "BTC-USDT-210625" ... |
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_unreal | true | decimal | unrealized profits and losses | |
liquidation_price | true | decimal | estimated liquidation price | |
lever_rate | true | decimal | lever rate | |
adjust_factor | true | decimal | adjustment factor | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</futures_contract_detail> | ||||
<positions> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
volume | true | decimal | position quantity | |
available | true | decimal | available position can be closed | |
frozen | true | decimal | frozen quantity | |
cost_open | true | decimal | opening average price | |
cost_hold | true | decimal | average price of position | |
profit_unreal | true | decimal | unrealized profits and losses | |
profit_rate | true | decimal | profit rate | |
profit | true | decimal | profit | |
margin_asset | true | string | margin asset | |
position_margin | true | decimal | position margin | |
lever_rate | true | int | lever rate | |
direction | true | string | transaction direction of positions | "buy":long "sell":short |
last_price | true | decimal | latest price | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
position_mode | true | string | position mode | single_side,dual_side |
</positions> | ||||
</data> |
[General]Set a Batch of Sub-Account Trading Permissions
- POST
/linear-swap-api/v1/swap_sub_auth
Note:
The interface supports cross margin mode and isolated margin mode.
If the sub-account trading permission has been enable, the interface will directly return success when request to enable again; if the sub-account trading permission has been disable, the interface will directly return success when request to disable again;
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
sub_uid | true | string | sub-account uid (multiple uids are separated by ",", and one time 10 sub uid at most) | |
sub_auth | true | int | sub auth, 1:enable, 0:disable |
Note:
- When enable the transaction authority on the sub-account for the first time, deemed to agree to access the contract market.
Response:
{
"status": "ok",
"data": {
"errors": [
{
"sub_uid": "1234567",
"err_code": 1010,
"err_msg": "Account doesnt exist."
}
],
"successes": "123456789"
},
"ts": 1612504316476
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | "ok" , "error" |
<data> | true | |||
<errors> | true | object array | ||
sub_uid | true | string | the list of sub uid which failed | |
err_code | true | int | error code | |
err_msg | true | string | error msg | |
</errors> | ||||
successes | true | string | the list of sub uid which successes | |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit:Millisecond |
[Isolated] Query assets information of all sub-accounts under the master account
- POST
/linear-swap-api/v1/swap_sub_account_list
Remarks
- This interface only supports isolated margin mode.
Request Parameters
Parameter name | Must fill or not | Type | Description | Value range |
---|---|---|---|---|
contract_code | false | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
Response:
{
"status": "ok",
"data": [
{
"sub_uid": 123456789,
"list": [
{
"symbol": "BTC",
"margin_balance": 20,
"liquidation_price": null,
"risk_rate": null,
"contract_code": "BTC-USDT",
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT"
}
]
}
],
"ts": 1603698380336
}
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"... |
contract_code | true | string | contract code | e.g. "BTC-USDT" |
margin_asset | true | string | margin asset | |
margin_balance | true | decimal | account equity | |
liquidation_price | true | decimal | estimated liquidation price | |
risk_rate | true | decimal | margin rate | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
</list> | ||||
</data> |
Notice
- Only return data for activated contract sub-account (i.e. sub-accounts that have gained contract trading permission).
[Cross] Query Assets Information Of All Sub-Accounts Under The Master Account
- POST
/linear-swap-api/v1/swap_cross_sub_account_list
Remarks
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
margin_account | false | string | margin account,return all margin account info when null | "USDT"...,but now only USDT |
Response
{
"status": "ok",
"data": [
{
"sub_uid": 123456789,
"list": [
{
"margin_balance": 163.561708129559110889,
"risk_rate": 78.896729392251481019,
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT"
}
]
}
],
"ts": 1606962745633
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
sub_uid | true | long | sub-account UID | |
<list> | true | object array | ||
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
margin_asset | true | string | margin asset | |
margin_balance | true | decimal | account equity | |
risk_rate | true | decimal | margin rate | |
</list> | ||||
</data> |
Notice
- Only return data for activated contract sub-account (i.e. sub-accounts that have gained contract trading permission).
[Isolated]Query a Batch of Sub-Account's Assets Information
- POST
/linear-swap-api/v1/swap_sub_account_info_list
Note
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code | "BTC-USDT"... ,if not filled, return all |
page_index | false | int | page index, if not filled in as 1st | |
page_size | false | int | if not filled in as 20,50 at most |
Note:
- Only return data of sub-accounts that have agreed to access the contract market.
- By default, the list of sub-accounts is in ascending order according to the time when agree to access the contract market, and the earlier the agreed time, the first the position
Response:
{
"status": "ok",
"data": {
"total_page": 1,
"current_page": 1,
"total_size": 1,
"sub_list": [
{
"sub_uid": 123456789,
"account_info_list": [
{
"symbol": "BTC",
"margin_balance": 0,
"liquidation_price": null,
"risk_rate": null,
"contract_code": "BTC-USDT",
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT"
}
]
}
]
},
"ts": 1612504756853
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | "ok" , "error" |
ts | true | long | Time of Respond Generation,Unit:Millisecond | |
<data> | true | object | ||
<sub_list> | true | object array | ||
sub_uid | true | long | sub uid | |
<account_info_list> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_account | true | string | margin account | such as:BTC-USDT” |
margin_mode | true | string | margin mode | isolated: isolated |
margin_asset | true | string | margin asset) | |
margin_balance | true | decimal | margin balance | |
liquidation_price | true | decimal | liquidation price | |
risk_rate | true | decimal | risk rate | |
</account_info_list> | ||||
</sub_list> | ||||
current_page | true | int | current page | |
total_page | true | int | total page | |
total_size | true | int | total size | |
</data> |
[Cross]Query a Batch of Sub-Account's Assets Information
- POST
/linear-swap-api/v1/swap_cross_sub_account_info_list
Note
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
margin_account | false | string | margin account,if not filled in return all margin account | "USDT",but now just has one account usdt |
page_index | false | int | page index, if not filled in as 1st | |
page_size | false | int | if not filled in as 20,50 at most |
Note:
- Only return data of sub-accounts that have agreed to access the contract market.
- By default, the list of sub-accounts is in ascending order according to the time when agree to access the contract market, and and the earlier the agreed time, the first the position
Response:
{
"status": "ok",
"data": {
"total_page": 1,
"current_page": 1,
"total_size": 1,
"sub_list": [
{
"sub_uid": 12345678,
"account_info_list": [
{
"margin_balance": 2,
"risk_rate": null,
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT"
}
]
}
]
},
"ts": 1612504845679
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | "ok" , "error" |
ts | true | long | Time of Respond Generation,Unit:Millisecond | |
<data> | true | object | ||
<sub_list> | true | object array | ||
sub_uid | true | long | sub uid | |
<account_info_list> | true | object array | ||
margin_mode | true | string | margin mode | cross; |
margin_account | true | string | margin account | such as:USDT” |
margin_asset | true | string | margin asset | |
margin_balance | true | decimal | margin balance | |
risk_rate | true | decimal | risk rate | |
</account_info_list> | ||||
</sub_list> | ||||
current_page | true | int | current page | |
total_page | true | int | total page | |
total_size | true | int | total size | |
</data> |
[Isolated] Query a single sub-account's assets information
- POST
/linear-swap-api/v1/swap_sub_account_info
Remarks
- This interface only supports isolated margin mode.
Request Parameters
Parameter name | Must fill or not | Type | Description |
---|---|---|---|
contract_code | false | string | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
sub_uid | true | long | sub-account UID |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"margin_balance": 20,
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 20.000000000000000000,
"profit_real": 0,
"profit_unreal": 0,
"risk_rate": null,
"withdraw_available": 20.000000000000000000,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"margin_static": 20,
"contract_code": "BTC-USDT",
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"ts": 1603698523200
}
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 | e.g. "BTC-USDT" |
margin_asset | true | string | margin asset | |
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 | int | leverage ratios | |
adjust_factor | true | decimal | Adjustment Factor | |
margin_static | true | decimal | Static Margin | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
position_mode | true | string | position mode | single_side,dual_side |
</data> |
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.
[Cross] Query A Sub-Account's Assets Information
- POST
/linear-swap-api/v1/swap_cross_sub_account_info
Remarks
- The interface only supports cross margin mode.
Request Parameter*
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
sub_uid | true | long | sub-account UID | |
margin_account | false | string | margin account,return all margin account info when null | "USDT"...,but now only USDT |
Response:
{
"status": "ok",
"data": [
{
"futures_contract_detail": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 500.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "next_week",
"pair": "BTC-USDT",
"business_type": "futures"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 500.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 500.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "quarter",
"pair": "BTC-USDT",
"business_type": "futures"
}
],
"margin_mode": "cross",
"margin_account": "USDT",
"margin_asset": "USDT",
"margin_balance": 500,
"margin_static": 500,
"margin_position": 0,
"margin_frozen": 0,
"profit_real": 0,
"profit_unreal": 0,
"withdraw_available": 5E+2,
"risk_rate": null,
"position_mode": "dual_side",
"contract_detail": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_position": 0,
"margin_frozen": 0,
"margin_available": 500.000000000000000000,
"profit_unreal": 0E-18,
"liquidation_price": null,
"lever_rate": 5,
"adjust_factor": 0.040000000000000000,
"contract_type": "swap",
"pair": "BTC-USDT",
"business_type": "swap"
}
]
}
],
"ts": 1638759191747
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | long | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
margin_asset | true | string | margin asset | |
margin_balance | true | decimal | account equity | |
margin_static | true | decimal | static margin | |
margin_position | true | decimal | position margin (the margin used by current positions) | |
margin_frozen | true | decimal | frozen margin | |
profit_real | true | decimal | realized profits and losses | |
profit_unreal | true | decimal | unrealized profits and losses | |
withdraw_available | true | decimal | available transfer amount | |
risk_rate | true | decimal | margin rate | |
position_mode | true | string | position mode | single_side,dual_side |
<contract_detail> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap:"BTC-USDT" ... |
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_unreal | true | decimal | unrealized profits and losses | |
liquidation_price | true | decimal | estimated liquidation price | |
lever_rate | true | decimal | lever rate | |
adjust_factor | true | decimal | adjustment factor | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</contract_detail> | ||||
<futures_contract_detail> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | future:"BTC-USDT-211231" ... |
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_unreal | true | decimal | unrealized profits and losses | |
liquidation_price | true | decimal | estimated liquidation price | |
lever_rate | true | decimal | lever rate | |
adjust_factor | true | decimal | adjustment factor | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</futures_contract_detail> | ||||
</data> |
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.
[Isolated] Query a single sub-account's position information
- POST
/linear-swap-api/v1/swap_sub_position_info
Remarks
- This interface only supports isolated margin mode.
Request Parameters
Parameter name | Must fill or not | Type | Description |
---|---|---|---|
contract_code | false | string | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
sub_uid | true | long | sub-account UID |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0,
"cost_open": 13038.700000000000000000,
"cost_hold": 13038.700000000000000000,
"profit_unreal": 0,
"profit_rate": 0,
"lever_rate": 10,
"position_margin": 1.303870000000000000,
"direction": "buy",
"profit": 0,
"last_price": 13038.7,
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"ts": 1603699081114
}
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 | "BTC-USDT" ... |
margin_asset | true | string | margin asset | |
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 |
last_price | true | decimal | Latest price | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
position_mode | true | string | position mode | single_side,dual_side |
</data> |
[Cross] Query A Sub-Account's Position Information
- POST
/linear-swap-api/v1/swap_cross_sub_position_info
Remarks
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-211225.
When both of pair、contract_type and contract_code filled in, the contract_code is the preferred. when no one filled in, return all contract type's data(swap and futures)
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
sub_uid | true | long | sub-account UID | |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"volume": 1.000000000000000000,
"available": 1.000000000000000000,
"frozen": 0E-18,
"cost_open": 48886.700000000000000000,
"cost_hold": 48886.700000000000000000,
"profit_unreal": -0.065300000000000000,
"profit_rate": -0.001335741622977210,
"lever_rate": 1,
"position_margin": 48.952000000000000000,
"direction": "sell",
"profit": -0.065300000000000000,
"last_price": 48952,
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"contract_type": "quarter",
"pair": "BTC-USDT",
"business_type": "futures",
"position_mode": "dual_side"
}
],
"ts": 1638759509329
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
volume | true | decimal | position quantity | |
available | true | decimal | available position can be closed | |
frozen | true | decimal | frozen quantity | |
cost_open | true | decimal | opening average price | |
cost_hold | true | decimal | average price of position | |
profit_unreal | true | decimal | unrealized profits and losses | |
profit_rate | true | decimal | profit rate | |
profit | true | decimal | profit | |
margin_asset | true | string | margin asset | |
position_margin | true | decimal | position margin | |
lever_rate | true | int | lever rate | |
direction | true | string | transaction direction of positions | "buy":long "sell":short |
last_price | true | decimal | latest price | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
position_mode | true | string | position mode | single_side,dual_side |
</data> |
[General] Query account financial records(New)
- POST
/linear-swap-api/v3/swap_financial_record
Note
- The interface supports cross margin mode and isolated margin mode.
- The request parameter "contract" supports the contract code of futures, in that the format is BTC-USDT-210625.
Request:
{
"contract": "BTC-USDT",
"mar_acct": "BTC-USDT",
"type": "3,4,5,6,7",
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
Request Parameter
Parameter Name | Required | Type | Desc | Default | Value Range | OriginalParameter |
---|---|---|---|---|---|---|
contract | false | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" | contract_code | |
mar_acct | true | string | margin account | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... | margin_account | |
type | false | string | if not fill this parameter, it will query all types [please use "," to seperate multiple types] | 3:close long; 4:close short; 5:fees for open positions-taker; 6:fees for open positions-maker; 7:fees for close positions-taker; 8:fees for close positions-maker; 9:close long for delivery; 10:close short for delivery; 11:delivery fee; 12:close long for liquidation; 13:lose short for liquidation; 14:transfer from spot exchange to contract exchange; 15:tranfer from contract exchange to spot exchange; 16:settle unrealized PnL-long positions; 17:settle unrealized PnL-short positions; 19:clawback; 26:system; 28:activity prize rewards; 29:rebate; 30:Funding fee-income; 31:Funding fee-expenditure; 34:transfer to sub; 35:transfer from sub; 36:transfer to master; 37:transfer from master; 38:transfer from other margin account; 39:transfer to another margin account; | ||
start_time | false | long | Query start time, query by data creation time | Value range [((end-time) – 48h), (end-time)] , maximum query window size is 48 hours, query window shift should be within past 90 days. |
||
end_time | false | long | Query end time, query data by creation time | now | Value range [(present-90d), present] , maximum query window size is 48 hours, query window shift should be within past 90 days. |
|
direct | false | string | Search direct, If the direction is NEXT, the data is returned in positive chronological order; if the direction is PREV, the data is returned in reverse chronological order | next | next, prev default is prev | |
from_id | false | long | If the query direction is prev, from_id should be the min query_id in the last query result. If the query direction is next, from_id should be the max query_id in the last query result | Search query_id to begin with |
Response:
{
"code": 200,
"msg": "",
"data": [
{
"query_id": 138798248,
"id": 117840,
"type": 5,
"amount": -0.024464850000000000,
"ts": 1638758435635,
"contract_code": "BTC-USDT-211210",
"asset": "USDT",
"margin_account": "USDT",
"face_margin_account": ""
}
],
"ts": 1604312615051
}
Response Content
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
code | true | int | State code | |
msg | true | string | The code description | |
ts | true | long | Timestamp | |
<data> | true | object array | ||
query_id | true | long | ||
id | true | long | ||
ts | true | long | create time | |
asset | true | string | asset | "USDT"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_account | true | string | margin account | "BTC-USDT","USDT"... |
face_margin_account | true | string | the counterparty margin account, only has value when the transaction Type is 34, 35, 36, 37, 38, 39, and the other types are empty strings | "BTC-USDT"... |
type | true | int | transaction Type | 3:close long; 4:close short; 5:fees for open positions-taker; 6:fees for open positions-maker; 7:fees for close positions-taker; 8:fees for close positions-maker; 9:close long for delivery; 10:close short for delivery; 11:delivery fee; 12:close long for liquidation; 13:lose short for liquidation; 14:transfer from spot exchange to contract exchange; 15:tranfer from contract exchange to spot exchange; 16:settle unrealized PnL-long positions; 17:settle unrealized PnL-short positions; 19:clawback; 26:system; 28:activity prize rewards; 29:rebate; 30:Funding fee-income; 31:Funding fee-expenditure; 34:transfer to sub; 35:transfer from sub; 36:transfer to master; 37:transfer from master; 38:transfer from other margin account; 39:transfer to another margin account; |
amount | true | decimal | amount(quote currency) | |
</data> |
[General]Query account financial records via Multiple Fields(New)
- POST
/linear-swap-api/v3/swap_financial_record_exact
Note
- The interface supports cross margin mode and isolated margin mode.
- The request parameter "contract" supports the contract code of futures, in that the format is BTC-USDT-210625.
Request:
{
"contract": "BTC-USDT",
"mar_acct": "BTC-USDT",
"type": "3,4,5,6,7",
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
Request Parameter
Parameter Name | Required | Type | Desc | Default | Value Range | OriginalParameter |
---|---|---|---|---|---|---|
contract | false | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" | contract_code | |
mar_acct | true | string | margin account | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... | margin_account | |
type | false | string | if not fill this parameter, it will query all types [please use "," to seperate multiple types] | 3:close long; 4:close short; 5:fees for open positions-taker; 6:fees for open positions-maker; 7:fees for close positions-taker; 8:fees for close positions-maker; 9:close long for delivery; 10:close short for delivery; 11:delivery fee; 12:close long for liquidation; 13:lose short for liquidation; 14:transfer from spot exchange to contract exchange; 15:tranfer from contract exchange to spot exchange; 16:settle unrealized PnL-long positions; 17:settle unrealized PnL-short positions; 19:clawback; 26:system; 28:activity prize rewards; 29:rebate; 30:Funding fee-income; 31:Funding fee-expenditure; 34:transfer to sub; 35:transfer from sub; 36:transfer to master; 37:transfer from master; 38:transfer from other margin account; 39:transfer to another margin account; | ||
start_time | false | long | Query start time, query by data creation time | Value range [((end-time) – 48h), (end-time)] , maximum query window size is 48 hours, query window shift should be within past 90 days. |
||
end_time | false | long | Query end time, query data by creation time | now | Value range [(present-90d), present] , maximum query window size is 48 hours, query window shift should be within past 90 days. |
|
direct | false | string | Search direct, If the direction is NEXT, the data is returned in positive chronological order; if the direction is PREV, the data is returned in reverse chronological order | next | next, prev default is prev | |
from_id | false | long | If the query direction is prev, from_id should be the min query_id in the last query result. If the query direction is next, from_id should be the max query_id in the last query result | Search query_id to begin with |
Response:
{
"code": 200,
"msg": "",
"data": [
{
"query_id": 138798248,
"id": 117840,
"type": 5,
"amount": -0.024464850000000000,
"ts": 1638758435635,
"contract_code": "BTC-USDT-211210",
"asset": "USDT",
"margin_account": "USDT",
"face_margin_account": ""
}
],
"ts": 1604312615051
}
Response Content
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
code | true | int | State code | |
msg | true | string | The code description | |
ts | true | long | Timestamp | |
<data> | true | object array | ||
query_id | true | long | ||
id | true | long | ||
ts | true | long | create time | |
asset | true | string | asset | "USDT"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_account | true | string | margin account | "BTC-USDT","USDT"... |
face_margin_account | true | string | the counterparty margin account, only has value when the transaction Type is 34, 35, 36, 37, 38, 39, and the other types are empty strings | "BTC-USDT"... |
type | true | int | transaction Type | 3:close long; 4:close short; 5:fees for open positions-taker; 6:fees for open positions-maker; 7:fees for close positions-taker; 8:fees for close positions-maker; 9:close long for delivery; 10:close short for delivery; 11:delivery fee; 12:close long for liquidation; 13:lose short for liquidation; 14:transfer from spot exchange to contract exchange; 15:tranfer from contract exchange to spot exchange; 16:settle unrealized PnL-long positions; 17:settle unrealized PnL-short positions; 19:clawback; 26:system; 28:activity prize rewards; 29:rebate; 30:Funding fee-income; 31:Funding fee-expenditure; 34:transfer to sub; 35:transfer from sub; 36:transfer to master; 37:transfer from master; 38:transfer from other margin account; 39:transfer to another margin account; |
amount | true | decimal | amount(quote currency) | |
</data> |
[Isolated]Query Settlement Records of Users
- POST
linear-swap-api/v1/swap_user_settlement_records
Note:
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract_code | "BTC-USDT"... |
start_time | false | long | start time(timestamp, Unit: Millisecond) | Value Range:[(now - 90 days), now] , now - 90 days |
end_time | false | long | end time(timestamp, Unit: Millisecond) | Value Range:(start_time, now], now |
page_index | false | int | page index | if not filled in is 1st |
page_size | false | int | page size | if not filled in is 20, and 50 at most(if more than 50, treated as 50 |
Note:
- The data of response is descending sorted, the latest the first.
- The settlement records is between "from" and "to"
- This interface only supports users to query data for the last 90 days.
Response:
{
"status":"ok",
"data":{
"total_page":1,
"current_page":1,
"total_size":13,
"settlement_records":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"margin_mode":"isolated",
"margin_account":"BTC-USDT",
"margin_balance_init":5000,
"margin_balance":4891.74704672,
"settlement_profit_real":-108.25295328,
"settlement_time":1611040802012,
"clawback":0,
"funding_fee":0,
"offset_profitloss":0,
"fee":-2.63615328,
"fee_asset":"USDT",
"positions":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"direction":"buy",
"volume":12,
"cost_open":27900,
"cost_hold_pre":27900,
"cost_hold":27459.93,
"settlement_profit_unreal":-52.8084,
"settlement_price":27459.93,
"settlement_type":"settlement"
},
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"direction":"sell",
"volume":12,
"cost_open":27019.86,
"cost_hold_pre":27019.86,
"cost_hold":27459.93,
"settlement_profit_unreal":-52.8084,
"settlement_price":27459.93,
"settlement_type":"settlement"
}
]
}
]
},
"ts":1611052289681
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | |
<data> | true | object | ||
<settlement_records> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_mode | true | string | margin mode | cross/isolated |
margin_account | true | string | margin account | such as: “BTC-USDT” |
margin_balance_init | true | decimal | margin balance init | |
margin_balance | true | decimal | margin balance | |
settlement_profit_real | true | decimal | settlement profit real | |
settlement_time | true | long | settlement time/delivery time | |
clawback | true | decimal | clawback | |
funding_fee | true | decimal | current funding fee(or current delivery fee) | |
offset_profitloss | true | decimal | offset profit or loss | |
fee | true | decimal | fee | |
fee_asset | true | string | fee asset | |
<positions> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
direction | true | string | direction | "buy"/"sell" |
volume | true | decimal | volume before settlement(cont) | |
cost_open | true | decimal | cost open | |
cost_hold_pre | true | decimal | cost hold before settlement | |
cost_hold | true | decimal | cost hold after settlement | |
settlement_profit_unreal | true | decimal | settlement profit unreal | |
settlement_price | true | decimal | settlement price/delivery time | |
settlement_type | true | string | settlement type | settlement/delivery |
</positions> | ||||
</settlement_records> | ||||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
</data> | ||||
ts | true | long | timestamp |
[Cross]Query Settlement Records of Users
- POST
linear-swap-api/v1/swap_cross_user_settlement_records
Note:
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
margin_account | true | string | margin account | "USDT", now only support USDT |
start_time | false | long | start time(timestamp, Unit: Millisecond) | Value Range:[(now - 90 days), now] , now - 90 days |
end_time | false | long | end time(timestamp, Unit: Millisecond) | Value Range:(start_time, now], now |
page_index | false | int | page index | if not filled in is 1st |
page_size | false | int | page size | if not filled is 10, 25 at most(if more than 25, treated as 50) |
Note:
- The data of response is descending sorted, the latest the first.
- The settlement records is between "from" and "to"
- This interface only supports users to query data for the last 90 days.
Response:
{
"status":"ok",
"data":{
"total_page":2,
"current_page":1,
"total_size":13,
"settlement_records":[
{
"margin_mode":"cross",
"margin_account":"USDT",
"margin_balance_init":5000,
"margin_balance":5007.6708,
"settlement_profit_real":7.6708,
"settlement_time":1611051602040,
"clawback":0,
"funding_fee":0,
"offset_profitloss":0,
"fee":0.6708,
"fee_asset":"USDT",
"contract_detail":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"offset_profitloss":0,
"fee":0.6708,
"fee_asset":"USDT",
"positions":[
{
"symbol":"BTC-USDT",
"contract_code":"BTC-USDT",
"direction":"buy",
"volume":9,
"cost_open":27911.111111111111111111,
"cost_hold_pre":27911.111111111111111111,
"cost_hold":34361.25,
"settlement_profit_unreal":580.5125,
"settlement_price":34361.25,
"settlement_type":"settlement"
},
{
"symbol":"BTC-USDT",
"contract_code":"BTC-USDT",
"direction":"sell",
"volume":9,
"cost_open":27988.888888888888888888,
"cost_hold_pre":27988.888888888888888888,
"cost_hold":34361.25,
"settlement_profit_unreal":-573.5125,
"settlement_price":34361.25,
"settlement_type":"settlement"
}
]
}
]
},
{
"margin_mode":"cross",
"margin_account":"USDT",
"margin_balance_init":5000,
"margin_balance":5000,
"settlement_profit_real":0,
"settlement_time":1611047654316,
"clawback":0,
"funding_fee":0,
"offset_profitloss":0,
"fee":0,
"fee_asset":"USDT",
"contract_detail":[
]
}
]
},
"ts":1611051729365
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | |
<data> | true | object | ||
<settlement_records> | true | object array | ||
margin_mode | true | string | margin mode | cross/isolated |
margin_account | true | string | margin account | such as “USDT” |
margin_balance_init | true | decimal | margin balance init | |
margin_balance | true | decimal | margin balance after current settlement | |
settlement_profit_real | true | decimal | settlement profit real | |
settlement_time | true | long | settlement time/delivery time | |
clawback | true | decimal | clawback | |
funding_fee | true | decimal | total funding fee(delivery fee included) | |
offset_profitloss | true | decimal | offset profit or loss | |
fee | true | decimal | fee | |
fee_asset | true | string | fee asset | |
<contract_detail> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
offset_profitloss | true | decimal | offset profit or loss current settlement | |
fee | true | decimal | fee current settlement | |
fee_asset | true | string | fee asset | |
pair | true | string | pair | such as: “BTC-USDT” |
<positions> | true | object array | positions(just place when has positions) | |
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
direction | true | string | direction | "buy"/"sell" |
volume | true | decimal | volume before settlement(cont) | |
cost_open | true | decimal | cost open | |
cost_hold_pre | true | decimal | cost hold before settlement | |
cost_hold | true | decimal | cost hold after current settlement | |
settlement_profit_unreal | true | decimal | settlement profit unreal | |
settlement_price | true | decimal | settlement price/delivery price | |
settlement_type | true | string | settlement type | settlement/delivery |
pair | true | string | pair | such as: “BTC-USDT” |
</positions> | ||||
</contract_detail> | true | |||
</settlement_records> | ||||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
</data> | ||||
ts | true | long | timestamp |
[Isolated] Query user’s available leverage
- POST
/linear-swap-api/v1/swap_available_level_rate
Remarks
- This interface only supports isolated margin mode.
Request Parameter:
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | Contract code, if not filled in, the actual available leverage of all contracts will be returned by default | “BTC-USDT”... |
Response:
{
"status": "ok",
"data": [
{
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"available_level_rate": "1,2,3,5,10,20,30,50,75,100,125"
}
],
"ts": 1603699467348
}
Returning Parameter:
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object array | ||
contract_code | true | string | contract code | "BTC-USDT" |
margin_mode | true | string | margin mode | isolated : "isolated" |
available_level_rate | true | string | available level rate,splited by ',' | "1,5,10" |
</data> | ||||
ts | true | long | Response generation time point, unit: millisecond |
[Cross] Query User’s Available Leverage
- POST
/linear-swap-api/v1/swap_cross_available_level_rate
Remarks
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false | string | contract code,return all contract info when null | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response
{
"status": "ok",
"data": [
{
"contract_code": "ETH-USDT",
"available_level_rate": "1,2,3,5",
"margin_mode": "cross",
"contract_type": "swap",
"pair": "ETH-USDT",
"business_type": "swap"
},
{
"contract_code": "ETH-USDT-211210",
"available_level_rate": "1,2,3,5",
"margin_mode": "cross",
"contract_type": "this_week",
"pair": "ETH-USDT",
"business_type": "futures"
},
{
"contract_code": "ETH-USDT-211217",
"available_level_rate": "1,2,3,5",
"margin_mode": "cross",
"contract_type": "next_week",
"pair": "ETH-USDT",
"business_type": "futures"
},
{
"contract_code": "ETH-USDT-211231",
"available_level_rate": "1,2,3,5",
"margin_mode": "cross",
"contract_type": "quarter",
"pair": "ETH-USDT",
"business_type": "futures"
}
],
"ts": 1638760001689
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object array | ||
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross: cross margin mode |
available_level_rate | true | string | available level rate,splited by ',' | "1,5,10" |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General] Query swap information on order limit
- POST
/linear-swap-api/v1/swap_order_limit
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | false |
string |
contract type code |
Case-Insenstive.Both uppercase and lowercase are supported.e.g. swap:"BTC-USDT"... , future:"BTC-USDT-210625"... |
order_price_type | true | string | Order Type | "limit": Limit Order,"opponent":BBO,"lightning": Lightning 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, "opponent_ioc":IOC order using the BBO price,"lightning_ioc":lightning IOC,"optimal_5_ioc":optimal_5 IOC,"optimal_10_ioc":optimal_10 IOC,"optimal_20_ioc":optimal_20 IOC, "opponent_fok":FOK order using the BBO price,"lightning_fok":lightning FOK,"optimal_5_fok":optimal_5 FOK,"optimal_10_fok":optimal_10 FOK,"optimal_20_fok":optimal_20 FOK |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response:
{
"status": "ok",
"data": {
"order_price_type": "limit",
"list": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"open_limit": 170000.000000000000000000,
"close_limit": 170000.000000000000000000,
"business_type": "swap",
"contract_type": "swap",
"pair": "BTC-USDT"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"open_limit": 170000.000000000000000000,
"close_limit": 170000.000000000000000000,
"business_type": "futures",
"contract_type": "next_week",
"pair": "BTC-USDT"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"open_limit": 170000.000000000000000000,
"close_limit": 170000.000000000000000000,
"business_type": "futures",
"contract_type": "this_week",
"pair": "BTC-USDT"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"open_limit": 170000.000000000000000000,
"close_limit": 170000.000000000000000000,
"business_type": "futures",
"contract_type": "quarter",
"pair": "BTC-USDT"
}
]
},
"ts": 1638760136200
}
Returning Parameter
Parameter Name | Required | 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": Lightning 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, "opponent_ioc":IOC order using the BBO price,"lightning_ioc":lightning IOC,"optimal_5_ioc":optimal_5 IOC,"optimal_10_ioc":optimal_10 IOC,"optimal_20_ioc":optimal_20 IOC, "opponent_fok":FOK order using the BBO price,"lightning_fok":lightning FOK,"optimal_5_fok":optimal_5 FOK,"optimal_10_fok":optimal_10 FOK,"optimal_20_fok":optimal_20 FOK |
<list> | ||||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract type code | swap:"BTC-USDT"... , future:"BTC-USDT-210625"... |
open_limit | true | decimal | Max open order limit | |
close_limit | true | decimal | Max close order limit | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</list> | ||||
</data> |
[General] Query information on swap trading fee
- POST
/linear-swap-api/v1/swap_fee
Remarks
The interface supports cross margin mode and isolated margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract type code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"open_maker_fee": "0.0002",
"open_taker_fee": "0.0004",
"close_maker_fee": "0.0002",
"close_taker_fee": "0.0004",
"fee_asset": "USDT",
"delivery_fee": "0",
"business_type": "swap",
"contract_type": "swap",
"pair": "BTC-USDT"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"open_maker_fee": "0.0002",
"open_taker_fee": "0.0005",
"close_maker_fee": "0.0002",
"close_taker_fee": "0.0005",
"fee_asset": "USDT",
"delivery_fee": "0.00015",
"business_type": "futures",
"contract_type": "next_week",
"pair": "BTC-USDT"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"open_maker_fee": "0.0002",
"open_taker_fee": "0.0005",
"close_maker_fee": "0.0002",
"close_taker_fee": "0.0005",
"fee_asset": "USDT",
"delivery_fee": "0.00015",
"business_type": "futures",
"contract_type": "this_week",
"pair": "BTC-USDT"
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"open_maker_fee": "0.0002",
"open_taker_fee": "0.0005",
"close_maker_fee": "0.0002",
"close_taker_fee": "0.0005",
"fee_asset": "USDT",
"delivery_fee": "0.00015",
"business_type": "futures",
"contract_type": "quarter",
"pair": "BTC-USDT"
}
],
"ts": 1638760715804
}
Returning Parameter
Parameter Name | Required | 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 | Variety code | |
contract_code | true | string | contract type code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
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 | |
fee_asset | true | string | the corresponding cryptocurrency to the given fee | "USDT"... |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
delivery_fee | true | string | delivery fee rate | |
</data> |
[Isolated] Query information on Transfer Limit
- POST
/linear-swap-api/v1/swap_transfer_limit
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract type code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"transfer_in_max_each": 100000000.000000000000000000,
"transfer_in_min_each": 1.0000000000E-8,
"transfer_out_max_each": 10000000.000000000000000000,
"transfer_out_min_each": 1.0000000000E-8,
"transfer_in_max_daily": 1000000000.000000000000000000,
"transfer_out_max_daily": 200000000.000000000000000000,
"net_transfer_in_max_daily": 500000000.000000000000000000,
"net_transfer_out_max_daily": 100000000.000000000000000000,
"margin_account": "BTC-USDT",
"margin_mode": "isolated"
}
],
"ts": 1640852376293
}
Returning Parameter
Parameter Name | Required | 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 | symbol | "BTC","ETH"... |
contract_code | true | string | contract type code | "BTC-USDT",... |
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 | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | e.g: "BTC-USDT" ... |
</data> |
[Cross] Query Information On Transfer Limit
- POST
/linear-swap-api/v1/swap_cross_transfer_limit
Remarks
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
margin_account | false | string | margin account, return all margin account info when null | "USDT"...,but now only USDT |
Response:
{
"status": "ok",
"data": [
{
"transfer_in_max_each": 999999999999999999,
"transfer_in_min_each": 0.0001,
"transfer_out_max_each": 999999999999999999,
"transfer_out_min_each": 0.0001,
"transfer_in_max_daily": 900000000999999999,
"transfer_out_max_daily": 900000099999999999,
"net_transfer_in_max_daily": 900000000099999999,
"net_transfer_out_max_daily": 123456789012345678.12345678,
"margin_account": "USDT",
"margin_mode": "cross"
}
],
"ts": 1606964432217
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
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> |
[Isolated] Query information on position limit
- POST
/linear-swap-api/v1/swap_position_limit
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract type code | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"buy_limit": 1026154,
"sell_limit": 1026154,
"margin_mode": "isolated",
"lever_rate": 5,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000,
"mark_price": 48725.6
}
],
"ts": 1638770954672
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Responding Generation, Unit: Millisecond | |
<data> | ||||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract type code | "BTC-USDT",... |
margin_mode | true | string | margin mode | isolated : "isolated" |
buy_limit | true | decimal | max qty of position on long positions, unit: piece(calculated with mark_price) | |
sell_limit | true | decimal | max qty of position on short positions, unit: piece(calculated with mark_price) | |
lever_rate | true | int | leverage rate | |
buy_limit_value | true | decimal | upper limit on long positions, unit: usdt | |
sell_limit_value | true | decimal | upper limit on short positions, unit: usdt | |
mark_price | true | decimal | mark price(use this price to calculate the qty of open positions) | |
</data> |
[Cross] Query Information On Position Limit
- POST
/linear-swap-api/v1/swap_cross_position_limit
Remarks
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
When both of pair, contract_type and contract_code filled in, the contract_code is the preferred.
business_type is a required parameter when query info of futures contract, and its value must be futures or all.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
contract_type | false | string | contract type | swap, this_week, next_week, quarter, next_quarter |
business_type | false(more see remarks) | string | business type, default is swap | futures, swap, all |
Response
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "cross",
"buy_limit": 1021671,
"sell_limit": 1021671,
"business_type": "swap",
"contract_type": "swap",
"pair": "BTC-USDT",
"lever_rate": 5,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000,
"mark_price": 48939.4
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"margin_mode": "cross",
"buy_limit": 1021865,
"sell_limit": 1021865,
"business_type": "futures",
"contract_type": "next_week",
"pair": "BTC-USDT",
"lever_rate": 5,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000,
"mark_price": 48930.1
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_mode": "cross",
"buy_limit": 1023478,
"sell_limit": 1023478,
"business_type": "futures",
"contract_type": "this_week",
"pair": "BTC-USDT",
"lever_rate": 5,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000,
"mark_price": 48853
},
{
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"margin_mode": "cross",
"buy_limit": 1021867,
"sell_limit": 1021867,
"business_type": "futures",
"contract_type": "quarter",
"pair": "BTC-USDT",
"lever_rate": 1,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000,
"mark_price": 48930
}
],
"ts": 1638760890261
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross: cross margin mode |
buy_limit | true | decimal | max qty of position on long positions, unit: piece(calculated with mark_price) | |
sell_limit | true | decimal | max qty of position on short positions, unit: piece(calculated with mark_price) | |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
lever_rate | true | int | leverage rate | |
buy_limit_value | true | decimal | upper limit on long positions, unit: usdt | |
sell_limit_value | true | decimal | upper limit on short positions, unit: usdt | |
mark_price | true | decimal | mark price(use this price to calculate the qty of open positions) | |
</data> |
[Isolated]Query Users' Position Limit for All Leverages
- POST
/linear-swap-api/v1/swap_lever_position_limit
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code, NA means all | such as "BTC-USDT", "ETH-USDT" |
lever_rate | false | int | leverage rate, NA means all |
Note
- This interface only supports isolated margin mode.
- If the status of contract is Pending Listing, Listing, Suspension, or Suspending of Listing, the data of that contract will not be returned when querying all; If that contract is queried separately, error 1014 will be reported;
- lever_rate must fall within the user's available leverage rate, otherwise error 1037 will be reported
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"list": [
{
"lever_rate": 2,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000
}
]
}
],
"ts": 1638769536897
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | status code | "ok" , "error" |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_mode | true | string | margin mode | isolated |
<list> | true | object array | ||
lever_rate | true | int | leverage rate | |
buy_limit_value | true | decimal | upper limit on long positions, unit: usdt | |
sell_limit_value | true | decimal | upper limit on short positions, unit: usdt | |
</list> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit:Millisecond |
[Cross]Query Users' Position Limit for All Leverages
- POST
/linear-swap-api/v1/swap_cross_lever_position_limit
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
business_type | false(more to see Note) | string | business type, NA means all | futures, swap, all |
contract_type | false | string | contract type, NA means all | swap, this_week, next_week, quarter, next_quarter |
pair | false | string | pair, NA means all | such as "BTC-USDT" |
contract_code | false | string | contract_code, NA means all | swap: "BTC-USDT"... future: "BTC-USDT-211231"... |
lever_rate | false | int | leverage rate, NA means all |
Note
- The interface only supports cross margin mode.
- If the status of contract is Pending Listing, Listing, Suspension, or Suspending of Listing, the data of that contract will not be returned when querying all; If that contract is queried separately, error 1014 will be reported;
- pair, contract_type and contract_code all filled in,contract_code is preferred
- lever_rate must fall within the user's available leverage rate, otherwise error 1037 will be reported
- business_type is a required parameter when querying the contract of futures. And the parameter value must be: futures or all.
Response:
{
"status": "ok",
"data": [
{
"business_type": "swap",
"contract_type": "swap",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "cross",
"list": [
{
"lever_rate": 2,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000
}
]
},
{
"business_type": "futures",
"contract_type": "next_week",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211217",
"margin_mode": "cross",
"list": [
{
"lever_rate": 2,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000
}
]
},
{
"business_type": "futures",
"contract_type": "this_week",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_mode": "cross",
"list": [
{
"lever_rate": 2,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000
}
]
},
{
"business_type": "futures",
"contract_type": "quarter",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"margin_mode": "cross",
"list": [
{
"lever_rate": 2,
"buy_limit_value": 50000000.000000000000000000,
"sell_limit_value": 50000000.000000000000000000
}
]
}
],
"ts": 1638769370732
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
<data> | true | object array | ||
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | swap: "BTC-USDT"... futures: "BTC-USDT-211231"... |
margin_mode | true | string | margin mode | cross |
business_type | true | string | business type | futures, swap |
contract_type | true | string | contract type | swap, this_week, next_week, quarter, next_quarter |
pair | true | string | pair | such as: "BTC-USDT" |
<list> | true | object array | ||
lever_rate | true | int | leverage rate | |
buy_limit_value | true | decimal | upper limit on long positions, unit: usdt | |
sell_limit_value | true | decimal | upper limit on short positions, unit: usdt | |
</list> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit:Millisecond |
[General] Transfer between master and sub account
- post
/linear-swap-api/v1/swap_master_sub_transfer
Remarks
- The interface supports cross margin mode and isolated margin mode.
Request Parameters
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
sub_uid | true | long | uid of sub account | |
asset | true | string | asset | "USDT"... |
from_margin_account | true | string | from margin account | "BTC-USDT","USDT"... |
to_margin_account | true | string | to margin account | "BTC-USDT","USDT"... |
amount | true | decimal | transfer amount | |
type | true | string | transfer type | "master_to_sub" or "sub_to_master" |
client_order_id | false | long | Clients fill and maintain themselves. | [1, 9223372036854775807] |
Note:
- When from_margin_account or to_margin_account is USDT, it means the transfer in or transfer out from cross margin account
- represents transfer from transfer_out margin account to transfer_in margin account. The currency transferred shall be the same as the denominated currency of the transfer_out margin account.;
- The denominated currency of the transfer_out margin account and transfer_in margin account must be the same. (eg, USDT can be transferred from BTC-USDT to ETH-USDT, but cannot be transferred from BTC-USDT to ETH-HUSD account).
- the rate limit between the master account and each subaccount is 10 times/ minute
- The client_order_id is valid in 8 hours only, that is the user cannot use the same client_order_id beyonds one times for the same transfer path (for example, transfer currency from master account to sub-account using client_order_id=1, and you can't do that transfe currency from master account to sub-account using client_order_id=1 in the next time; but you can transfer currency from sub-account to master account using client_order_id=1).
Response:
{
"status": "ok",
"data": {
"order_id": "770320047276195840"
},
"ts": 1603700211160
}
response
attr | required | type | desc | |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
ts | true | long | response timestamp,millionseconds | |
<data> | true | object | ||
order_id | true | string | order id | |
client_order_id | false | long | the client ID that is filled in when the order is placed, if it’s not filled, it won’t be returned | |
</data> |
[General] Query transfer records between master and sub account
- post
/linear-swap-api/v1/swap_master_sub_transfer_record
Remarks
- The interface supports cross margin mode and isolated margin mode.
request
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
margin_account | true | string | margin account | "BTC-USDT","USDT"... |
transfer_type | false | string | All by default(multiple types need to be joined with ',') | 34:transfer to sub account 35:transfer from sub account |
create_date | true | int | days | days need to be less than or equal to 90 |
page_index | false | int | 1 by default | |
page_size | false | int | 20 by default.less than or equal to 50. | [1-50] |
Response:
{
"status": "ok",
"data": {
"total_page": 2,
"current_page": 1,
"total_size": 2,
"transfer_record": [
{
"id": 57920,
"transfer_type": 34,
"amount": -10.000000000000000000,
"ts": 1603700211125,
"sub_uid": "12343678",
"sub_account_name": "tom",
"margin_account": "BTC-USDT",
"asset": "USDT",
"to_margin_account": "BTC-USDT",
"from_margin_account": "BTC-USDT"
}
]
},
"ts": 1603700414957
}
response
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | respone status | "ok" , "error" |
ts | true | long | response millionseconds. | |
<data> | true | object | ||
<transfer_record> | true | object array | ||
id | true | long | transfer id | |
ts | true | long | create timestamp | |
asset | true | string | asset | "USDT"... |
margin_account | true | string | margin account | "BTC-USDT"... |
from_margin_account | true | string | from margin account | "BTC-USDT"... |
to_margin_account | true | string | to margin account | "BTC-USDT"... |
sub_uid | true | string | subaccount uid | |
sub_account_name | true | string | subaccount name | |
transfer_type | true | int | transfer type | 35:transfer from subaccount; 34:transfer to subaccount; |
amount | true | decimal | amount | |
</transfer_record> | ||||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
</data> |
[General] Transfer between different margin accounts under the same account
- post
/linear-swap-api/v1/swap_transfer_inner
Remarks
- The interface supports cross margin mode and isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
asset | true | string | asset | "USDT"... |
from_margin_account | true | string | from margin account | "BTC-USDT","USDT"... |
to_margin_account | true | string | to margin account | "ETH-USDT","USDT"... |
amount | true | decimal | amount(The unit is the denominated currency of the contract.) | |
client_order_id | false | long | Clients fill and maintain themselves. | [1, 9223372036854775807] |
Note:
- When from_margin_account or to_margin_account is USDT, it means the transfer in or transfer out from cross margin account
- represents transfer from transfer_out margin account to transfer_in margin account. The currency transferred shall be the same as the denominated currency of the transfer_out margin account.;
- The denominated currency of the transfer_out margin account and transfer_in margin account must be the same. (eg, USDT can be transferred from BTC-USDT to ETH-USDT, but cannot be transferred from BTC-USDT to ETH-HUSD account)。
- API rate limit for this interface is up to 10 times per minute.
- The client_order_id is valid in 8 hours only, that is the user cannot use the same client_order_id beyonds one times
response:
{
"status": "ok",
"data": {
"order_id": "770321554893758464"
},
"ts": 1603700570600
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | response status | "ok" , "error" |
<data> | object array | |||
order_id | true | string | order id | |
client_order_id | false | long | the client ID that is filled in when the order is placed, if it’s not filled, it won’t be returned | |
</data> | ||||
ts | true | long | response millionseconds. |
[General] Query user's API indicator disable information
- get
/linear-swap-api/v1/swap_api_trading_status
Remarks
- The interface supports cross margin mode and isolated margin mode.
request body
null
Response:
attr | required | type | desc | Value Range |
---|---|---|---|---|
status | true | string | response status | "ok" , "error" |
ts | true | long | response millionseconds | |
<data> | true | array object | ||
is_disable | true | int | 1:is disabled,0:isn't disabled | |
order_price_types | true | string | order price types,such as:“limit,post_only,FOK,IOC” | |
disable_reason | true | string | disable reason | "COR":(Cancel Order Ratio),“TDN”:(Total Disable Number) |
disable_interval | true | long | disable millionseconds | |
recovery_time | true | long | recovery millionseconds | |
<COR> | true | dict object | (Cancel Order Ratio) | |
orders_threshold | true | long | orders threshold | |
orders | true | long | total pending orders | |
invalid_cancel_orders | true | long | numbers of invalid cancel orders | |
cancel_ratio_threshold | true | decimal | cancel ratio threshold | |
cancel_ratio | true | decimal | cancel ratio | |
is_trigger | true | int | 1: triggered,0: not triggered | |
is_active | true | int | 1: active,0:not active | |
</COR> | true | dict object | ||
<TDN> | true | dict object | Total Disable Number | |
disables_threshold | true | long | disable threshold | |
disables | true | long | total disable number | |
is_trigger | true | int | 1:triggered,0:not triggered | |
is_active | true | int | 1:active,0:not active | |
</TDN> | true | dict object | ||
</data> |
Response:
{
"status": "ok",
"data":
[{
"is_disable": 1,
"order_price_types": "limit,post_only,FOK,IOC",
"disable_reason":"COR",
"disable_interval": 5,
"recovery_time": 1,
"COR":
{
"orders_threshold": 150,
"orders": 150,
"invalid_cancel_orders": 150,
"cancel_ratio_threshold": 0.98,
"cancel_ratio": 0.98,
"is_trigger": 1,
"is_active": 1
} ,
"TDN":
{
"disables_threshold": 3,
"disables": 3,
"is_trigger": 1,
"is_active": 1
}
}],
"ts": 158797866555
}
Swap Trade Interface
[Isolated]Switch Position Mode
- POST
/linear-swap-api/v1/swap_switch_position_mode
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
margin_account | true | string | margin account | such as: "BTC-USDT", "ETH-USDT" ... |
position_mode | true | string | position mode | single_side; dual_side |
response
{
"status":"ok",
"data":[
{
"margin_account":"BTC-USDT",
"position_mode":"single_side"
}
],
"ts":1566899973811
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
<data> | true | object array | ||
margin_account | true | string | margin account | such as: "BTC-USDT", "ETH-USDT" ... |
position_mode | true | string | position mode | single_side; dual_side |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross]Switch Position Mode
- POST
/linear-swap-api/v1/swap_cross_switch_position_mode
Remarks
- The interface only supports cross margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
margin_account | true | string | margin account | such as: "USDT" |
position_mode | true | string | position mode | single_side; dual_side |
response
{
"status":"ok",
"data":[
{
"margin_account":"USDT",
"position_mode":"single_side"
}
],
"ts":1566899973811
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
<data> | true | object array | ||
margin_account | true | string | margin account | such as: "USDT" |
position_mode | true | string | position mode | single_side; dual_side |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated] Place an Order
Example
- POST
/linear-swap-api/v1/swap_order
Remarks
- This interface only supports isolated margin mode.
Request
{
"contract_code": "btc-usdt",
"direction": "buy",
"offset":"open",
"price":"29999",
"lever_rate": 5,
"volume": 1,
"order_price_type":"opponent",
"tp_trigger_price": 31000,
"tp_order_price": 31000,
"tp_order_price_type": "optimal_5",
"sl_trigger_price": "29100",
"sl_order_price": "29100",
"sl_order_price_type": "optimal_5"
}
Request Parameter
Parameter Name | Parameter Type | Required | Desc |
---|---|---|---|
contract_code | string | true | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
reduce_only | int | false | reduce only(in hedge mode it is invalid, and in one-way mode it's value is 0 when not filled.) 0: no, 1: yes |
client_order_id | long | false | Clients fill and maintain themselves. the value must be in [1, 9223372036854775807] |
price | decimal | false | Price |
volume | long | true | Numbers of orders (volume) |
direction | string | true | Transaction direction |
offset | string | false(more see remarks) | "open", "close", "both" |
lever_rate | int | true | Leverage rate [ if“Open”is multiple orders in 10 rate, there will be not multiple orders in 20 rate; high leverage has a high risk factor, so please use it with caution. |
order_price_type | string | true | "market": Market Order,"limit”: Limit Order "opponent":BBO "post_only": Post-Only Order, No order limit but position limit for post-only orders.,optimal_5: Optimal , optimal_10: Optimal 10, optimal_20:Optimal 20,ioc: IOC Order,,fok:FOK Order, "opponent_ioc":IOC order using the BBO price,"optimal_5_ioc":optimal_5 IOC,"optimal_10_ioc":optimal_10 IOC,"optimal_20_ioc":optimal_20 IOC, "opponent_fok":FOK order using the BBO price,"optimal_5_fok":optimal_5 FOK,"optimal_10_fok":optimal_10 FOK,"optimal_20_fok":optimal_20 FOK |
tp_trigger_price | decimal | false | Trigger price of take-profit order |
tp_order_price | decimal | false | Order price of take-profit order(The order price is not required to fill in for Optimal N) |
tp_order_price_type | string | false | Order type of take-profit order default is market;market, limit,optimal_5,optimal_10,optimal_20 |
sl_trigger_price | decimal | false | Trigger price of stop-loss order |
sl_order_price | decimal | false | Order price of stop-loss order(The order price is not required to fill in for Optimal N) |
sl_order_price_type | string | false | Order type of take-profit order default is market;market, limit,optimal_5,optimal_10,optimal_20 |
Note :
"limit","post_only","ioc" and "fok" the four order price type need price value and the other don't need.
Post-Only orders are limit orders that will never take liquidity (also called maker-only order). There are order limit and position for post-only orders which the upper limit is 5,000,000 for open/close orders.
If you’re holding a position currently, the leverage you choose when placing an order should be the same as the leverage of your current positions, otherwise, the order will fail to be placed. If you need a new leverage to place an order, you should switch the leverage of current positions first by using the Switch Leverage interface.
Only open orders can support setting take profit and stop loss.
The take profit trigger price is a required field for setting a take profit order, and the stop loss trigger price is a required field for setting a stop loss order; if the trigger price field is not filled in, the corresponding take profit order or stop loss order will not be set.
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.
offset, in hedge mode it is a required field, and in one-way mode it is optional paramater which's value must be both when filled.
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 1 and 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": {
"order_id": 770323133537685504,
"client_order_id": 57012021022,
"order_id_str": "770323133537685504"
},
"ts": 1603700946949
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
order_id | true | long | Order ID | |
order_id_str | true | string | 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 | |
</data> | ||||
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 json-bigint package.
[Cross] Place An Order
- POST
/linear-swap-api/v1/swap_cross_order
Remarks
The interface only supports cross margin mode.
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
one of (pair+contract_type) and contract_code must be filled in(if all of them not filled in, will get 1014 error code); and all filled in, the contract_code is the preferred.
Request
{
"contract_code": "btc-usdt",
"direction": "buy",
"offset":"open",
"price":"29999",
"lever_rate": 5,
"volume": 1,
"order_price_type":"opponent",
"tp_trigger_price": 31000,
"tp_order_price": 31000,
"tp_order_price_type": "optimal_5",
"sl_trigger_price": "29100",
"sl_order_price": "29100",
"sl_order_price_type": "optimal_5"
}
Request Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false(more see remarks) | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false(more see remarks) | string | pair | BTC-USDT |
contract_type | false(more see remarks) | string | contract type | swap, this_week, next_week, quarter, next_quarter |
reduce_only | false | int | reduce only(in hedge mode it is invalid, and in one-way mode it's value is 0 when not filled.) | 0: no, 1: yes |
client_order_id | false | long | Clients fill and maintain themselves. | [1, 9223372036854775807] |
price | false | decimal | price | |
volume | true | long | Numbers of orders (volume) | |
direction | true | string | Transaction direction | "buy"/"sell" |
offset | false(more see remarks) | string | "open", "close" | "open","close","both" |
lever_rate | true | int | leverage [ if“Open”is multiple orders in 10 rate, there will be not multiple orders in 20 rate; high leverage has a high risk factor, so please use it with caution. | |
order_price_type | true | string | type of order price | "market": Market Order,"limit”: Limit Order "opponent":BBO "post_only": Post-Only Order, No order limit but position limit for post-only orders.,optimal_5: Optimal , optimal_10: Optimal 10, optimal_20:Optimal 20,ioc: IOC Order,,fok:FOK Order, "opponent_ioc":IOC order using the BBO price,"optimal_5_ioc":optimal_5 IOC,"optimal_10_ioc":optimal_10 IOC,"optimal_20_ioc":optimal_20 IOC, "opponent_fok":FOK order using the BBO price,"optimal_5_fok":optimal_5 FOK,"optimal_10_fok":optimal_10 FOK,"optimal_20_fok":optimal_20 FOK |
tp_trigger_price | decimal | false | Trigger price of take-profit order | |
tp_order_price | decimal | false | Order price of take-profit order(The order price is not required to fill in for Optimal N) | |
tp_order_price_type | string | false | Order type of take-profit order default is limit; | Order type of take-profit order default is market;market, limit,optimal_5,optimal_10,optimal_20 |
sl_trigger_price | decimal | false | Trigger price of stop-loss order | |
sl_order_price | decimal | false | Order price of stop-loss order(The order price is not required to fill in for Optimal N) | |
sl_order_price_type | string | false | Order type of stop-loss order default is limit; | Order type of take-profit order default is market;market, limit,optimal_5,optimal_10,optimal_20 |
Note
"limit","post_only","ioc" and "fok" the four order price type need price value and the other don't need.
Post-Only orders are limit orders that will never take liquidity (also called maker-only order). There are order limit and position for post-only orders which the upper limit is 5,000,000 for open/close orders.
If you’re holding a position currently, the leverage you choose when placing an order should be the same as the leverage of your current positions, otherwise, the order will fail to be placed. If you need a new leverage to place an order, you should switch the leverage of current positions first by using the Switch Leverage interface.
Only open orders can support setting take profit and stop loss.
The take profit trigger price is a required field for setting a take profit order, and the stop loss trigger price is a required field for setting a stop loss order; if the trigger price field is not filled in, the corresponding take profit order or stop loss order will not be set.
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.
offset, in hedge mode it is a required field, and in one-way mode it is optional paramater which's value must be both when filled.
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 1 and 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": {
"order_id": 784017187857760256,
"order_id_str": "784017187857760256"
},
"ts": 1606965863952
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
client_order_id | false | long | the client ID that is filled in when the order is placed, if it’s not filled, it won’t be returned | |
</data> | ||||
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 json-bigint package.
[Isolated] Place a Batch of Orders
Example
- POST
/linear-swap-api/v1/swap_batchorder
Remarks
- This interface only supports isolated margin mode.
Request
{
"orders_data": [
{
"contract_code": "btc-usdt",
"direction": "sell",
"offset": "open",
"price": "29999",
"lever_rate": 5,
"volume": 1,
"order_price_type": "opponent",
"tp_trigger_price": 27000,
"tp_order_price": 27000,
"tp_order_price_type": "optimal_5",
"sl_trigger_price": "30100",
"sl_order_price": "30100",
"sl_order_price_type": "optimal_5"
},
{
"contract_code": "btc-usdt",
"direction": "buy",
"offset": "open",
"price": "29999",
"lever_rate": 5,
"volume": 1,
"order_price_type": "post_only",
"tp_trigger_price": 31000,
"tp_order_price": 31000,
"tp_order_price_type": "optimal_5",
"sl_trigger_price": "29100",
"sl_order_price": "29100",
"sl_order_price_type": "optimal_5"
}
]
}
Request Parameter
Parameter Name | Parameter Type | Required | Desc |
---|---|---|---|
orders_data | List<Object> | 10 orders at most. |
- orders_data object detail
Parameter Name | Parameter Type | Required | Desc |
---|---|---|---|
contract_code | string | true | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
reduce_only | int | false | reduce only(in hedge mode it is invalid, and in one-way mode it's value is 0 when not filled.) 0: no, 1: yes |
client_order_id | long | false | Clients fill and maintain themselves. the value must be in [1, 9223372036854775807] |
price | decimal | false | Price |
volume | long | true | Numbers of orders (volume) |
direction | string | true | Transaction direction |
offset | string | false(more see remarks) | "open", "close", "both" |
lever_rate | int | true | Leverage rate [ if“Open”is multiple orders in 10 rate, there will be not multiple orders in 20 rate; high leverage has a high risk factor, so please use it with caution. |
order_price_type | string | true | "market": Market Order,"limit”: Limit Order "opponent":BBO "post_only": Post-Only Order, No order limit but position limit for post-only orders.,optimal_5: Optimal , optimal_10: Optimal 10, optimal_20:Optimal 20,ioc: IOC Order,,fok:FOK Order, "opponent_ioc":IOC order using the BBO price,"optimal_5_ioc":optimal_5 IOC,"optimal_10_ioc":optimal_10 IOC,"optimal_20_ioc":optimal_20 IOC, "opponent_fok":FOK order using the BBO price,"optimal_5_fok":optimal_5 FOK,"optimal_10_fok":optimal_10 FOK,"optimal_20_fok":optimal_20 FOK |
tp_trigger_price | decimal | false | Trigger price of take-profit order |
tp_order_price | decimal | false | Order price of take-profit order(The order price is not required to fill in for Optimal N) |
tp_order_price_type | string | false | Order type of take-profit order default is market;market, limit,optimal_5,optimal_10,optimal_20 |
sl_trigger_price | decimal | false | Trigger price of stop-loss order |
sl_order_price | decimal | false | Order price of stop-loss order(The order price is not required to fill in for Optimal N) |
sl_order_price_type | string | false | Order type of take-profit order default is market;market, limit,optimal_5,optimal_10,optimal_20 |
Note :
"limit","post_only","ioc" and "fok" the four order price type need price value and the other don't need.
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.
If you’re holding a position currently, the leverage you choose when placing an order should be the same as the leverage of your current positions, otherwise, the order will fail to be placed. If you need a new leverage to place an order, you should switch the leverage of current positions first by using the Switch Leverage interface.
Only open orders can support setting take profit and stop loss.
The take profit trigger price is a required field for setting a take profit order, and the stop loss trigger price is a required field for setting a stop loss order; if the trigger price field is not filled in, the corresponding take profit order or stop loss order will not be set.
No need to transfer BBO order price(ask 1 and 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.
offset, in hedge mode it is a required field, and in one-way mode it is optional paramater which's value must be both when filled.
10 orders at most
Response:
{
"status": "ok",
"data": {
"errors": [
{
"index": 2,
"err_code": 1050,
"err_msg": "Customers order number is repeated. Please try again later."
}
],
"success": [