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": [
{
"order_id": 770323847022211072,
"client_order_id": 57012021024,
"index": 1,
"order_id_str": "770323847022211072"
}
]
},
"ts": 1603701117058
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | object | |||
<errors> | array | |||
index | true | int | order Index | |
err_code | true | int | Error code | |
err_msg | true | string | Error information | |
</errors> | ||||
<success> | ||||
index | true | int | order Index | |
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 | |
</success> | ||||
</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 A Batch Of Orders
- POST
/linear-swap-api/v1/swap_cross_batchorder
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
{
"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 | Required | Type | Desc | Data Value |
---|---|---|---|---|
<orders_data> | true | object array | ||
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 | offset | "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 | false | decimal | Trigger price of take-profit order | |
tp_order_price | false | decimal | Order price of take-profit order(The order price is not required to fill in for Optimal N) | |
tp_order_price_type | false | string | 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 | false | decimal | Trigger price of stop-loss order | |
sl_order_price | false | decimal | Order price of stop-loss order(The order price is not required to fill in for Optimal N) | |
sl_order_price_type | false | string | 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 |
</orders_data> |
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.
25 orders at most
Response:
{
"status": "ok",
"data": {
"errors": [
{
"index": 2,
"err_code": 1045,
"err_msg": "Unable to switch leverage due to open orders."
}
],
"success": [
{
"order_id": 784022175422087168,
"index": 1,
"order_id_str": "784022175422087168"
}
]
},
"ts": 1606967053089
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
<errors> | true | object array | ||
index | true | int | order index | |
err_code | true | int | error code | |
err_msg | true | string | error message | |
</errors> | ||||
<success> | ||||
index | true | int | order index | |
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 | |
</success> | ||||
</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] Cancel an Order
Example
- POST
/linear-swap-api/v1/swap_cancel
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
order_id | false(more detail see the note) | string | Order ID(different IDs are separated by ",", maximum 10 orders can be withdrew at one time) |
client_order_id | false(more detail see the note) | string | Client order ID (different IDs are separated by ",", maximum 10 orders can be withdrew at one time) |
contract_code | true | string | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
Note :
Both order_id and client_order_id can be used for order withdrawl,one of them needed at one time,if both of them are set,the default will be order id。
The return data from Cancel An Order Interface only means that order cancelation designation is executed successfully. To check cancelation result, please check your order status at Get Information Of An Order interface.
client_order_id, order status query is available for orders placed within 8 hours; Otherwise, clients cannot check orders placed beyond 8 hours.
Response: result of multiple order withdrawls (successful withdrew order ID, failed withdrew order ID)
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "770323133537685504",
"err_code": 1071,
"err_msg": "Repeated withdraw."
}
],
"successes": "770323847022211072"
},
"ts": 1603701351602
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | object | |||
<errors> | array | |||
order_id | true | string | Order ID | |
err_code | true | int | Error code | |
err_msg | true | string | Error information | |
</errors> | ||||
successes | true | string | Successfully withdrew list of order_id or client_order_id | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross] Cancel An Order
- POST
/linear-swap-api/v1/swap_cross_cancel
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 Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
order_id | false(more see remarks) | string | order ID(different IDs are separated by ",", maximum 10 orders can be withdrew at one time) | |
client_order_id | false(more see remarks) | string | Client order ID (different IDs are separated by ",", maximum 10 orders can be withdrew at one time) | |
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 |
Note:
Both order_id and client_order_id can be used for order withdrawl,one of them needed at one time,if both of them are set,the default will be order id。
The return data from Cancel An Order Interface only means that order cancelation designation is executed successfully. To check cancelation result, please check your order status at Get Information Of An Order interface.
client_order_id, order status query is available for orders placed within 8 hours; Otherwise, clients cannot check orders placed beyond 8 hours.
Response
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "784054331179532288",
"err_code": 1062,
"err_msg": "Cancelling. Please be patient."
}
],
"successes": "784054331179532288"
},
"ts": 1606974744952
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
<errors> | true | array | ||
order_id | true | string | order ID | |
err_code | true | int | error code | |
err_msg | true | string | error message | |
</errors> | ||||
successes | true | string | successfully withdrew list of order_id or client_order_id | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated] Cancel All Orders
Example
- POST
/linear-swap-api/v1/swap_cancelall
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
contract_code | true | string | Case-Insenstive.Both uppercase and lowercase are supported..e.g. "BTC-USDT" |
direction | false | string | Transaction direction(if not filled in means all) ["buy" , "sell"] |
offset | false | string | offset direction(if not filled in means all) ["open" , "close"] |
Note:
- You can fill in only one of direction and offset to cancel the orders. (such as direction=buy, all buy orders will be cancelled, including "open" and "close" offset)
Response:result of multiple order withdrawls (successful withdrew order ID, failed withdrew order ID)
{
"status": "ok",
"data": {
"errors": [],
"successes": "768883002062282752,770325103371542528,770325103388319744"
},
"ts": 1603701437838
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | object | |||
<errors> | array | |||
order_id | true | string | Order ID | |
err_code | true | int | failed order error messageError code | |
err_msg | true | string | failed order information | |
</errors> | ||||
successes | true | string | Successful order | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross] Cancel All Orders
- POST
/linear-swap-api/v1/swap_cross_cancelall
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 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 |
direction | false | string | Transaction direction(if not filled in means all) ["buy" , "sell"] | |
offset | false | string | offset direction(if not filled in means all) ["open" , "close"] |
Note:
- You can fill in only one of direction and offset to cancel the orders. (such as direction=buy, all buy orders will be cancelled, including "open" and "close" offset)
Response
{
"status": "ok",
"data": {
"errors": [],
"successes": "784055473531781120,784055473842159616"
},
"ts": 1606974998510
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
<errors> | true | array | ||
order_id | true | string | order ID | |
err_code | true | int | error code | |
err_msg | true | string | error message | |
</errors> | ||||
successes | true | string | the list order which's successful | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated] Switch Leverage
- POST
/linear-swap-api/v1/swap_switch_lever_rate
Note
This interface only supports isolated margin mode.
Only if a user has positions of a single token and has no open orders, the leverage is available to be switched flexibly.
The interface limits the number of requests to 1 time per 3 seconds.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "BTC-USDT"... |
lever_rate | true | int | The leverage multiple to be switched; high leverage has a high risk factor, so please use it with caution. |
Response:
OK:
{
"status": "ok",
"data": {
"contract_code": "btc-usdt",
"margin_mode": "isolated",
"lever_rate": 10
},
"ts": 1603699417036
}
No:
{
"status": "error",
"err_code": 1045,
"err_msg": "Unable to switch leverage due to current holdings or open orders.",
"ts": 1603701654205
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | status: ok,error | |
<data> | false | object | ||
contract_code | false | string | contract code | "BTC-USDT"... |
margin_mode | false | string | margin mode | isolated : "isolated" |
lever_rate | false | int | Switched leverage | |
</data> | ||||
err_code | false | int | error code | |
err_msg | false | string | error msg | |
ts | true | long | Timestamp |
[Cross] Switch Leverage
- POST
/linear-swap-api/v1/swap_cross_switch_lever_rate
Note
The interface only supports cross margin mode.
Only if a user has positions of a single token and has no open orders, the leverage is available to be switched flexibly.
The interface limits the number of requests to 1 time per 3 seconds.
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 Value |
---|---|---|---|---|
contract_code | false(more detail see the note) | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false(more detail see the note) | string | pair | BTC-USDT |
contract_type | false(more detail see the note) | string | contract type | swap, this_week, next_week, quarter, next_quarter |
lever_rate | true | int | The leverage multiple to be switched; high leverage has a high risk factor, so please use it with caution. |
Response
{
"status": "ok",
"data": {
"contract_type": "swap",
"pair": "BTC-USDT",
"business_type": "swap",
"contract_code": "BTC-USDT",
"lever_rate": 2,
"margin_mode": "cross"
},
"ts": 1639099382678
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | ok/error | |
<data> | false | object | ||
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | false | string | margin mode | cross: cross margin mode |
lever_rate | false | int | switched leverage | |
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> | ||||
err-code | false | int | error code | |
err-msg | false | string | error message | |
ts | true | long | timestamp |
[Isolated] Place Lightning Close Order
- POST
/linear-swap-api/v1/swap_lightning_close_position
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" | |
volume | true | long | Order Quantity(Cont) | |
direction | true | string | “buy”:Open,“sell”:Close | |
client_order_id | false | long | Client needs to provide unique API and have to maintain the API themselves afterwards. | [1, 9223372036854775807] |
order_price_type | false | string | "lightning" by default. "lightning_fok": lightning FOK type,"lightning_ioc": lightning IOC type | "market" by default."market": market Order type," "lightning_fok": lightning FOK type,"lightning_ioc": lightning IOC type |
Note:
- Lightning Close Position,is order with rival price and optimal 30 grades. And the unsettled part will be automatically converted into a limited price order.
Response:
{
"status": "ok",
"data": {
"order_id": 633766664829804544,
"order_id_str": "633766664829804544",
"client_order_id": 9086
},
"ts": 158797866555
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" :Order placed successfully, "error":Order failed |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | Dictionary | |||
order_id | true | long | Order ID | |
order_id_str | true | string | Order ID | |
client_order_id | false | long | user’s own order ID | |
</data> |
Error:
{
"status": "error",
"err_code": 1048,
"err_msg": "Insufficient close amount available.",
"ts": 1603704587846
}
[Cross] Place Lightning Close Position
- POST
/linear-swap-api/v1/swap_cross_lightning_close_position
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 Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
contract_code | false(more detail see the note) | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false(more detail see the note) | string | pair | BTC-USDT |
contract_type | false(more detail see the note) | string | contract type | swap, this_week, next_week, quarter, next_quarter |
volume | true | decimal | place volume | |
direction | true | string | direction | “buy”/“sell” |
client_order_id | false | long | client order ID | [1, 9223372036854775807] |
order_price_type | false | string | type of order price | "market" by default."market": market Order type," "lightning_fok": lightning FOK type,"lightning_ioc": lightning IOC type |
Note
Lightning Close Position,is order with rival price and optimal 30 grades. And the unsettled part will be automatically converted into a limited price order.
The closing price of lightning closing position has a predictable effect, which can avoid the loss of users when the order cannot be completed when the market price rises sharply and falls sharply.
Response
{
"status": "ok",
"data": {
"order_id": 784063527799226368,
"order_id_str": "784063527799226368"
},
"ts": 1606976912267
}
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 | ||
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
client_order_id | false | int | client order ID | |
</data> |
[Isolated] Get Information of an Order
- POST
/linear-swap-api/v1/swap_order_info
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
order_id | false(Please see the notes) | string | Order ID(different IDs are separated by ",", maximum 50 orders can be withdrew at one time) |
client_order_id | false(Please see the notes) | string | Client order ID Order ID(different IDs are separated by ",", maximum 50 orders can be withdrew at one time) |
contract_code | true | string | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
Note :
When getting information on order cancellation via get order Information interface, users can only query last 2-hour data
At least one of order_id and client_order_id must be filled in
Both order_id and client_order_id can be used for order withdrawl,one of them needed at one time,if both of them are set,the default will be order id. The order completed( 5.partially fulfilled but cancelled by client; 6. Fully fulfilled; 7. Cancelled; ) will be deleted after the settlement of funding rate on 00:00(GMT+8), 08:00(GMT+8) and 16:00(GMT+8).
client_order_id,order status query is available for orders placed within 8 hours; Otherwise, clients cannot check orders placed beyond 8 hours.
Response:
{
"status": "ok",
"data": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1,
"price": 13059.8,
"order_price_type": "opponent",
"order_type": 1,
"direction": "sell",
"offset": "open",
"lever_rate": 10,
"order_id": 770334322963152896,
"client_order_id": 57012021045,
"created_at": 1603703614712,
"trade_volume": 1,
"trade_turnover": 13.059800000000000000,
"fee": -0.005223920000000000,
"trade_avg_price": 13059.800000000000000000,
"margin_frozen": 0,
"profit": 0,
"status": 6,
"order_source": "api",
"order_id_str": "770334322963152896",
"fee_asset": "USDT",
"liquidation_type": "0",
"canceled_at": 0,
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
}
],
"ts": 1603703631815
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
symbol | true | string | symbol | eg."BTC" |
contract_code | true | string | Contract Code | "BTC-USDT" ... |
volume | true | decimal | Numbers of order | |
price | true | decimal | Price committed | |
order_price_type | true | string | order price type | "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 |
order_type | true | int | Order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
direction | true | string | Transaction direction | "buy":"sell" |
offset | true | string | "open": "close" | "open", "close", "both" |
lever_rate | true | int | Leverage rate | 1\5\10\20 |
order_id | true | long | Order ID | |
order_id_str | true | string | Order ID | |
client_order_id | true | long | Client order ID | |
created_at | true | long | Creation time | |
canceled_at | true | long | Canceled time | |
trade_volume | true | decimal | Transaction quantity | |
trade_turnover | true | decimal | Transaction aggregate amount | |
fee | true | decimal | Service fee | |
trade_avg_price | true | decimal | Transaction average price | |
margin_frozen | true | decimal | Frozen margin | |
margin_asset | true | string | margin asset | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling. |
order_source | true | string | Order source | (system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl) |
fee_asset | true | string | the corresponding cryptocurrency to the given fee | "USDT"... |
liquidation_type | true | string | Liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history settlement.) | |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> | ||||
ts | true | long | Timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And in the other orders created before that times, it is 0.
[Cross] Get Information of order
- POST
/linear-swap-api/v1/swap_cross_order_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-210625.
one of pair 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 Value |
---|---|---|---|---|
order_id | false(more detail see the note) | string | order ID(different IDs are separated by ",", maximum 50 orders can be withdrew at one time) | |
client_order_id | false(more detail see the note) | string | client order ID Order ID(different IDs are separated by ",", maximum 50 orders can be withdrew at one time) | |
contract_code | false(more detail see the note) | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false(more detail see the note) | string | pair | BTC-USDT |
Note:
When getting information on order cancellation via get order Information interface, users can only query last 2-hour data
Both order_id and client_order_id can be used for order withdrawl,one of them needed at one time,if both of them are set,the default will be order id. The order completed( 5.partially fulfilled but cancelled by client; 6. Fully fulfilled; 7. Cancelled; ) will be deleted after the settlement of funding rate on 00:00(GMT+8), 08:00(GMT+8) and 16:00(GMT+8).
client_order_id,order status query is available for orders placed within 8 hours; Otherwise, clients cannot check orders placed beyond 8 hours.
Response
{
"status": "ok",
"data": [
{
"business_type": "futures",
"contract_type": "quarter",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"volume": 1.000000000000000000,
"price": 66000.000000000000000000,
"order_price_type": "post_only",
"order_type": 1,
"direction": "sell",
"offset": "open",
"lever_rate": 1,
"order_id": 917361800293453824,
"client_order_id": null,
"created_at": 1638757696945,
"trade_volume": 0E-18,
"trade_turnover": 0E-18,
"fee": 0E-18,
"trade_avg_price": null,
"margin_frozen": 66.000000000000000000,
"profit": 0E-18,
"status": 3,
"order_source": "api",
"order_id_str": "917361800293453824",
"fee_asset": "USDT",
"liquidation_type": "0",
"canceled_at": 0,
"margin_asset": "USDT",
"margin_account": "USDT",
"margin_mode": "cross",
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
}
],
"ts": 1639099755552
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object array | ||
symbol | true | string | symbol | |
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 | place volume | |
price | true | decimal | place price | |
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 |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
lever_rate | true | int | leverage | |
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
client_order_id | true | long | client order ID | |
created_at | true | long | created time | |
trade_volume | true | decimal | trade quantity | |
trade_turnover | true | decimal | trade amount | |
fee | true | decimal | service fee | |
trade_avg_price | true | decimal | trade average price | |
margin_asset | true | string | margin asset | |
margin_frozen | true | decimal | frozen margin | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling. |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated | |
canceled_at | true | long | canceled time | |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history 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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> | ||||
ts | true | long | timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And in the other orders created before that times, it is 0.
[Isolated] Order details acquisition
- POST
/linear-swap-api/v1/swap_order_detail
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
contract_code | true | string | Case-Insenstive.Both uppercase and lowercase are supported.e.g. "BTC-USDT" |
order_id | true | long | Order ID |
created_at | false | long | Timestamp |
order_type | false | int | Order type: 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order; 22. ADL reduction-only order |
page_index | false | int | Page number, default 1st page |
page_size | false | int | Default 20,no more than 50 |
Note
When getting information on order cancellation via query order detail interface, users who type in parameters “created_at” and “order_type” can query last 6-hour data, while users who don’t type in parameters “created_at” and “order_type” can only query last 2-hour data.
The return order_id is 18 bits, it will make mistake when nodejs and JavaScript analysed 18 bits. Because the Json.parse in nodejs and JavaScript is int by default. so the number over 18 bits need be parsed by jaso-bigint package.
created_at should use timestamp of long type as 13 bits (include Millisecond), if send the accurate timestamp for "created_at", query performance will be improved.
Please note that created_at can't be "0"
Response:
{
"status": "ok",
"data": {
"symbol": "BTC",
"contract_code": "BTC-USDT",
"instrument_price": 0,
"final_interest": 0,
"adjust_value": 0,
"lever_rate": 10,
"direction": "sell",
"offset": "open",
"volume": 1.000000000000000000,
"price": 13059.800000000000000000,
"created_at": 1603703614712,
"canceled_at": 0,
"order_source": "api",
"order_price_type": "opponent",
"margin_frozen": 0,
"profit": 0,
"trades": [
{
"trade_id": 131560927,
"trade_price": 13059.800000000000000000,
"trade_volume": 1.000000000000000000,
"trade_turnover": 13.059800000000000000,
"trade_fee": -0.005223920000000000,
"created_at": 1603703614715,
"role": "taker",
"fee_asset": "USDT",
"profit": 0,
"real_profit": 0,
"id": "131560927-770334322963152896-1"
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1,
"liquidation_type": "0",
"fee_asset": "USDT",
"fee": -0.005223920000000000,
"order_id": 770334322963152896,
"order_id_str": "770334322963152896",
"client_order_id": 57012021045,
"order_type": "1",
"status": 6,
"trade_avg_price": 13059.800000000000000000,
"trade_turnover": 13.059800000000000000,
"trade_volume": 1.000000000000000000,
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"real_profit": 0,
"is_tpsl": 0,
"reduce_only": 0
},
"ts": 1603703678477
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | ||||
symbol | true | string | Variety code | |
contract_code | true | string | Contract Code | "BTC-USDT" ... |
lever_rate | true | int | Leverage Rate | 1\5\10\20 |
direction | true | string | Transaction direction | "buy", "sell" |
offset | true | string | "open": "close" | "open", "close", "both" |
volume | true | decimal | Number of Order | |
price | true | decimal | Price committed | |
created_at | true | long | Creation time | |
canceled_at | true | long | Canceled time | |
order_source | true | string | Order Source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | "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 |
margin_frozen | true | decimal | Frozen margin | |
margin_asset | true | string | margin asset | |
profit | true | decimal | total profit or loss of order when close position (calculated with the average price of position, exclude profit in history settlement.) | |
order_id | true | long | Order ID | |
order_id_str | true | string | Order ID | |
client_order_id | true | long | Client order ID | |
order_type | true | string | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order ; 22. ADL reduction-only order |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling. |
trade_volume | true | decimal | Transaction quantity | |
trade_turnover | true | decimal | Transaction aggregate amount | |
trade_avg_price | true | decimal | Transaction average price | |
total_page | true | int | Page in total | |
current_page | true | int | Current Page | |
total_size | true | int | Total Size | |
instrument_price | true | decimal | Liquidation price | |
final_interest | true | decimal | Account Balance After Liquidation | |
adjust_value | true | decimal | Adjustment Factor of Liquidating Order | |
fee_asset | true | string | the corresponding cryptocurrency to the given fee | "USDT"... |
fee | true | decimal | total amount of fees | |
liquidation_type | true | string | Liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | total real profit of order (calculated with the opening average price, include profit in history settlement.) | |
reduce_only | true | int | reduce only | 0: no, 1: yes |
<trades> | ||||
id | true | string | the global unique ID of the trade. | |
trade_id | true | long | In this interface, trade_id is the same with match_id of linear-swap-api/v1/swap_matchresults. trade_id is the result of sets of order execution and trade confirmation. NOTE: trade_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same trade_id. | |
trade_price | true | decimal | Match Price | |
trade_volume | true | decimal | Transaction quantity | |
trade_turnover | true | decimal | Transaction price | |
trade_fee | true | decimal | Transaction Service fee | |
role | true | string | taker or maker | |
created_at | true | long | Creation time | |
profit | true | decimal | profit or loss of the transaction (calculated with the average price of position, exclude profit in history settlement.) | |
real_profit | true | decimal | real profit of the transaction (calculated with the opening average price, include profit in history settlement.) | |
</trades> | ||||
</data > | ||||
ts | true | long | Timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And the real profit (real_profit) of the transaction information that orders traded after December 10, 2020 has a value.
[Cross] Get Detail Information of order
- POST
/linear-swap-api/v1/swap_cross_order_detail
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 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 Value |
---|---|---|---|---|
contract_code | false(more detail see the note) | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false(more detail see the note) | string | pair | BTC-USDT |
order_id | true | long | order ID | |
created_at | false | long | created timestamp | |
order_type | false | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order; 5. ADL reduction-only order |
page_index | false | int | page number, default 1st page | |
page_size | false | int | default 20,no more than 50 |
Note
When getting information on order cancellation via query order detail interface, users who type in parameters “created_at” and “order_type” can query last 6-hour data, while users who don’t type in parameters “created_at” and “order_type” can only query last 2-hour data.
The return order_id is 18 bits, it will make mistake when nodejs and JavaScript analysed 18 bits. Because the Json.parse in nodejs and JavaScript is int by default. so the number over 18 bits need be parsed by jaso-bigint package.
created_at should use timestamp of long type as 13 bits (include Millisecond), if send the accurate timestamp for "created_at", query performance will be improved.
Please note that created_at can't be "0"
Response
{
"status": "ok",
"data": {
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"instrument_price": 0,
"final_interest": 0,
"adjust_value": 0,
"lever_rate": 5,
"direction": "buy",
"offset": "open",
"volume": 100.000000000000000000,
"price": 48555.600000000000000000,
"created_at": 1639100651569,
"canceled_at": 0,
"order_source": "api",
"order_price_type": "opponent",
"margin_frozen": 0E-18,
"profit": 0E-18,
"trades": [
{
"trade_id": 2902136,
"trade_price": 48555.600000000000000000,
"trade_volume": 100.000000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_fee": -2.427780000000000000,
"created_at": 1639100651577,
"role": "taker",
"fee_asset": "USDT",
"real_profit": 0E-18,
"profit": 0E-18,
"id": "2902136-918800256249405440-1"
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1,
"liquidation_type": "0",
"fee_asset": "USDT",
"fee": -2.427780000000000000,
"order_id": 918800256249405440,
"order_id_str": "918800256249405440",
"client_order_id": null,
"order_type": "1",
"status": 6,
"trade_avg_price": 48555.600000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_volume": 100.000000000000000000,
"margin_asset": "USDT",
"margin_account": "USDT",
"margin_mode": "cross",
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
},
"ts": 1639100665681
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
symbol | true | string | symbol | |
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"... |
lever_rate | true | int | leverage | |
direction | true | string | direction | "buy","sell" |
offset | true | string | offset | "open", "close", "both" |
volume | true | decimal | place volume | |
price | true | decimal | place price | |
created_at | true | long | created time | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
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 |
margin_asset | true | string | margin asset | |
margin_frozen | true | decimal | frozen margin | |
profit | true | decimal | total profit or loss of order when close position (calculated with the average price of position, exclude profit in history settlement.) | |
instrument_price | true | decimal | liquidation price | |
final_interest | true | decimal | account balance after liquidation | |
adjust_value | true | decimal | adjustment factor of liquidating order | |
fee | true | decimal | total fee | |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | |
canceled_at | true | long | canceled time | |
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
client_order_id | true | long | client order ID | |
order_type | true | string | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order ; 22. ADL reduction-only order |
status | true | int | order status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling. |
trade_avg_price | true | decimal | trade average price | |
trade_turnover | true | decimal | trade total amount | |
trade_volume | true | decimal | trade total amount | |
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 |
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | total real profit of order (calculated with the opening average price, include profit in history settlement.) | |
reduce_only | true | int | reduce only | 0: no, 1: yes |
<trades> | true | object array | ||
id | true | string | the global unique ID of the trade | |
trade_id | true | long | In this interface, trade_id is the same with match_id of linear-swap-api/v1/swap_cross_matchresults. trade_id is the result of sets of order execution and trade confirmation. NOTE: trade_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same trade_id. | |
trade_price | true | decimal | trade price | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade amount | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker/maker | |
created_at | true | long | created time | |
profit | true | decimal | profit or loss of the transaction (calculated with the average price of position, exclude profit in history settlement.) | |
real_profit | true | decimal | real profit of the transaction (calculated with the opening average price, include profit in history settlement.) | |
</trades> | ||||
</data> | ||||
ts | true | long | timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And the real profit (real_profit) of the transaction information that orders traded after December 10, 2020 has a value.
[Isolated] Current unfilled order acquisition
- POST
/linear-swap-api/v1/swap_openorders
Remarks
- This interface only supports isolated margin mode.
Request Parameter
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" | |
page_index | false | int | Page, default 1st page | 1 | |
page_size | false | int | Default 20,no more than 50 | 20 | |
sort_by | false | string | sort fields(descending) | created_at | “created_at”descending order by order created at, "update_time": descending order by order update time |
trade_type | false | int | trade type(Default:all) | 0 | 0:all,1: buy long,2: sell short,3: buy short,4: sell long , 17:buy(one-way mode), 18:sell(one-way mode) |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1,
"price": 13329,
"order_price_type": "limit",
"order_type": 1,
"direction": "sell",
"offset": "open",
"lever_rate": 10,
"order_id": 770326042832437248,
"client_order_id": 57012021028,
"created_at": 1603701640576,
"trade_volume": 0,
"trade_turnover": 0,
"fee": 0,
"trade_avg_price": null,
"margin_frozen": 1.332900000000000000,
"profit": 0,
"status": 3,
"order_source": "api",
"order_id_str": "770326042832437248",
"fee_asset": "USDT",
"liquidation_type": null,
"canceled_at": null,
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"is_tpsl": 0,
"update_time": 1606975980467,
"real_profit": 0,
"reduce_only": 0
}
],
"total_page": 2,
"current_page": 1,
"total_size": 2
},
"ts": 1603703993952
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | |
<data> | object | |||
<orders> | array | |||
symbol | true | string | Variety code | |
contract_code | true | string | Contract Code | "BTC-USDT" ... |
volume | true | decimal | Number of Order | |
price | true | decimal | Price committed | |
order_price_type | true | string | type of order price | "limit":Limit,"opponent":opponent,"post_only":Post-Only Order, No order limit but position limit for post-only orders.,"lightning":lightning, "optimal_5":optimal 5,"optimal_10":optimal 10,"optimal_20":optimal 20,"fok":FOK Order,"ioc":IOC Order, "opponent_ioc": opponent ioc,"lightning_ioc": lightning ioc,"optimal_5_ioc": optimal_5 ioc,"optimal_10_ioc": optimal_10 ioc,"optimal_20_ioc":optimal_20 ioc,"opponent_fok": opponent fok,"lightning_fok":lightning fok,"optimal_5_fok":optimal_5 fok,"optimal_10_fok":optimal_10 fok,"optimal_20_fok":optimal_20 fok |
order_type | true | int | Order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
direction | true | string | Transaction direction | "buy","sell" |
offset | true | string | "open": "close" | "open", "close", "both" |
lever_rate | true | int | Leverage Rate | 1\5\10\20 |
order_id | true | long | Order ID | |
order_id_str | true | string | Order ID | |
client_order_id | true | long | Client order ID | |
created_at | true | long | Order Creation time | |
trade_volume | true | decimal | Transaction quantity | |
trade_turnover | true | decimal | Transaction aggregate amount | |
fee | true | decimal | Service fee | |
trade_avg_price | true | decimal | Transaction average price | |
margin_frozen | true | decimal | Frozen margin | |
margin_asset | true | string | margin asset | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; |
order_source | true | string | Order Source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
fee_asset | true | string | the corresponding cryptocurrency to the given fee | "USDT"... |
liquidation_type | true | string | liquidation type | |
canceled_at | true | long | order Cancellation time | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history settlement.) | |
update_time | true | Long | order update time ,millesecond timestamp | |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
total_page | true | int | Total Pages | |
current_page | true | int | Current Page | |
total_size | true | int | Total Size | |
</data> | ||||
ts | true | long | Timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And in the other orders created before that times, it is 0.
[Cross] Current unfilled order acquisition
- POST
/linear-swap-api/v1/swap_cross_openorders
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 and contract_code filled in, the contract_code is the preferred. supports none any parameter filled in, it means all contract code in cross mode.
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 |
page_index | false | int | page index, default 1st page | |
page_size | false | int | page size, default 20,no more than 50 | |
sort_by | false | string | sort fields(Default: “created_at” descending order) | “created_at”: descending order by order created at, "update_time": descending order by order update time |
trade_type | false | int | trade type(Default:all) | 0:all,1: buy long,2: sell short,3: buy short,4: sell long , 17.buy(one-way mode), 18.sell(one-way mode) |
Response
{
"status": "ok",
"data": {
"orders": [
{
"update_time": 1639104153425,
"business_type": "swap",
"contract_type": "swap",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1,
"price": 66000,
"order_price_type": "post_only",
"order_type": 1,
"direction": "sell",
"offset": "open",
"lever_rate": 5,
"order_id": 918814943964184578,
"client_order_id": null,
"created_at": 1639104153393,
"trade_volume": 0,
"trade_turnover": 0,
"fee": 0,
"trade_avg_price": null,
"margin_frozen": 13.200000000000000000,
"profit": 0,
"status": 3,
"order_source": "api",
"order_id_str": "918814943964184578",
"fee_asset": "USDT",
"liquidation_type": null,
"canceled_at": null,
"margin_asset": "USDT",
"margin_account": "USDT",
"margin_mode": "cross",
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1639104160523
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | |
<data> | true | object | ||
<orders> | true | object | ||
symbol | true | string | symbol | |
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 | place volume | |
price | true | decimal | place price | |
order_price_type | true | string | type of order price | "limit":Limit,"opponent":opponent,"post_only":Post-Only Order, No order limit but position limit for post-only orders.,"lightning":lightning, "optimal_5":optimal 5,"optimal_10":optimal 10,"optimal_20":optimal 20,"fok":FOK Order,"ioc":IOC Order, "opponent_ioc": opponent ioc,"lightning_ioc": lightning ioc,"optimal_5_ioc": optimal_5 ioc,"optimal_10_ioc": optimal_10 ioc,"optimal_20_ioc":optimal_20 ioc,"opponent_fok": opponent fok,"lightning_fok":lightning fok,"optimal_5_fok":optimal_5 fok,"optimal_10_fok":optimal_10 fok,"optimal_20_fok":optimal_20 fok |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
direction | true | string | "buy"/"sell" | "buy","sell" |
offset | true | string | "open"/"close" | "open","close","both" |
lever_rate | true | int | leverage | |
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
client_order_id | true | long | client order ID | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
created_at | true | long | created time | |
trade_volume | true | decimal | trade total volume | |
trade_turnover | true | decimal | trade total amount | |
fee | true | decimal | service fee | |
fee_asset | true | string | fee asset | ("USDT"...) |
trade_avg_price | true | decimal | trade average price | |
margin_asset | true | string | margin asset | |
margin_frozen | true | decimal | frozen margin | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
status | true | int | order status | 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled |
liquidation_type | true | string | liquidation type | |
canceled_at | true | long | canceled time | |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history settlement.) | |
update_time | true | Long | order update time ,millesecond timestamp | |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
</data> | ||||
ts | true | long | timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And in the other orders created before that times, it is 0.
[Isolated] Get History Orders(New)
- POST
/linear-swap-api/v3/swap_hisorders
Remarks
- This interface only supports isolated margin mode.
- All via API interface submited price limit orders that had been cancelled will only be kept for 2 hours.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"status": 0,
"type": 1,
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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 | |
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) – 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 | ||
type | true | int | Type | 1:All Orders,2:Order in Finished Status | ||
status | true | string | status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; |
Response:
{
"code": 200,
"msg": "",
"data": [
{
"query_id": 13580806498,
"order_id": 770336866451992600,
"contract_code": "BTC-USDT",
"symbol": "BTC",
"lever_rate": 10,
"direction": "sell",
"offset": "close",
"volume": 1,
"price": 13100,
"create_date": 1603704221118,
"update_time": 1603704221118,
"order_source": "web",
"order_price_type": 6,
"order_type": 1,
"margin_frozen": 0,
"profit": 0,
"trade_volume": 0,
"trade_turnover": 0,
"fee": 0,
"trade_avg_price": 0,
"status": 3,
"order_id_str": "770336866451992576",
"fee_asset": "USDT",
"liquidation_type": "0",
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
}
],
"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. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | isolated: isolated |
margin_account | true | string | margin account | such as:BTC-USDT” |
lever_rate | true | int | lever rate | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
volume | true | decimal | volume | |
price | true | decimal | price | |
create_date | true | long | create date | |
update_time | true | long | order update time,millesecond timestamp | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | "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 |
margin_asset | true | string | margin asset | |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit | |
real_profit | true | decimal | real profit | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 10.Orders failed. 11. Orders cancelling. |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
is_tpsl | true | int | is tpsl | 1: yes; 0:no |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
[Cross] Get History Orders(New)
- POST
/linear-swap-api/v3/swap_cross_hisorders
Remarks
- The interface only supports cross margin mode.
- The request parameter "contract" supports the contract code of futures, in that the format is BTC-USDT-210625.
- one of pair and contract must be filled in(if both of them not filled in, will get 1014 error code); and all filled in, the contract is the preferred.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"pair": "BTC-USDT",
"status": 0,
"type": 1,
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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) – 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 | ||
type | true | int | Type | 1:All Orders,2:Order in Finished Status | ||
status | true | string | status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; |
Note
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And in the other orders created before that times, it is 0.
Response:
{
"code": 200,
"msg": "",
"data": [
{
"query_id": 13580806498,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"order_id": 918800256249405440,
"contract_code": "BTC-USDT-211210",
"symbol": "BTC",
"lever_rate": 5,
"direction": "buy",
"offset": "open",
"volume": 100.000000000000000000,
"price": 48555.600000000000000000,
"create_date": 1639100651569,
"order_source": "api",
"order_price_type": 3,
"order_type": 1,
"margin_frozen": 0E-18,
"profit": 0E-18,
"trade_volume": 100.000000000000000000,
"trade_turnover": 4855.560000000000000000,
"fee": -2.427780000000000000,
"trade_avg_price": 48555.6000,
"status": 6,
"order_id_str": "918800256249405440",
"fee_asset": "USDT",
"liquidation_type": "0",
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"update_time": 1639100651000,
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
}
],
"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. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
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 | "USDT"... |
lever_rate | true | int | lever rate | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
volume | true | decimal | volume | |
price | true | decimal | price | |
create_date | true | long | create date | |
update_time | true | long | order update time,millesecond timestamp | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | "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 |
margin_asset | true | string | margin asset | |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit | |
real_profit | true | decimal | real profit | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 10.Orders failed. 11. Orders cancelling. |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
is_tpsl | true | int | is tpsl | 1: yes; 0:no |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
[Isolated] Get History Orders via Multiple Fields(New)
- POST
/linear-swap-api/v3/swap_hisorders_exact
Remarks
- This interface only supports isolated margin mode.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"status": 0,
"type": 1,
"price_type": "opponent",
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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) – 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 | ||
type | true | int | Type | 1:All Orders,2:Order in Finished Status | ||
status | true | string | status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; | ||
price_type | false | string | order price type | order price type, "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 | order_price_type |
Response:
{
"code": 200,
"msg": "",
"data": [
{
"query_id": 13580806498,
"order_id": 807038270541733888,
"contract_code": "BTC-USDT",
"symbol": "BTC",
"lever_rate": 10,
"direction": "buy",
"offset": "close",
"volume": 9,
"price": 36580,
"create_date": 1612454517740,
"order_source": "android",
"order_price_type": "opponent",
"order_type": 1,
"margin_frozen": 0,
"profit": 0.3636,
"trade_volume": 9,
"trade_turnover": 329.22,
"fee": -0.131688,
"trade_avg_price": 36580,
"status": 6,
"order_id_str": "807038270541733888",
"fee_asset": "BTC-USDT",
"liquidation_type": "0",
"is_tpsl": 0,
"real_profit": 0.2394,
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"reduce_only": 0
}
],
"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. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | isolated: isolated |
margin_account | true | string | margin account | such as:BTC-USDT” |
lever_rate | true | int | lever rate | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
volume | true | decimal | volume | |
price | true | decimal | price | |
create_date | true | long | create date | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | "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 |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit | |
real_profit | true | decimal | real profit | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 10.Orders failed. 11. Orders cancelling. |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
is_tpsl | true | int | is tpsl | 1: yes; 0:no |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
[Cross]Get History Orders via Multiple Fields(New)
- POST
/linear-swap-api/v3/swap_cross_hisorders_exact
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 and contract_code filled in, the contract_code is the preferred.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"pair": "BTC-USDT",
"status": 0,
"type": 1,
"price_type": "opponent",
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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) – 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 | ||
type | true | int | Type | 1:All Orders,2:Order in Finished Status | ||
status | true | string | status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; | ||
price_type | false | string | order price type | order price type, "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 | order_price_type |
Response:
{
"code": 200,
"msg": "",
"data": [
{
"query_id": 452057,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"query_id": 136966,
"match_id": 2902136,
"order_id": 918800256249405440,
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"direction": "buy",
"offset": "open",
"trade_volume": 100.000000000000000000,
"trade_price": 48555.600000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_fee": -2.427780000000000000,
"offset_profitloss": 0E-18,
"create_date": 1639100651577,
"role": "Taker",
"order_source": "api",
"order_id_str": "918800256249405440",
"id": "2902136-918800256249405440-1",
"fee_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"real_profit": 0E-18,
"reduce_only": 0
}
],
"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. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross; |
lever_rate | true | int | lever rate | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
volume | true | decimal | volume | |
price | true | decimal | price | |
create_date | true | long | create date | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | "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 |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit | |
real_profit | true | decimal | real profit | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 10.Orders failed. 11. Orders cancelling. |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
is_tpsl | true | int | is tpsl | 1: yes; 0:no |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
[Isolated] Acquire History Match Results(New)
- POST
/linear-swap-api/v3/swap_matchresults
Remarks
- The interface only supports isolated margin mode.
- The request parameter "contract" supports the contract code of futures, in that the format is BTC-USDT-210625.
- one of pair and contract must be filled in(if all of them not filled in, will get 1014 error code); and all filled in, the contract is the preferred.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"pair": "BTC-USDT",
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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) – 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": 452057,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"query_id": 136966,
"match_id": 2902136,
"order_id": 918800256249405440,
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"direction": "buy",
"offset": "open",
"trade_volume": 100.000000000000000000,
"trade_price": 48555.600000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_fee": -2.427780000000000000,
"offset_profitloss": 0E-18,
"create_date": 1639100651577,
"role": "Taker",
"order_source": "api",
"order_id_str": "918800256249405440",
"id": "2902136-918800256249405440-1",
"fee_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"real_profit": 0E-18,
"reduce_only": 0
}
],
"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 | ||
id | true | string | unique id of the trade, and match_id is not unique id. The specific method of use is to use match_id and id as the joint primary key to form a unique transaction ID. | |
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
match_id | true | long | match_id is the same with trade_id of the websocket subscriptions: orders_cross.$contract_code match_id is the result of sets of order execution and trade confirmation. NOTE: match_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same match_id. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | isolated; |
margin_account | true | string | margin account | such as:USDT” |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
trade_volume | true | decimal | trade volume | |
trade_price | true | decimal | trade price | |
trade_turnover | true | decimal | trade turnover | |
create_date | true | long | create date | |
offset_profitloss | true | decimal | profit or loss when cloase position | |
real_profit | true | decimal | real profit | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker or maker | |
fee_asset | true | string | fee asset | ("USDT"...) |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
[Cross] Get History Match Results(New)
- POST
/linear-swap-api/v3/swap_cross_matchresults
Note
- The interface only supports cross margin mode.
- The request parameter "contract" supports the contract code of futures, in that the format is BTC-USDT-210625.
- one of pair and contract must be filled in(if all of them not filled in, will get 1014 error code); and all filled in, the contract is the preferred.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"pair": "BTC-USDT",
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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) – 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": 452057,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"match_id": 2902136,
"order_id": 918800256249405440,
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"direction": "buy",
"offset": "open",
"trade_volume": 100.000000000000000000,
"trade_price": 48555.600000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_fee": -2.427780000000000000,
"offset_profitloss": 0E-18,
"create_date": 1639100651577,
"role": "Taker",
"order_source": "api",
"order_id_str": "918800256249405440",
"id": "2902136-918800256249405440-1",
"fee_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"real_profit": 0E-18,
"reduce_only": 0
}
],
"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 | ||
id | true | string | unique id of the trade, and match_id is not unique id. The specific method of use is to use match_id and id as the joint primary key to form a unique transaction ID. | |
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
match_id | true | long | match_id is the same with trade_id of the websocket subscriptions: orders_cross.$contract_code match_id is the result of sets of order execution and trade confirmation. NOTE: match_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same match_id. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
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” |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
trade_volume | true | decimal | trade volume | |
trade_price | true | decimal | trade price | |
trade_turnover | true | decimal | trade turnover | |
create_date | true | long | create date | |
offset_profitloss | true | decimal | profit or loss when cloase position | |
real_profit | true | decimal | real profit | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker or maker | |
fee_asset | true | string | fee asset | ("USDT"...) |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
true | ||||
</data> |
[Isolated]Get History Match Results via Multiple Fields(New)
- POST
/linear-swap-api/v3/swap_matchresults_exact
Remarks
- This interface only supports isolated margin mode.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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 | |
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) – 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,
"match_id": 13752484857,
"order_id": 807038270541733888,
"symbol": "BTC",
"contract_code": "BTC-USDT",
"direction": "buy",
"offset": "close",
"trade_volume": 9,
"trade_price": 36580,
"trade_turnover": 329.22,
"trade_fee": -0.131688,
"offset_profitloss": 0.3636,
"create_date": 1612454517757,
"role": "Taker",
"order_source": "android",
"order_id_str": "807038270541733888",
"id": "13752484857-807038270541733888-1",
"fee_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"real_profit": 0.2394,
"reduce_only": 0
}
],
"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 | ||
id | true | string | unique id of the trade, and match_id is not unique id. The specific method of use is to use match_id and id as the joint primary key to form a unique transaction ID. | |
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
match_id | true | long | match_id is the same with trade_id of the websocket subscriptions: orders_cross.$contract_code match_id is the result of sets of order execution and trade confirmation. NOTE: match_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same match_id. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | isolated; |
margin_account | true | string | margin account | such as:BTC-USDT” |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
trade_volume | true | decimal | trade volume | |
trade_price | true | decimal | trade price | |
trade_turnover | true | decimal | trade turnover | |
create_date | true | long | create date | |
offset_profitloss | true | decimal | profit or loss when cloase position | |
real_profit | true | decimal | real profit | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker or maker | |
fee_asset | true | string | fee asset | ("USDT"...) |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
[Cross]Get History Match Results via Multiple Fields(New)
- POST
/linear-swap-api/v3/swap_cross_matchresults_exact
Note
- The interface only supports cross margin mode.
- The request parameter "contract" supports the contract code of futures, in that the format is BTC-USDT-210625.
- When both of pair and contract filled in, the contract_code is the preferred.
Request:
{
"contract": "BTC-USDT",
"trade_type": 0,
"pair": "BTC-USDT",
"start_time": 1660119810000,
"end_time": 1660274746031,
"direct": "next",
"from_id": 1110
}
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) – 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": 452057,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"match_id": 2902136,
"order_id": 918800256249405440,
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"direction": "buy",
"offset": "open",
"trade_volume": 100.000000000000000000,
"trade_price": 48555.600000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_fee": -2.427780000000000000,
"offset_profitloss": 0E-18,
"create_date": 1639100651577,
"role": "Taker",
"order_source": "api",
"order_id_str": "918800256249405440",
"id": "2902136-918800256249405440-1",
"fee_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"real_profit": 0E-18,
"reduce_only": 0
}
],
"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 | ||
id | true | string | unique id of the trade, and match_id is not unique id. The specific method of use is to use match_id and id as the joint primary key to form a unique transaction ID. | |
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
match_id | true | long | matching result id, not unique, may be repeated | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
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” |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
trade_volume | true | decimal | trade volume | |
trade_price | true | decimal | trade price | |
trade_turnover | true | decimal | trade turnover | |
create_date | true | long | create date | |
offset_profitloss | true | decimal | profit or loss when cloase position | |
real_profit | true | decimal | real profit | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker or maker | |
fee_asset | true | string | fee asset | ("USDT"...) |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
remain_size | true | int | remain size(In the time range, the size that was not queried due to size restrictions) | |
next_id | true | long | query_id for next data(It only has a value when the query result exceeds the size limit) | |
</data> |
Swap Strategy Order Interface
[Isolated] Place Trigger Order
- POST
/linear-swap-api/v1/swap_trigger_order
Remarks
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
Request:
{
"contract_code": "BTC-USDT",
"trigger_type": "ge",
"trigger_price": 1111,
"order_price": 1000,
"order_price_type":"limit",
"volume": 111,
"direction": "buy",
"offset": "open",
"lever_rate": 10
}
body
Params | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract type | BTC-USDT |
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 |
trigger_type | true | string | trigger: ge Equal to or Greater than;le Less than or Equal to |
|
trigger_price | true | decimal | Trigger Price | |
order_price | false | decimal | Order Price | |
order_price_type | false | string | order price type: "limit" by default;"optimal_5", "optimal_10","optimal_20" | |
volume | true | long | volume | |
direction | true | string | buy sell | |
offset | false(more see remarks) | string | open, close, both | |
lever_rate | false | int | Long leverage shall be equal to short leverage.high leverage has a high risk factor, so please use it with caution. |
Note
optimal_5: top 5 optimal BBO price. optimal_10: top 10 optimal BBO price. optimal_20: top 20 optimal BBO price. limit: the limit order, order_price needed.
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.
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.
please note that, in the one-way mode, if using the parameter reduce_only=1 to place an order for opening positions, when the order triggered, it will respond error message: 1492 Amount of Reduce Only order exceeds the amount available to close. order will be failed.
Return:
{
"status": "ok",
"data": {
"order_id": 35,
"order_id_str": "35"
},
"ts": 1547521135713
}
Response Desc
field | type | Required | Desc |
---|---|---|---|
status | string | true | status: ok,error |
err_code | int | false | error code |
err_msg | string | false | error message |
data | List |
false | list info |
ts | long | true | timestamp |
- OrderInsertRspInfo
field | type | Required | Desc |
---|---|---|---|
order_id | int | true | order id. |
order_id_str | string | true | order id str |
Error:
{
"status": "error",
"err_code": 1014,
"err_msg": "This contract doesnt exist.",
"ts": 1603704820880
}
[Cross] Place Trigger Order
- POST
/linear-swap-api/v1/swap_cross_trigger_order
Remarks
- The interface only supports cross margin mode.
- The frequency limit of this interface is 5 times per second.
- 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.
- 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.
- please note that, in the one-way mode, if using the parameter reduce_only=1 to place an order for opening positions, when the order triggered, it will respond error message: 1492 Amount of Reduce Only order exceeds the amount available to close. order will be failed.
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 |
trigger_type | true | string | trigger type | ge: Equal to or Greater than;le: Less than or Equal to |
trigger_price | true | decimal | trigger price | |
order_price | false | decimal | order price | |
order_price_type | false | string | order price type | "limit" by default;"optimal_5", "optimal_10","optimal_20" |
volume | true | long | Numbers of orders (volume) | |
direction | true | string | direction | buy/sell |
offset | false(more see remarks) | string | offset | open,close,both |
lever_rate | false | int | leverage rate | Long leverage shall be equal to short leverage.high leverage has a high risk factor, so please use it with caution. |
Response
Success:
{
"status": "ok",
"data": {
"order_id": 1880,
"order_id_str": "1880"
},
"ts": 1606977456766
}
Error:
{
"status": "error",
"err_code": 1085,
"err_msg": "Trigger order failed, please modify the price and place the order again or contact the customer service.",
"ts": 1606977396756
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
ts | true | long | timestamp | |
<data> | true | object | ||
order_id | true | int | order ID | |
order_id_str | true | string | order id | |
</data> |
[Isolated] Cancel Trigger Order
- POST
/linear-swap-api/v1/swap_trigger_cancel
Remarks
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
request params
field | type | Required | desc |
---|---|---|---|
contract_code | string | true | Case-Insenstive.Both uppercase and lowercase are supported.BTC-USDT... |
order_id | string | true | order id. multiple orderids need to be joined by ",".Max number of order ids is 20 once. |
Response:
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "34",
"err_code": 1061,
"err_msg": "This order doesnt exist."
}
],
"successes": "1"
},
"ts": 1603704887184
}
response
field | Required | type | desc | value range |
---|---|---|---|---|
status | true | string | response status | "ok" , "error" |
<data> | ||||
<errors> | ||||
order_id | true | string | order id | |
err_code | true | int | error code | |
err_msg | true | string | error messages | |
</errors> | ||||
successes | true | string | successful orders | |
</data> | ||||
ts | true | long | response timestamp millseconds |
[Cross] Cancel Trigger Order
- POST
/linear-swap-api/v1/swap_cross_trigger_cancel
Remarks
- The interface only supports cross margin mode.
The frequency limit of this interface is 5 times per second.
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 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 |
order_id | true | string | order id. multiple orderids need to be joined by ",".Max number of order ids is 10 once. |
Response
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "1888",
"err_code": 1061,
"err_msg": "This order doesnt exist."
}
],
"successes": "1880"
},
"ts": 1606977508308
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
<errors> | true | object array | ||
order_id | false | string | order ID | |
err_code | false | int | error code | |
err_msg | false | string | error message | |
</errors> | ||||
successes | true | string | the list order which's successful,joined by "," | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated] Cancel All Trigger Orders
- POST
/linear-swap-api/v1/swap_trigger_cancelall
Remarks
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
Params
field | type | Required | desc |
---|---|---|---|
contract_code | string | true | contract code,"BTC-USDT" ... |
direction | string | false | Transaction direction(if not filled in means all) ["buy" , "sell"] |
offset | string | false | offset direction(if not filled in means all) ["open" , "close"] |
Note
- You can fill in only one of direction and offset to cancel the orders. (such as direction=buy, all buy orders will be cancelled, including "open" and "close" offset)
Response:
{
"status": "ok",
"data": {
"errors": [],
"successes": "2"
},
"ts": 1603704998960
}
response params
field | Required | type | desc | value range |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
<data> | ||||
<errors> | ||||
order_id | true | string | order id | |
err_code | true | int | error code | |
err_msg | true | string | error message | |
</errors> | ||||
successes | true | string | successful orders | |
</data> | ||||
ts | true | long | response timestamp in millseconds |
response error:
{
"status": "error",
"err_code": 1051,
"err_msg": "No orders to cancel.",
"ts": 1603705063592
}
[Cross] Cancel All Trigger Orders
- POST
/linear-swap-api/v1/swap_cross_trigger_cancelall
Remarks
The interface only supports cross margin mode.
The frequency limit of this interface is 5 times per second.
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 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 |
direction | false | string | Transaction direction(if not filled in means all) | ["buy" , "sell"] |
offset | false | string | offset direction(if not filled in means all) | ["open" , "close"] |
Note
- You can fill in only one of direction and offset to cancel the orders. (such as direction=buy, all buy orders will be cancelled, including "open" and "close" offset)
Response
{
"status": "ok",
"data": {
"errors": [],
"successes": "1879,1878"
},
"ts": 1606977712328
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
<errors> | true | object array | ||
order_id | false | string | order ID | |
err_code | false | int | error code | |
err_msg | false | string | error message | |
</errors> | ||||
successes | true | string | the list order which's successful,joined by "," | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated] Query Trigger Order Open Orders
- POST
/linear-swap-api/v1/swap_trigger_openorders
Remarks
- This interface only supports isolated margin mode.
Request Parameter
Parameter Name | Type | Required | Description |
---|---|---|---|
contract_code | string | true | contract code "BTC-USDT"... |
page_index | int | false | page number,default page 1 if no given instruction |
page_size | int | false | default 20 if no given instruction ,no more than 50 |
trade_type | int | false | trade type(Default:all) 0:all,1: buy long,2: sell short,3: buy short,4: sell long, 17:buy(one-way mode), 18:sell(one-way mode) |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"trigger_type": "ge",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "sell",
"offset": "open",
"lever_rate": 10,
"order_id": 4,
"order_id_str": "4",
"order_source": "api",
"trigger_price": 13900.000000000000000000,
"order_price": 13900.000000000000000000,
"created_at": 1603705215654,
"order_price_type": "limit",
"status": 2,
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1603705219567
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
data | true | object | Returned data | |
ts | true | long | Time stamp of response, Unit: millisecond |
- data details
Parameter Name | Type | Required | Description | Value Range |
---|---|---|---|---|
total_page | int | true | total page | |
current_page | int | true | current page | |
total_size | int | true | total size | |
<orders> | ||||
symbol | string | true | Cryptocurrency | |
contract_code | string | true | contract code | |
trigger_type | string | true | trigger type: ge great than or equal to;le less than or equal to |
|
volume | decimal | true | trigger order volume | |
order_type | int | true | Transaction Type 1. Place orders 2. cancel orders | |
direction | string | true | order direction [buy,sell] | |
offset | string | true | offset direction [open,close,both] | |
lever_rate | int | true | Leverage 1\5\10\20 | |
order_id | long | true | trigger order ID | |
order_id_str | string | true | the order ID with string | |
order_source | string | true | order source( system、web、api、m、risk、settlement、ios、android、windows、mac、trigger ) | |
trigger_price | decimal | true | trigger price | |
order_price | decimal | true | the preset price by the client | |
created_at | long | true | order creation time | |
order_price_type | string | true | order price type "limit": limit order,"optimal_5":optimal 5,"optimal_10":optimal 10,"optimal_20":optimal 20 | |
status | int | true | order status:1:ready to submit、2:submited、3:order accepted 、8:canceled orders but not found、9:canceling order、10:failed' | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> |
[Cross] Query Trigger Order Open Orders
- POST
/linear-swap-api/v1/swap_cross_trigger_openorders
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 and contract_code filled in, the contract_code is the preferred. when none any of them, it means to get the all open orders.
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 |
page_index | false | int | page index, default 1st | |
page_size | false | int | page size default 20,no more than 50 | |
trade_type | false | int | trade type(Default:all) | 0:all,1: buy long,2: sell short,3: buy short,4: sell long, 17:buy(one-way mode), 18:sell(one-way mode) |
Response
{
"status": "ok",
"data": {
"orders": [
{
"contract_type": "quarter",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"trigger_type": "le",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "buy",
"offset": "open",
"lever_rate": 1,
"order_id": 918808635214700544,
"order_id_str": "918808635214700544",
"order_source": "api",
"trigger_price": 40000.000000000000000000,
"order_price": 40000.000000000000000000,
"created_at": 1639102649275,
"order_price_type": "limit",
"status": 2,
"margin_mode": "cross",
"margin_account": "USDT",
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1639102667934
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
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"... |
trigger_type | true | string | trigger type: gegreat than or equal to;leless than or equal to | |
volume | true | decimal | place volume | |
order_type | true | int | order type 1. Place orders 2. cancel orders | |
direction | true | string | direction [buy/sell] | |
offset | true | string | offset [open/close,both] | |
lever_rate | true | int | leverage | |
order_id | true | long | order id | |
order_id_str | true | string | order id | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_price | true | decimal | trigger price | |
order_price | true | decimal | order price | |
created_at | true | long | created time | |
order_price_type | true | string | type of order price "limit": limit order,"optimal_5":optimal 5,"optimal_10":optimal 10,"optimal_20":optimal 20 | |
status | true | int | order status:1:ready to submit、2:submited、3:order accepted 、8:canceled orders but not found、9:canceling order、10:failed' | |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated] Query Trigger Order History
- POST
/linear-swap-api/v1/swap_trigger_hisorders
Remarks
- This interface only supports isolated margin mode.
Request:
{
"contract_code": "BTC-USDT",
"create_date": 3,
"trade_type": 0,
"status":"4,6",
"page_index":1,
"page_size":10
}
Request Parameter
Parameter Name | Required | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | Contract Code | BTC-USDT | |
trade_type | true | int | Transaction type | 0: All ,1: Open Long,2: Close Short,3: Open Short,4: Close Long, 17:buy(one-way mode), 18:sell(one-way mode);the system will transfer these parameters into offset and direction and query the requested data. Please note that no data can be requested with parameter out of this range. | |
status | true | string | Order Status | data divided with several commas, trigger orders ready to be submitted:0: All (All filled orders),4: Trigger orders successfully submitted,5: Trigger orders failed being submitted, 6: Trigger orders cancelled | |
create_date | true | int | Date | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. | |
page_index | false | int | Page, 1st page by default without given instruction | 1 | page,1st page by default without given instruction |
page_size | false | int | Page 20 by default without given instruction, ,no more than 50 | 20 | Page 20 by default without given instruction, ,no more than 50 |
sort_by | false | string | sort fields(descending) | created_at | "created_at":descending order by order creation time, "update_time": descending order by order update time |
NOTE
- Default to query completed orders (order status is one of 4, 5, 6);
Response:
{
"status": "ok",
"data": {
"orders": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"trigger_type": "ge",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "sell",
"offset": "open",
"lever_rate": 10,
"order_id": 3,
"order_id_str": "3",
"relation_order_id": "-1",
"order_price_type": "limit",
"status": 6,
"order_source": "api",
"trigger_price": 13900.000000000000000000,
"triggered_price": null,
"order_price": 13900.000000000000000000,
"created_at": 1603705155231,
"update_time": 1603874287699,
"triggered_at": null,
"order_insert_at": 0,
"canceled_at": 1603705159520,
"fail_code": null,
"fail_reason": null,
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"reduce_only": 0
}
],
"total_page": 3,
"current_page": 1,
"total_size": 3
},
"ts": 1603705603369
}
Returning Parameter
Parameter Name | Type | Required | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
data | true | object | Return data | |
ts | true | long | Time of Respond Generation, Unit: Millisecond |
- Data details:
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
total_page | int | true | Total page | |
current_page | int | true | Current page | |
total_size | int | true | Total Size | |
<orders> | ||||
symbol | string | true | symbol | |
contract_code | string | true | Contract Code | |
trigger_type | string | true | trigger: ge Equal to or Greater than;le Less than or Equal to |
|
volume | decimal | true | Numbers of order placed | |
order_type | int | true | Transaction type:1、Place orders 2、Cancel orders | |
direction | string | true | order direction, [Buy (buy), Sell(sell)] | |
offset | string | true | offset direction [Open(open), Close(lose), both] | |
lever_rate | int | true | leverage 1\5\10\20 | |
order_id | long | true | Trigger order ID | |
order_id_str | string | true | the order ID with string | |
relation_order_id | string | true | Relation order ID is the string related to the limit orders The value is -1 before the trigger orders executed. | |
order_price_type | string | true | order type "limit": Limit order price,"optimal_5": Optimal 5 price level,"optimal_10":Optimal 10 price level,"optimal_20": the Optimal 20 price level | |
status | int | true | Order status (4:Orders accepted、5: Orders failing being placed、6: Orders canceled ) | |
order_source | string | true | Order source( system、web、api、m、risk、settlement、ios、android、windows、mac、trigger) | |
trigger_price | decimal | true | trigger price | |
triggered_price | decimal | true | the price when trigger orders executed | |
order_price | decimal | true | the order price preset by the client | |
created_at | long | true | the order creation time | |
triggered_at | long | true | the execution time when orders getting triggered. | |
order_insert_at | long | true | the time when the triggered orders filled successfully. | |
canceled_at | long | true | Order cancelation time | |
update_time | long | true | order update time,millesecond timestamp | |
fail_code | int | true | the error code when the triggered orders failed to be filled | |
fail_reason | string | true | the error message with failure reason when triggered orders failed to filled. | |
margin_mode | string | true | margin mode | isolated : "isolated" |
margin_account | string | true | margin account | "BTC-USDT"... |
reduce_only | int | reduce only | 0: no, 1: yes | |
</orders> |
[Cross] Query Trigger Order History
- POST
/linear-swap-api/v1/swap_cross_trigger_hisorders
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 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 | Value 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 |
trade_type | true | int | trade type | 0: All ,1: Open Long,2: Close Short,3: Open Short,4: Close Long, 17:buy(one-way mode), 18:sell(one-way mode);the system will transfer these parameters into offset and direction and query the requested data. Please note that no data can be requested with parameter out of this range. |
status | true | string | order status | data divided with several commas, trigger orders ready to be submitted:0: All (All filled orders),4: Trigger orders successfully submitted,5: Trigger orders failed being submitted, 6: Trigger orders cancelled |
create_date | true | int | date | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. |
page_index | false | int | page index, default 1st page | page index, default 1st |
page_size | false | int | default 20,no more than 50 | default 20,no more than 50 |
sort_by | false | string | sort fields(Default: “created_at” descending order) | "created_at":descending order by order creation time, "update_time": descending order by order update time |
Notice:
- Default to query completed orders (order status is one of 4, 5, 6);
Response
{
"status": "ok",
"data": {
"orders": [
{
"contract_type": "quarter",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"trigger_type": "le",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "buy",
"offset": "open",
"lever_rate": 1,
"order_id": 918808635214700544,
"order_id_str": "918808635214700544",
"relation_order_id": "-1",
"order_price_type": "limit",
"status": 6,
"order_source": "api",
"trigger_price": 40000.000000000000000000,
"triggered_price": null,
"order_price": 40000.000000000000000000,
"created_at": 1639102649275,
"triggered_at": null,
"order_insert_at": 0,
"canceled_at": 1639103205980,
"fail_code": null,
"fail_reason": null,
"margin_mode": "cross",
"margin_account": "USDT",
"update_time": 1639103206083,
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1639103213233
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | "ok" , "error" |
<data> | true | object | ||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
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"... |
trigger_type | true | string | trigger type: ge: Equal to or Greater than;le: Less than or Equal to | |
volume | true | decimal | place volume | |
order_type | true | int | order type:1、Place orders 2、Cancel orders | |
direction | true | string | direction [buy/sell] | |
offset | true | string | offset [open,close,both] | |
lever_rate | true | int | leverage | |
order_id | true | long | order id | |
order_id_str | true | string | order id | |
relation_order_id | true | string | relation order ID is the string related to the limit orders The value is -1 before the trigger orders executed | |
order_price_type | true | string | order type "limit": Limit order price,"optimal_5": Optimal 5 price level,"optimal_10":Optimal 10 price level,"optimal_20": the Optimal 20 price level | |
status | true | int | status (4:Orders accepted、5: Orders failing being placed、6: Orders canceled ) | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_price | true | decimal | trigger price | |
triggered_price | true | decimal | triggered price | |
order_price | true | decimal | order price | |
created_at | true | long | created time | |
update_time | true | long | order update time,millesecond timestamp | |
triggered_at | true | long | trigger time | |
order_insert_at | true | long | insert time | |
canceled_at | true | long | canceled time | |
fail_code | true | int | fail code | |
fail_reason | true | string | fail reason | |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated]Set a Take-profit and Stop-loss Order for an Existing Position
- POST
/linear-swap-api/v1/swap_tpsl_order
Note:
- All take-profit and stop-loss orders are position closing orders.
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
- Fill in at least one of the take-profit trigger price(tp_trigger_price) and stop-loss trigger price(sl_trigger_price). If all the trigger price is not filled in, this type of take-profit and stop-loss order will not be placed.
Request
{
"contract_code": "btc-usdt",
"direction": "sell",
"volume": 1,
"tp_trigger_price": 32000,
"tp_order_price": 32000,
"tp_order_price_type": "optimal_5",
"sl_trigger_price": "29000",
"sl_order_price": "29000",
"sl_order_price_type": "optimal_5"
}
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | BTC-USDT |
direction | true | string | direction | "buy", "sell" |
volume | true | decimal | Numbers of orders (volume) | |
tp_trigger_price | false | decimal | Trigger price of take-profit order | |
tp_order_price | false | decimal | Order price of take-profit order(The order price is not required to fill in for Optimal N) | |
tp_order_price_type | false | string | Order type of take-profit order | default is market; market,limit,optimal_5,optimal_10,optimal_20 |
sl_trigger_price | false | decimal | Trigger price of stop-loss order | |
sl_order_price | false | decimal | Order price of stop-loss order(The order price is not required to fill in for Optimal N) | |
sl_order_price_type | false | string | Order type of stop-loss order | default is market; market,limit,optimal_5,optimal_10,optimal_20 |
Response
{
"status": "ok",
"data": {
"tp_order": {
"order_id": 795713650661638144,
"order_id_str": "795713650661638144"
},
"sl_order": {
"order_id": 795713650665832448,
"order_id_str": "795713650665832448"
}
},
"ts": 1609754517975
}
Error Response
{
"status": "error",
"err_code": 1066,
"err_msg": "contract_code cannot be empty.",
"ts": 1604369954194
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
ts | true | long | time stamp | |
<data> | false | object | Returned data when order is placed successfully, and will not be returned when order fails to be placed. | |
<tp_order> | true | object | Order placing result of take-profit order | |
order_id | true | long | order id | |
order_id_str | true | string | order id (string) | |
</tp_order> | ||||
<sl_order> | true | object | Order placing result of stop-loss order | |
order_id | true | long | order id | |
order_id_str | true | string | order id (string) | |
</sl_order> | ||||
</data> | ||||
err_code | false | int | error code(only when order fails to be placed) | |
err_msg | false | string | error message(only when order fails to be placed) |
Note
- When only take-profit order or stop-loss order is set , the accordingly returned "sl_order" or "tp_order" will be empty.
[Cross]Set a Take-profit and Stop-loss Order for an Existing Position
- POST
/linear-swap-api/v1/swap_cross_tpsl_order
Note
- All take-profit and stop-loss orders are position closing orders.
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
- Fill in at least one of the take-profit trigger price(tp_trigger_price) and stop-loss trigger price(sl_trigger_price). If all the trigger price is not filled in, this type of take-profit and stop-loss order will not be placed.
- 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": "sell",
"volume": 1,
"tp_trigger_price": 32000,
"tp_order_price": 32000,
"tp_order_price_type": "optimal_5",
"sl_trigger_price": "29000",
"sl_order_price": "29000",
"sl_order_price_type": "optimal_5"
}
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
direction | true | string | direction | "buy", "sell" |
volume | true | decimal | Numbers of orders (volume) | |
tp_trigger_price | false | decimal | Trigger price of take-profit order | |
tp_order_price | false | decimal | Order price of take-profit order(The order price is not required to fill in for Optimal N) | |
tp_order_price_type | false | string | Order type of take-profit order | default is market; market,limit,optimal_5,optimal_10,optimal_20 |
sl_trigger_price | false | decimal | Trigger price of stop-loss order | |
sl_order_price | false | decimal | Order price of stop-loss order(The order price is not required to fill in for Optimal N) | |
sl_order_price_type | false | string | Order type of stop-loss order | default is market; market,limit,optimal_5,optimal_10,optimal_20 |
Note:
- All take-profit and stop-loss orders are position closing orders.
Response
{
"status": "ok",
"data": {
"tp_order": {
"order_id": 795714078698749952,
"order_id_str": "795714078698749952"
},
"sl_order": {
"order_id": 795714078698749953,
"order_id_str": "795714078698749953"
}
},
"ts": 1609754620038
}
Error Response
{
"status": "error",
"err_code": 1066,
"err_msg": "contract_code cannot be empty.",
"ts": 1604369954194
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok" , "error" |
ts | true | long | time stamp | |
<data> | false | object | Returned data when order is placed successfully, and will not be returned when order fails to be placed. | |
<tp_order> | true | object | Order placing result of take-profit order | |
order_id | true | long | order id | |
order_id_str | true | string | order id (string) | |
</tp_order> | ||||
<sl_order> | true | object | Order placing result of stop-loss order | |
order_id | true | long | order id | |
order_id_str | true | string | order id (string) | |
</sl_order> | ||||
</data> | ||||
err_code | false | int | error code(only when order fails to be placed) | |
err_msg | false | string | error message(only when order fails to be placed) |
Note
- When only take-profit order or stop-loss order is set , the accordingly returned "sl_order" or "tp_order" will be empty.
[Isolated]Cancel a Take-profit and Stop-loss Order
- POST
/linear-swap-api/v1/swap_tpsl_cancel
Note
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "BTC-USDT" ... |
order_id | true | string | order ID(different IDs are separated by ",", maximum 10 orders can be withdrew at one time) |
Response
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "795713650661638145",
"err_code": 1061,
"err_msg": "This order doesnt exist."
}
],
"successes": "795713650661638144"
},
"ts": 1609754722004
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | order id | |
err_code | false | long | error code | |
err_msg | false | string | error message | |
</errors> | ||||
successes | true | string | successes orders | |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Cross]Cancel a Take-profit and Stop-loss Order
- POST
/linear-swap-api/v1/swap_cross_tpsl_cancel
Note
- This interface only supports cross margin mode.
- The frequency limit of this interface is 5 times per second.
- 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 | Description | Value 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 |
order_id | true | string | order ID(different IDs are separated by ",", maximum 10 orders can be withdrew at one time) |
Response
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "795714078698749956",
"err_code": 1061,
"err_msg": "This order doesnt exist."
}
],
"successes": "795714078698749952"
},
"ts": 1609754775942
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | order id | |
err_code | false | long | error code | |
err_msg | false | string | error message | |
</errors> | ||||
successes | true | string | successes orders | |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Isolated]Cancel all Take-profit and Stop-loss Orders
- POST
/linear-swap-api/v1/swap_tpsl_cancelall
Note
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "BTC-USDT" ... |
direction | false | string | direction false string direction(if not filled in means all) | ["buy", "sell"] |
Response
{
"status": "ok",
"data": {
"errors": [],
"successes": "795713650665832448,795714964661583872,795714964661583873"
},
"ts": 1609754843671
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | order id | |
err_code | false | long | error code | |
err_msg | false | string | error message | |
</errors> | ||||
successes | true | string | successes orders | |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Cross]Cancel all Take-profit and Stop-loss Orders
- POST
/linear-swap-api/v1/swap_cross_tpsl_cancelall
Note
This interface only supports cross margin mode.
The frequency limit of this interface is 5 times per second.
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 | Description | Value 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 |
direction | false | string | direction false string direction(if not filled in means all) | ["buy", "sell"] |
Response
{
"status": "ok",
"data": {
"errors": [],
"successes": "795714078698749953,795715192882053120,795715192886247424"
},
"ts": 1609754894463
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | order id | |
err_code | false | long | error code | |
err_msg | false | string | error message | |
</errors> | ||||
successes | true | string | successes orders | |
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Isolated]Query Open Take-profit and Stop-loss Orders
- POST
/linear-swap-api/v1/swap_tpsl_openorders
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" ... |
page_index | false | int | page index. 1 by default | |
page_size | false | int | page size.20 by default. 50 at most | |
trade_type | false | int | trade type(Default:all) | 0:all,3: buy short,4: sell long |
Response
{
"status": "ok",
"data": {
"orders": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"volume": 1,
"order_type": 1,
"direction": "buy",
"order_id": 795715396674895872,
"order_id_str": "795715396674895872",
"order_source": "api",
"trigger_type": "le",
"trigger_price": 27000,
"order_price": 0,
"created_at": 1609754934244,
"order_price_type": "optimal_5",
"status": 2,
"tpsl_order_type": "tp",
"source_order_id": "795715396666507264",
"relation_tpsl_order_id": "795715396674895873"
}
],
"total_page": 4,
"current_page": 1,
"total_size": 4
},
"ts": 1609755183516
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_mode | true | string | margin mode | cross, isolated |
margin_account | true | string | margin account | such as “USDT”,“BTC-USDT” |
volume | true | decimal | Numbers of orders (volume) | |
order_type | true | int | Order type: 1. Quotation; 2. Cancelled order | |
tpsl_order_type | true | string | Order type(take-profit order/stop-loss order) | “tp”:take-profit order;"sl"stop-loss order |
direction | true | string | direction | "buy", "sell" |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_type | true | string | trigger type: ge, le | |
trigger_price | true | decimal | trigger price | |
created_at | true | long | created time | |
order_price_type | true | string | order price type | market,limit, optimal_5, optimal_10, optimal_20 |
order_price | true | decimal | order price | |
status | true | int | status: | 1.Not Activated, 2.Ready to submit the orders, 3.Submitting the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled, 8.Cancelled order not found, 9.Orders cancelling, 10.Failed, 11.Expired |
source_order_id | true | string | Order id of source limit order (the field will have a value only when the order placed is a take-profit and stop-loss order; it is used to indicate that a certain limit order that triggered current take-profit and stop-loss order.) | |
relation_tpsl_order_id | true | string | related take-profit and stop loss order id(The field will have a value when users set take-profit and stop loss order stimulatenously, otherwise, the value will be "-1".) | |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Cross]Query Open Take-profit and Stop-loss Orders
- POST
/linear-swap-api/v1/swap_cross_tpsl_openorders
Note
This 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 all of pair and contract_code filled in, the contract_code is the preferred; when no one filled in, return all data in cross mode.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
page_index | false | int | page index. 1 by default | |
page_size | false | int | page size.20 by default. 50 at most | |
trade_type | false | int | trade type(Default:all) | 0:all,3: buy short,4: sell long |
Response
{
"status": "ok",
"data": {
"orders": [
{
"contract_type": "this_week",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_mode": "cross",
"margin_account": "USDT",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "sell",
"order_id": 918816985859559425,
"order_id_str": "918816985859559425",
"order_source": "api",
"trigger_type": "le",
"trigger_price": 40000.000000000000000000,
"order_price": 0E-18,
"created_at": 1639104640223,
"order_price_type": "optimal_5",
"status": 2,
"tpsl_order_type": "sl",
"source_order_id": null,
"relation_tpsl_order_id": "918816985859559424"
},
{
"contract_type": "this_week",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_mode": "cross",
"margin_account": "USDT",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "sell",
"order_id": 918816985859559424,
"order_id_str": "918816985859559424",
"order_source": "api",
"trigger_type": "ge",
"trigger_price": 50000.000000000000000000,
"order_price": 0E-18,
"created_at": 1639104640223,
"order_price_type": "optimal_5",
"status": 2,
"tpsl_order_type": "tp",
"source_order_id": null,
"relation_tpsl_order_id": "918816985859559425"
}
],
"total_page": 1,
"current_page": 1,
"total_size": 2
},
"ts": 1639104794491
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross, isolated |
margin_account | true | string | margin account | such as “USDT”,“BTC-USDT” |
volume | true | decimal | Numbers of orders (volume) | |
order_type | true | int | Order type: 1. Quotation; 2. Cancelled order | |
tpsl_order_type | true | string | Order type(take-profit order/stop-loss order) | “tp”:take-profit order;"sl"stop-loss order |
direction | true | string | direction | "buy", "sell" |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_type | true | string | trigger type: ge, le | |
trigger_price | true | decimal | trigger price | |
created_at | true | long | created time | |
order_price_type | true | string | order price type | market,limit, optimal_5, optimal_10, optimal_20 |
order_price | true | decimal | order price | |
status | true | int | status: | 1.Not Activated, 2.Ready to submit the orders, 3.Submitting the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled, 8.Cancelled order not found, 9.Orders cancelling, 10.Failed, 11.Expired |
source_order_id | true | string | Order id of source limit order (the field will have a value only when the order placed is a take-profit and stop-loss order; it is used to indicate that a certain limit order that triggered current take-profit and stop-loss order.) | |
relation_tpsl_order_id | true | string | related take-profit and stop loss order id(The field will have a value when users set take-profit and stop loss order stimulatenously, otherwise, the value will be "-1".) | |
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 |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Isolated]Query Take-profit and Stop-loss History Orders
- POST
/linear-swap-api/v1/swap_tpsl_hisorders
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" ... |
status | true | string | status | Multiple orders are separated by English commas, and the status of stop-profit and stop-loss orders is: 0:all(representing all orders in the end state), 4:Have sumbmitted the orders, 5:orders failed, 6:orders canceled, 11:expired |
create_date | true | long | days | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. |
page_index | false | int | page index. 1 by default | |
page_size | false | int | page size.20 by default. 50 at most | |
sort_by | false | string | for sortting, descende order by created_at when without value | "created_at": descending order by order created at, "update_time": descending order by order update time |
Response
{
"status": "ok",
"data": {
"orders": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"volume": 1,
"order_type": 1,
"tpsl_order_type": "sl",
"direction": "sell",
"order_id": 795714964661583873,
"order_id_str": "795714964661583873",
"order_source": "api",
"trigger_type": "le",
"trigger_price": 29000,
"created_at": 1609754831244,
"order_price_type": "optimal_5",
"status": 6,
"source_order_id": null,
"relation_tpsl_order_id": "795714964661583872",
"canceled_at": 1609754844420,
"fail_code": null,
"fail_reason": null,
"triggered_price": null,
"relation_order_id": "-1",
"update_time": 1609754850018,
"order_price": 0
}
],
"total_page": 17,
"current_page": 1,
"total_size": 17
},
"ts": 1609756931689
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_mode | true | string | margin mode | cross, isolated |
margin_account | true | string | margin account | such as “USDT”,“BTC-USDT” |
volume | true | decimal | Numbers of orders (volume) | |
order_type | true | int | Order type: 1. Quotation; 2. Cancelled order | |
tpsl_order_type | true | string | Order type(take-profit order/stop-loss order) | “tp”:take-profit order;"sl"stop-loss order |
direction | true | string | direction | "buy", "sell" |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_type | true | string | trigger type: ge, le | |
trigger_price | true | decimal | trigger price | |
created_at | true | long | created time | |
order_price_type | true | string | order price type | market,limit, optimal_5, optimal_10, optimal_20 |
order_price | true | decimal | order price | |
status | true | int | status: | 1.Not Activated, 2.Ready to submit the orders, 3.Submitting the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled, 8.Cancelled order not found, 9.Orders cancelling, 10.Failed, 11.Expired |
source_order_id | true | string | Order id of source limit order (the field will have a value only when the order placed is a take-profit and stop-loss order; it is used to indicate that a certain limit order that triggered current take-profit and stop-loss order.) | |
relation_tpsl_order_id | true | string | related take-profit and stop loss order id(The field will have a value when users set take-profit and stop loss order stimulatenously, otherwise, the value will be "-1".) | |
canceled_at | true | long | canceled time | |
fail_code | true | int | fail code when triggered | |
fail_reason | true | string | fail reason when triggered | |
triggered_price | true | decimal | triggered price | |
relation_order_id | true | string | Relation order ID is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
update_time | true | long | update time, unit: Millisecond | |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Cross]Query Take-profit and Stop-loss History Orders
- POST
linear-swap-api/v1/swap_cross_tpsl_hisorders
Note
This 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 and contract_code must be filled in(if both of them not filled in, will get 1014 error code); and both filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
status | true | string | status | Multiple orders are separated by English commas, and the status of stop-profit and stop-loss orders is: 0:all(representing all orders in the end state), 4:Have sumbmitted the orders, 5:orders failed, 6:orders canceled, 11:expired |
create_date | true | long | days | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. |
page_index | false | int | page index. 1 by default | |
page_size | false | int | page size.20 by default. 50 at most | |
sort_by | false | string | for sortting, descende order by created_at when without value | "created_at": descending order by order created at, "update_time": descending order by order update time |
Response
{
"status": "ok",
"data": {
"orders": [
{
"contract_type": "this_week",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_mode": "cross",
"margin_account": "USDT",
"volume": 1.000000000000000000,
"order_type": 1,
"tpsl_order_type": "tp",
"direction": "sell",
"order_id": 918816985859559424,
"order_id_str": "918816985859559424",
"order_source": "api",
"trigger_type": "ge",
"trigger_price": 50000.000000000000000000,
"created_at": 1639104640223,
"order_price_type": "optimal_5",
"status": 6,
"source_order_id": null,
"relation_tpsl_order_id": "918816985859559425",
"canceled_at": 1639104933147,
"fail_code": null,
"fail_reason": null,
"triggered_price": null,
"relation_order_id": "-1",
"update_time": 1639104933172,
"order_price": 0E-18
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1639104940769
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross, isolated |
margin_account | true | string | margin account | such as “USDT”,“BTC-USDT” |
volume | true | decimal | Numbers of orders (volume) | |
order_type | true | int | Order type: 1. Quotation; 2. Cancelled order | |
tpsl_order_type | true | string | Order type(take-profit order/stop-loss order) | “tp”:take-profit order;"sl"stop-loss order |
direction | true | string | direction | "buy", "sell" |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_type | true | string | trigger type: ge, le | |
trigger_price | true | decimal | trigger price | |
created_at | true | long | created time | |
order_price_type | true | string | order price type | market,limit, optimal_5, optimal_10, optimal_20 |
order_price | true | decimal | order price | |
status | true | int | status: | 1.Not Activated, 2.Ready to submit the orders, 3.Submitting the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled, 8.Cancelled order not found, 9.Orders cancelling, 10.Failed, 11.Expired |
source_order_id | true | string | Order id of source limit order (the field will have a value only when the order placed is a take-profit and stop-loss order; it is used to indicate that a certain limit order that triggered current take-profit and stop-loss order.) | |
relation_tpsl_order_id | true | string | related take-profit and stop loss order id(The field will have a value when users set take-profit and stop loss order stimulatenously, otherwise, the value will be "-1".) | |
canceled_at | true | long | canceled time | |
fail_code | true | int | fail code when triggered | |
fail_reason | true | string | fail reason when triggered | |
triggered_price | true | decimal | triggered price | |
relation_order_id | true | string | Relation order ID is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
update_time | true | long | update time, unit: Millisecond | |
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 |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Isolated]Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order
- POST
/linear-swap-api/v1/swap_relation_tpsl_order
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" ... |
order_id | true | long | order id |
Response
{
"status": "ok",
"data": {
"symbol": "BTC",
"contract_code": "BTC-USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"volume": 1,
"price": 29999,
"order_price_type": "opponent",
"direction": "buy",
"offset": "open",
"lever_rate": 75,
"order_id": 795947785812557824,
"order_id_str": "795947785812557824",
"client_order_id": null,
"created_at": 1609810340126,
"trade_volume": 1,
"trade_turnover": 29.999,
"fee": -0.01619946,
"trade_avg_price": 29999,
"margin_frozen": 0,
"profit": 0,
"status": 6,
"order_type": 1,
"order_source": "api",
"fee_asset": "USDT",
"canceled_at": 0,
"tpsl_order_info": [
{
"volume": 1,
"direction": "sell",
"tpsl_order_type": "tp",
"order_id": 795947785820946432,
"order_id_str": "795947785820946432",
"trigger_type": "ge",
"trigger_price": 31000,
"order_price": 0,
"created_at": 1609810340134,
"order_price_type": "optimal_5",
"relation_tpsl_order_id": "795947785820946433",
"status": 1,
"canceled_at": 0,
"fail_code": null,
"fail_reason": null,
"triggered_price": null,
"relation_order_id": "-1"
},
{
"volume": 1,
"direction": "sell",
"tpsl_order_type": "sl",
"order_id": 795947785820946433,
"order_id_str": "795947785820946433",
"trigger_type": "le",
"trigger_price": 29100,
"order_price": 0,
"created_at": 1609810340134,
"order_price_type": "optimal_5",
"relation_tpsl_order_id": "795947785820946432",
"status": 1,
"canceled_at": 0,
"fail_code": null,
"fail_reason": null,
"triggered_price": null,
"relation_order_id": "-1"
}
]
},
"ts": 1609810352828
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | "BTC180914" ... |
margin_mode | true | string | margin mode | cross, isolated |
margin_account | true | string | margin account | such as “USDT”,“BTC-USDT” |
volume | true | decimal | Numbers of orders (volume) | |
price | true | decimal | price | |
order_price_type | true | string | order price type | "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 |
direction | true | string | direction | "buy","sell" |
offset | true | string | offset | "open", "close", "both" |
lever_rate | true | int | lever rate | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
client_order_id | true | long | client order id | |
created_at | true | long | created at | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
order_source | true | string | order source | system. web. api. m. risk. settlement. ios. android. windows. mac. trigger |
fee_asset | true | string | fee asset | ("BTC","ETH"...) |
canceled_at | true | long | canceled at | |
<tpsl_order_info> | true | object array | related take-profit and stop loss order info | |
volume | true | decimal | Numbers of orders (volume) | |
tpsl_order_type | true | string | Order type(take-profit order/stop-loss order) | “tp”:take-profit order;"sl"stop-loss order |
direction | true | string | direction | "buy", "sell" |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
trigger_type | true | string | trigger type: ge, le | |
trigger_price | true | decimal | trigger price | |
created_at | true | long | created time | |
order_price_type | true | string | order price type | limit, optimal_5, optimal_10, optimal_20 |
order_price | true | decimal | order price | |
status | true | int | status | 1.Not Activated, 2.Ready to submit the orders, 3.Submitting the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled, 8.Cancelled order not found, 9.Orders cancelling, 10.Failed, 11.Expired. 12. Not Activated-Expired |
relation_tpsl_order_id | true | string | related take-profit and stop loss order id(The field will have a value when users set take-profit and stop loss order stimulatenously, otherwise, the value will be "-1".) | |
canceled_at | true | long | canceled time | |
fail_code | true | int | fail code when triggered | |
fail_reason | true | string | fail reason when triggered | |
triggered_price | true | decimal | triggered price | |
relation_order_id | true | string | Relation order ID is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
</tpsl_order_info> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Cross]Query Info Of Take-profit and Stop-loss Order That Related To Position Opening Order
- POST
/linear-swap-api/v1/swap_cross_relation_tpsl_order
Note
This 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 and contract_code must be filled in(if both of them not filled in, will get 1014 error code); and both filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
order_id | true | long | open order id |
Response
{
"status": "ok",
"data": {
"contract_type": "this_week",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"margin_mode": "cross",
"margin_account": "USDT",
"volume": 1,
"price": 48592.2,
"order_price_type": "opponent",
"direction": "buy",
"offset": "open",
"lever_rate": 5,
"order_id": 918819004716982272,
"order_id_str": "918819004716982272",
"client_order_id": null,
"created_at": 1639105121550,
"trade_volume": 1,
"trade_turnover": 48.592200000000000000,
"fee": -0.024296100000000000,
"trade_avg_price": 48592.200000000000000000,
"margin_frozen": 0E-18,
"profit": 0,
"status": 6,
"order_type": 1,
"order_source": "api",
"fee_asset": "USDT",
"canceled_at": 0,
"tpsl_order_info": [
{
"volume": 1.000000000000000000,
"direction": "sell",
"tpsl_order_type": "tp",
"order_id": 918819004746342400,
"order_id_str": "918819004746342400",
"trigger_type": "ge",
"trigger_price": 50000.000000000000000000,
"order_price": 0E-18,
"created_at": 1639105121563,
"order_price_type": "optimal_5",
"relation_tpsl_order_id": "918819004750536704",
"status": 2,
"canceled_at": 0,
"fail_code": null,
"fail_reason": null,
"triggered_price": null,
"relation_order_id": "-1"
},
{
"volume": 1.000000000000000000,
"direction": "sell",
"tpsl_order_type": "sl",
"order_id": 918819004750536704,
"order_id_str": "918819004750536704",
"trigger_type": "le",
"trigger_price": 40000.000000000000000000,
"order_price": 0E-18,
"created_at": 1639105121564,
"order_price_type": "optimal_5",
"relation_tpsl_order_id": "918819004746342400",
"status": 2,
"canceled_at": 0,
"fail_code": null,
"fail_reason": null,
"triggered_price": null,
"relation_order_id": "-1"
}
]
},
"ts": 1639105149621
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | status | "ok", "error" |
<data> | true | object | dictionary | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
margin_mode | true | string | margin mode | cross, isolated |
margin_account | true | string | margin account | such as “USDT”,“BTC-USDT” |
volume | true | decimal | Numbers of orders (volume) | |
price | true | decimal | price | |
order_price_type | true | string | order price type | "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 |
direction | true | string | direction | "buy","sell" |
offset | true | string | offset | "open", "close", "both" |
lever_rate | true | int | lever rate | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
client_order_id | true | long | client order id | |
created_at | true | long | created at | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
order_source | true | string | order source | system. web. api. m. risk. settlement. ios. android. windows. mac. trigger |
fee_asset | true | string | fee asset | ("BTC","ETH"...) |
canceled_at | true | long | canceled at | |
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 |
<tpsl_order_info> | true | object array | related take-profit and stop loss order info | |
volume | true | decimal | Numbers of orders (volume) | |
tpsl_order_type | true | string | Order type(take-profit order/stop-loss order) | “tp”:take-profit order;"sl"stop-loss order |
direction | true | string | direction | "buy", "sell" |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
trigger_type | true | string | trigger type: ge, le | |
trigger_price | true | decimal | trigger price | |
created_at | true | long | created time | |
order_price_type | true | string | order price type | limit, optimal_5, optimal_10, optimal_20 |
order_price | true | decimal | order price | |
status | true | int | status | 1.Not Activated, 2.Ready to submit the orders, 3.Submitting the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled, 8.Cancelled order not found, 9.Orders cancelling, 10.Failed, 11.Expired. 12. Not Activated-Expired |
relation_tpsl_order_id | true | string | related take-profit and stop loss order id(The field will have a value when users set take-profit and stop loss order stimulatenously, otherwise, the value will be "-1".) | |
canceled_at | true | long | canceled time | |
fail_code | true | int | fail code when triggered | |
fail_reason | true | string | fail reason when triggered | |
triggered_price | true | decimal | triggered price | |
relation_order_id | true | string | Relation order ID is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
</tpsl_order_info> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation,Unit: Millisecond |
[Isolated]Place a Trailing Order
- POST
/linear-swap-api/v1/swap_track_order
Note
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | BTC-USDT |
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 |
direction | true | string | direction | buy, sell |
offset | false(more see remarks) | string | offset | open, close, both |
lever_rate | false | int | lever rate, is required when open position, is optional when close position | |
volume | true | decimal | volume(cont) | |
callback_rate | true | decimal | callback rate | Such as: 0.01 means 1%. And must be not less than 0.001 (0.1%) |
active price | true | decimal | active price | |
order_price_type | true | string | order price type | optimal_5, optimal_10, optimal_20, formula_price |
Note
- When order_price_type is the formula_price, it means that after the tracking order is triggered successfully, use the lowest (highest) market price *(1 ± callback rate) that from statistic since place trading order, as the order price (the precision is the minimum variation of the contract price and be truncated) to place a limit price order
- whether filled in with the optimal N or the formula price, there is no guarantee that the order can be completely filled, which mainly depends on the market conditions.
- 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.
- please note that, in the one-way mode, if using the parameter reduce_only=1 to place an order for opening positions, when the order triggered, it will respond error message: 1492 Amount of Reduce Only order exceeds the amount available to close. order will be failed.
Response:
{
"status": "ok",
"data": {
"order_id": 826052268312821760,
"order_id_str": "826052268312821760"
},
"ts": 1616987808080
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" , "error" |
ts | true | long | timestamp | |
<data> | true | object | the returned data which is successful | |
order_id | true | long | trailing order id[Globally Unique] | |
order_id_str | true | string | trailing order id in string format | |
</data> |
[Cross]Place a Trailing Order
- POST
/linear-swap-api/v1/swap_cross_track_order
Note:
The interface only supports cross margin mode.
The frequency limit of this interface is 5 times per second.
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; and all filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
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 |
direction | true | string | direction | buy, sell |
offset | false(more see remarks) | string | offset | open, close, both |
lever_rate | false | int | lever rate, is required when open position, is optional when close position | |
volume | true | decimal | volume(cont) | |
callback_rate | true | decimal | callback rate | Such as: 0.01 means 1%. And must be not less than 0.001 (0.1%) |
active price | true | decimal | active price | |
order_price_type | true | string | order price type | optimal_5, optimal_10, optimal_20, formula_price |
Note
- When order_price_type is the formula_price, it means that after the tracking order is triggered successfully, use the lowest (highest) market price *(1 ± callback rate) that from statistic since place trading order, as the order price (the precision is the minimum variation of the contract price and be truncated) to place a limit price order
- whether filled in with the optimal N or the formula price, there is no guarantee that the order can be completely filled, which mainly depends on the market conditions.
- 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.
- please note that, in the one-way mode, if using the parameter reduce_only=1 to place an order for opening positions, when the order triggered, it will respond error message: 1492 Amount of Reduce Only order exceeds the amount available to close. order will be failed.
Response:
{
"status": "ok",
"data": {
"order_id": 826052906719444992,
"order_id_str": "826052906719444992"
},
"ts": 1616987960287
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" , "error" |
ts | true | long | timestamp | |
<data> | true | object | the returned data which is successful | |
order_id | true | long | trailing order id[Globally Unique] | |
order_id_str | true | string | trailing order id in string format | |
</data> |
[Isolated]Cancel a Trailing Order
- POST
/linear-swap-api/v1/swap_track_cancel
Note:
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | BTC-USDT |
order_id | true | string | User's trailing order id (multiple order IDs are separated by ",", a maximum of 10 orders are allowed to be withdrawn at a time) |
Response:
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "826052268312821761",
"err_code": 1061,
"err_msg": "This order doesnt exist."
}
],
"successes": "826052268312821760"
},
"ts": 1616988039695
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | trailing order id[Globally Unique] | |
err_code | false | long | error code | |
err_msg | false | string | error msg | |
</errors> | ||||
successes | true | string | the orders that are success | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross]Cancel a Trailing Order
- POST
/linear-swap-api/v1/swap_cross_track_cancel
Note:
The interface only supports cross margin mode.
The frequency limit of this interface is 5 times per second.
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; and all filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
order_id | true | string | User's trailing order id (multiple order IDs are separated by ",", a maximum of 10 orders are allowed to be withdrawn at a time) |
Response:
{
"status": "ok",
"data": {
"errors": [
{
"order_id": "826052906719444993",
"err_code": 1061,
"err_msg": "This order doesnt exist."
}
],
"successes": "826053970168446976"
},
"ts": 1616988232517
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | trailing order id[Globally Unique] | |
err_code | false | long | error code | |
err_msg | false | string | error msg | |
</errors> | ||||
successes | true | string | the orders that are success | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated]Cancel All Trailing Orders
- POST
/linear-swap-api/v1/swap_track_cancelall
Note:
- This interface only supports isolated margin mode.
- The frequency limit of this interface is 5 times per second.
- You can fill in only one of direction and offset to cancel the orders. (such as direction=buy, all buy orders will be cancelled, including "open" and "close" offset)
### Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | BTC-USDT |
direction | false | string | direction(if not filled in as all) | buy, sell |
offset | false | string | offset(if not filledin as all) | open, close |
Response:
{
"status": "ok",
"data": {
"errors": [],
"successes": "826054603831312384,826054608491184128,826054686706565120"
},
"ts": 1616988392280
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | trailing order id[Globally Unique] | |
err_code | false | long | error code | |
err_msg | false | string | error msg | |
</errors> | ||||
successes | true | string | the orders that are success | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross]Cancel All Trailing Orders
- POST
/linear-swap-api/v1/swap_cross_track_cancelall
Note:
- The interface only supports cross margin mode.
- The frequency limit of this interface is 5 times per second.
- You can fill in only one of direction and offset to cancel the orders. (such as direction=buy, all buy orders will be cancelled, including "open" and "close" offset)
- 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 | Description | Value 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 |
direction | false | string | direction(if not filled in, means all) | buy, sell |
offset | false | string | offset (if not filled in, means all) | open, close |
Response:
{
"status": "ok",
"data": {
"errors": [],
"successes": "826054813483597824,826054818734866432,826054867657228288"
},
"ts": 1616988442893
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
<errors> | true | object | dictionary | |
order_id | true | string | trailing order id[Globally Unique] | |
err_code | false | long | error code | |
err_msg | false | string | error msg | |
</errors> | ||||
successes | true | string | the orders that are success | |
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated]Current unfilled trailing order acquisition
- POST
/linear-swap-api/v1/swap_track_openorders
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 |
trade_type | false | int | trade type(if not filled in, means all) | 0:all,1: buy long,2: sell short,3: buy short,4: sell long, 17:buy(one-way mode), 18:sell(one-way mode) |
page_index | false | int | page index, if not filled in as 1st | |
page_size | false | int | if not filled in as 20, and no more than 50 |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "buy",
"offset": "open",
"lever_rate": 5,
"order_id": 826055066114916352,
"order_id_str": "826055066114916352",
"order_source": "api",
"created_at": 1616988475122,
"order_price_type": "formula_price",
"status": 2,
"callback_rate": 0.030000000000000000,
"active_price": 48888.000000000000000000,
"is_active": 0,
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1616988497109
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | BTC-USDT |
volume | true | decimal | volume | |
order_type | true | int | order type: 1. Quotation; 2. Cancelled order | |
direction | true | string | direction | buy, sell |
offset | true | string | offset | open, close, both |
lever_rate | true | int | lever rate | |
order_id | true | long | trailing order id | |
order_id_str | true | string | trailing order id in string format | |
order_source | true | string | order source | |
created_at | true | long | created at | |
order_price_type | true | string | order price type | optimal_5, optimal_10, optimal_20, formula_price |
status | true | int | order status | 2.Ready to submit the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled |
callback_rate | true | decimal | callback rate | such as: 0.01 means 1% |
active price | true | decimal | active price | |
is_active | true | int | Is the active price activated? | 1: activated; 0: not activated |
margin_mode | true | string | margin mode | isolated |
margin_account | true | string | margin account | e.g:“BTC-USDT” |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross]Current unfilled trailing order acquisition
- POST
/linear-swap-api/v1/swap_cross_track_openorders
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 and contract_code filled in, the contract_code is the preferred. if none of them filled in, it means all open orders.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false | string | pair | BTC-USDT |
trade_type | false | int | trade type(if not filled in, means all) | 0:all,1: buy long,2: sell short,3: buy short,4: sell long, 17:buy(one-way mode), 18:sell(one-way mode) |
page_index | false | int | page index, if not filled in as 1st | |
page_size | false | int | if not filled in as 20, and no more than 50 |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"contract_type": "quarter",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "buy",
"offset": "open",
"lever_rate": 1,
"order_id": 918819679173152768,
"order_id_str": "918819679173152768",
"order_source": "api",
"created_at": 1639105282359,
"order_price_type": "formula_price",
"status": 2,
"callback_rate": 0.030000000000000000,
"active_price": 41111.000000000000000000,
"is_active": 0,
"margin_mode": "cross",
"margin_account": "USDT",
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1639105312766
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
volume | true | decimal | volume | |
order_type | true | int | order type: 1. Quotation; 2. Cancelled order | |
direction | true | string | direction | buy, sell |
offset | true | string | offset | open, close, both |
lever_rate | true | int | lever rate | |
order_id | true | long | trailing order id | |
order_id_str | true | string | trailing order id in string format | |
order_source | true | string | order source | |
created_at | true | long | created at | |
order_price_type | true | string | order price type | optimal_5, optimal_10, optimal_20, formula_price |
status | true | int | order status | 2.Ready to submit the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled |
callback_rate | true | decimal | callback rate | such as: 0.01 means 1% |
active price | true | decimal | active price | |
is_active | true | int | Is the active price activated? | 1: activated; 0: not activated |
margin_mode | true | string | margin mode | cross |
margin_account | true | string | margin account | e.g:“BTC-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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Isolated]Get History Trailing Orders
- POST
/linear-swap-api/v1/swap_track_hisorders
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 |
status | true | string | order status | Multiple separated by English commas, Trailing Order status: 0:all(representing all orders in the end state), 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled |
trade_type | true | int | trade type | 0:all,1: buy long,2: sell short,3: buy short,4: sell long, 17:buy(one-way mode), 18:sell(one-way mode) |
create_date | true | long | days | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. |
page_index | false | int | page index, if not filled in as 1st | |
page_size | false | int | if not filled in as 20, and no more than 50 | |
sort_by | false | string | sort fields(descending), if not filled in, sort by created_at descending | "create_date":descending order by order create date , "update_time": descending order by order update time |
Response:
{
"status":"ok",
"data":{
"orders":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"triggered_price":null,
"volume":1,
"order_type":1,
"direction":"sell",
"offset":"open",
"lever_rate":5,
"order_id":826054686706565120,
"order_id_str":"826054686706565120",
"order_source":"api",
"created_at":1616988384665,
"update_time":1616988430833,
"order_price_type":"formula_price",
"status":6,
"canceled_at":1616988393365,
"fail_code":null,
"fail_reason":null,
"callback_rate":0.03,
"active_price":51111,
"is_active":0,
"market_limit_price":null,
"formula_price":null,
"real_volume":0,
"relation_order_id":"-1",
"margin_mode":"isolated",
"margin_account":"BTC-USDT",
"reduce_only": 0
}
],
"total_page":1,
"current_page":1,
"total_size":4
},
"ts":1616989113947
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | BTC-USDT |
volume | true | decimal | volume | |
order_type | true | int | order type: 1. Quotation; 2. Cancelled order | |
direction | true | string | direction | buy, sell |
offset | true | string | offset | open, close, both |
lever_rate | true | int | lever rate | |
order_id | true | long | trailing order id | |
order_id_str | true | string | trailing order id in string format | |
order_source | true | string | order source | |
created_at | true | long | created at | |
update_time | true | long | update time, unit: millisecond | |
order_price_type | true | string | order price type | optimal_5, optimal_10, optimal_20, formula_price |
status | true | int | order status | 2.Ready to submit the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled |
canceled_at | true | long | canceled at | |
fail_code | true | int | error code when place limit price order | |
fail_reason | true | string | error reason when place limit price order | |
callback_rate | true | decimal | callback rate | such as: 0.01 means 1% |
active price | true | decimal | active price | |
is_active | true | int | Is the active price activated? | 1: activated; 0: not activated |
market_limit_price | true | decimal | lowest/highest market price (use the lowest price when buy. use the highest when sell) | |
formula_price | true | decimal | formula price(the lowest (highest) market price* (1 ± callback rate)) | |
real_volume | true | decimal | real volume | |
triggered_price | true | decimal | triggered price | |
relation_order_id | true | string | relation_order_id is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
margin_mode | true | string | margin mode | isolated |
margin_account | true | string | margin account | e.g:“BTC-USDT” |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[Cross]Get History Trailing Orders
- POST
/linear-swap-api/v1/swap_cross_track_hisorders
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.
one of pair and contract_code must be filled in. and both filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
status | true | string | order status | Multiple separated by English commas, Trailing Order status: 0:all(representing all orders in the end state), 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled |
trade_type | true | int | trade type(if not filled in, means all) | 0:all,1: buy long,2: sell short,3: buy short,4: sell long, 17:buy(one-way mode), 18:sell(one-way mode) |
create_date | true | long | days | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. |
page_index | false | int | page index, if not filled in as 1st | |
page_size | false | int | if not filled in as 20, and no more than 50 | |
sort_by | false | string | sort fields(descending), if not filled in, sort by created_at descending | "create_date":descending order by order create date , "update_time": descending order by order update time |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"contract_type": "quarter",
"business_type": "futures",
"pair": "BTC-USDT",
"symbol": "BTC",
"contract_code": "BTC-USDT-211231",
"triggered_price": null,
"volume": 1.000000000000000000,
"order_type": 1,
"direction": "buy",
"offset": "open",
"lever_rate": 1,
"order_id": 918819679173152768,
"order_id_str": "918819679173152768",
"order_source": "api",
"created_at": 1639105282359,
"update_time": 1639105426243,
"order_price_type": "formula_price",
"status": 6,
"canceled_at": 1639105426208,
"fail_code": null,
"fail_reason": null,
"callback_rate": 0.030000000000000000,
"active_price": 41111.000000000000000000,
"is_active": 0,
"market_limit_price": null,
"formula_price": null,
"real_volume": 0,
"relation_order_id": "-1",
"margin_mode": "cross",
"margin_account": "USDT",
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 1
},
"ts": 1639105441911
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | the result of server handling to request | "ok" :success, "error": failed |
<data> | true | object | dictionary | |
total_page | true | int | total page | |
total_size | true | int | total size | |
current_page | true | int | current page | |
<orders> | true | object array | ||
symbol | true | string | symbol | |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
volume | true | decimal | volume | |
order_type | true | int | order type: 1. Quotation; 2. Cancelled order | |
direction | true | string | direction | buy, sell |
offset | true | string | offset | open, close, both |
lever_rate | true | int | lever rate | |
order_id | true | long | trailing order id | |
order_id_str | true | string | trailing order id in string format | |
order_source | true | string | order source | |
created_at | true | long | created at | |
update_time | true | long | update time, unit: millisecond | |
order_price_type | true | string | order price type | optimal_5, optimal_10, optimal_20, formula_price |
status | true | int | order status | 2.Ready to submit the orders, 4.Submit the orders success, 5.Submit the orders failed, 6.Orders cancelled |
canceled_at | true | long | canceled at | |
fail_code | true | int | error code when place limit price order | |
fail_reason | true | string | error reason when place limit price order | |
callback_rate | true | decimal | callback rate | such as: 0.01 means 1% |
active price | true | decimal | active price | |
is_active | true | int | Is the active price activated? | 1: activated; 0: not activated |
market_limit_price | true | decimal | lowest/highest market price (use the lowest price when buy. use the highest when sell) | |
formula_price | true | decimal | formula price(the lowest (highest) market price* (1 ± callback rate)) | |
real_volume | true | decimal | real volume | |
triggered_price | true | decimal | triggered price | |
relation_order_id | true | string | relation_order_id is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
margin_mode | true | string | margin mode | cross |
margin_account | true | string | margin account | e.g:“BTC-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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
</data> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
Swap Transferring Interface
[General] Transfer margin between Spot account and USDT Margined Contracts account
Example
- POST
https://api.huobi.pro/v2/account/transfer
Notice
The interface supports cross margin mode and isolated margin mode.
This interface is used to transfer assets between Spot account and USDT Margined Contracts account.
API rate limit for this interface is 1 times/second.
Transferring margin between Spot account and USDT Margined Contracts account Interface, sets 8 decimal places for transferring amount of all coins.
Request Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
from | true | string | source,value:spot、linear-swap | e.g. spot |
to | true | string | destination,value:spot、linear-swap | e.g. linear-swap |
currency | true | string | currency.Both uppercase and lowercase are supported. | e.g. USDT |
amount | true | decimal | Transferring amount | |
margin-account | true | string | margin account | e.g. BTC-USDT,ETH-USDT, USDT |
note
- when "margin-account" is USDT,it means the transfer in or transfer out from cross margin account.
Response:
Yes:
{
"code": 200,
"data": 176104252,
"message": "Succeed",
"success": true
}
No:
{
"code":1303,
"data":null,
"message":"The single transfer-out amount must be no less than 0.0008BTC",
"success":false
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
success | true | string | status | true/false |
data | true | long | The generated transfer order id | |
code | true | long | Response code | |
message | true | string | Response message |
Response Code Table
Response Code | Desc in Chinese | Desc in English |
---|---|---|
200 | 成功 | Succeed |
403 | 拒绝访问 | Access denied |
404 | 访问的资源不存在 | The resource being accessed does not exist |
429 | 太多的请求 | too many requests |
500 | 系统错误 | System error |
501 | 无效请求 | Invalid request |
502 | 无效参数 | Invalid parameter |
504 | 缺少参数 | Lack of parameter |
512 | 拒绝匿名请求 | Reject anonymous requests |
513 | 无效的签名 | Invalid signature |
10000 | 币种不存在 | Currency does not exist |
10001 | 不支持同业务划转 | Does not support transfer within single business |
10002 | 不支持此划转业务 | This transfer is not supported |
10003 | from方check校验不通过 | check rejected by the from party |
10004 | to方check校验不通过 | to check rejected by the to party |
10005 | 个人账户平账检查不通过 | Personal account balance check failed |
10006 | 系统账户检查失败 | System account check failed |
10008 | 黑名单校验不通过 | Blacklist check failed |
10009 | 用户有未安全上账资产,禁止划转 | No transfer is allowed if the user has any asset that has not been charged to the account safely |
10010 | 用户被锁定 | User locked |
10011 | 24小时内修改过安全策略 | Security policy has been modified within 24 hours |
20001 | OTC 人脸识别 | OTC Face Recognition |
1030 | 服务异常,请稍后再试 | Abnormal service. Please try again later. |
1010 | 用户不存在 | Abnormal service. Please try again later. |
1012 | 账户不存在 | Abnormal service. Please contact customer service. |
1013 | 合约品种不存在 | This contract type doesn't exist. |
1018 | 主账号不存在 | Main account doesn't exist. |
1089 | {0}合约暂时限制划转,请联系客服 | {0} contract is restricted of transfer. Please contact customer service. |
1102 | 您没有转入权限,请联系客服 | Unable to transfer in currently. Please contact customer service. |
1103 | 您没有转出权限,请联系客服 | Unable to transfer out currently. Please contact customer service. |
1106 | 合约状态异常,暂时无法划转 | Abnormal contracts status. Can’t transfer. |
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. |
1114 | 子账号没有划转权限,请登录主账号授权 | The sub-account does not have transfer permissions. Please login main account to authorize. |
1300 | 划转失败 | Transfer failed. |
1301 | 可划转余额不足 | Insufficient amount available. |
1302 | 系统划转错误 | Transfer failed. |
1303 | 单笔转出的数量不能低于{0}{1} | The single transfer-out amount must be no less than {0}{1}. |
1304 | 单笔转出的数量不能高于{0}{1} | The single transfer-out amount must be no more than {0}{1}. |
1305 | 单笔转入的数量不能低于{0}{1} | The single transfer-in amount must be no less than {0}{1}. |
1306 | 单笔转入的数量不能高于{0}{1} | The single transfer-in amount must be no more than {0}{1}. |
1307 | 您当日累计转出量超过{0}{1}, 暂无法转出 | Your accumulative transfer-out amount is over the daily maximum, {0}{1}. You can't transfer out for the time being. |
1308 | 您当日累计转入量超过{0}{1}, 暂无法转入 | Your accumulative transfer-in amount is over the daily maximum, {0}{1}. You can't transfer in for the time being. |
1309 | 您当日累计净转出量超过{0}{1}, 暂无法转出 | Your accumulative net transfer-out amount is over the daily maximum, {0}{1}. You can't transfer out for the time being. |
1310 | 您当日累计净转入量超过{0}{1}, 暂无法转入 | 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 | 划转金额必须大于0 | Invalid amount. Must be more than 0. |
1323 | 服务异常, 划转失败, 请稍后再试 | Abnormal service, transfer failed. Please try again later. |
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 | 超出划转精度限制(8位), 请修改后操作 | Exceeds limit of transfer accuracy (8 digits). Please modify it. |
Swap WebSocket Reference
API List
Permission | Content Type | Interface Mode | Request Method | Type | Description | Authentication Required |
---|---|---|---|---|---|---|
Read | Market Data Interface | general | market.$contract_code.kline.$period | sub | Subscribe KLine data | No |
Read | Market Data Interface | general | market.$contract_code.kline.$period | req | Request Kline Data | No |
Read | Market Data Interface | general | market.$contract_code.depth.$type | sub | Subscribe Market Depth Data | No |
Read | Market Data Interface | general | market.$contract_code.depth.size_${size}.high_freq | sub | Subscribe Incremental Market Depth Data | No |
Read | Market Data Interface | general | market.$contract_code.bbo | sub | Subscribe market BBO data push | No |
Read | Market Data Interface | general | market.$contract_code.detail | sub | Subscribe Market Detail Data | No |
Read | Market Data Interface | general | market.$contract_code.trade.detail | req | Request Trade Detail Data | No |
Read | Market Data Interface | general | market.$contract_code.trade.detail | sub | Subscribe Trade Detail Data | No |
Read | Index and Basis Interface | general | market.$contract_code.index.$period | sub | Subscribe Index Kline Data | No |
Read | Index and Basis Interface | general | market.$contract_code.index.$period | sub | Request Index Kline Data | No |
Read | Index and Basis Interface | general | market.$contract_code.basis.$period.$basis_price_type | sub | Subscribe Basis Data | No |
Read | Index and Basis Interface | general | market.$contract_code.basis.$period.$basis_price_type | req | Request Basis Data | No |
Read | Index and Basis Interface | general | market.$contract_code.premium_index.$period | sub | Subscribe Premium Index Kline Data | No |
Read | Index and Basis Interface | general | market.$contract_code.premium_index.$period | req | Request Premium Index Kline Data | No |
Read | Index and Basis Interface | general | market.$contract_code.estimated_rate.$period | sub | Subscribe Estimated Funding Rate Kline Data | No |
Read | Index and Basis Interface | general | market.$contract_code.estimated_rate.$period | req | Request Estimated Funding Rate Kline Data | No |
Read | Index and Basis Interface | general | market.$contract_code.mark_price.$period | sub | Subscribe Kline Data of Mark Price | No |
Read | Index and Basis Interface | general | market.$contract_code.mark_price.$period | req | Request Kline Data of Mark Price | No |
Read | Trade Interface | general | public.$contract_code.liquidation_orders | sub | Subscribe Liquidation Orders (no authentication) (sub) | No |
Read | Trade Interface | general | public.$contract_code.funding_rate | sub | Subscribe funding rate (no authentication)(sub) | No |
Read | Trade Interface | general | public.$contract_code.contract_info | sub | Subscribe Contract Info (no authentication)(sub) | No |
Read | Trade Interface | Isolated Margin | orders.$contract_code | sub | Subscribe Order Data(sub) | Yes |
Read | Account Interface | Isolated Margin | accounts.$contract_code | sub | Subscribe Account Equity Updates Data(sub) | Yes |
Read | Account Interface | Isolated Margin | positions.$contract_code | sub | Subscribe Position Updates(sub) | Yes |
Read | Trade Interface | Isolated Margin | matchOrders.$contract_code | sub | Subscribe Match Order Data(sub) | Yes |
Read | Trade Interface | Isolated Margin | trigger_order.$contract_code | sub | Subscribe trigger orders updates(sub) | Yes |
Read | Account Interface | cross margin | orders_cross.$contract_code | sub | Subscribe Order Data | Yes |
Read | Account Interface | cross margin | accounts_cross.$margin_account | sub | Subscribe Account Equity Updates Data | Yes |
Read | Trade Interface | cross margin | positions_cross.$contract_code | sub | Subscribe Position Updates | Yes |
Read | Trade Interface | cross margin | matchOrders_cross.$contract_code | sub | Subscribe Match Order Data | Yes |
Read | Trade Interface | cross margin | trigger_order_cross.$contract_code | sub | Subscribe trigger orders updates(sub) | Yes |
Read | System Status Interface | cross margin | public.$service.heartbeat | sub | Subscription system status updates | No |
WebSocket Subscription Address
Market Data Request and Subscription: wss://api.hbdm.com/linear-swap-ws
Order Push Subscription: wss://api.hbdm.com/linear-swap-notification
Index Kline Data and Basis Data Subscription: wss://api.hbdm.com/ws_index
System status updates subscription :wss://api.hbdm.com/center-notification
If the url: api.hbdm.com can't be accessed, please use the url below:
Market Data Request and Subscription Address: wss://api.btcgateway.pro/linear-swap-ws;
Order Push Subscription:wss://api.btcgateway.pro/linear-swap-notification
Index Kline Data and Basis Data Subscription: wss://api.btcgateway.pro/ws_index
System status updates subscription :wss://api.btcgateway.pro/center-notification
If you have further queries about Huobi USDT Margined Contracts order push subscription, please refer to Demo
Note:
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".
API Rate Limit Illustration
There is rate limit for both public and private interfaces. More details are laid out 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).
For public interfaces used to get information of non-market data (such as request information of index, price limit, delivery and settlement, positions, etc.), the rate limit for each IP is 240 times every 3 seconds. (Please note that the 240 times/3s rate limit is shared by all the requests for non-market data under this UID)
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) The rate limit for “req” request is 50 times/s at most. No limit for “sub” request as the data will be pushed by server voluntarily.
The order push private WebSocket interface requires API Key for authentication.
Each UID can create 30 WS connections at most for private order push at the same time. The user under this UID only need to subscribe one WS order push for the contracts of the same underlying coins. For example, users only need to create one WS order push connection for BTC Contract, which our system will automatically push orders of BTC weekly, BTC biweekly and BTC quarterly contracts via this connection.
Note: The rate limit of WS order push and RESTFUL private interface are separated from each other with no relations.
- 40 subscriptions at most can be sent in one second in websocket connections.
Response the following strings for “Header” via API
ratelimit-limit: the upper request limit per time, unit: times
ratelimit-interval: reset interval(reset the number of request ), unit: ms
ratelimit-remaining: available request number left in this round, unit: times
ratelimit-reset: upper limit of reset time used to request number, unit: ms
WebSocket Heartbeat and Authentication Interface
Market Heartbeat
WebSocket API supports two-way heartbeat. Both Server and Client can send ping message, which the opposite side can return with pong message.
- WebSocket Server sends heartbeat:
{"ping": 18212558000}
- WebSocket Client should respond::
{"pong": 18212558000}
Note: Once the WebSocket Client and WebSocket Server get connected, the server will send a heartbeat every 5 seconds (the frequency might change). The connection will get disconnected automatically if the WebSocket Client ignores the heartbeat message for 5 times. The server will remain connection if the WebSocket Client responds one “ping” value within the latest 2 heartbeat messages.
Order Push Heartbeat
WebSocket API supports one-way heartbeat. The Server initiates ping message and the Client will return pong message. The Server sends back a heartbeat:
{
"op": "ping",
"ts": "1492420473058"
}
- WebSocket Client should return:
{
"op": "pong",
"ts": "1492420473058"
}
Note
- "ts" value in the return "pong" message is the "ts" value from "ping" push Once the WebSocket Client and WebSocket Server connected, Websocket Server will send a heartbeat every 5 seconds (the frequency might change) to Wesocket Client. If WebSocket Client ignores the heartbeat message for 5 times, it will get disconnected with Websocket Sever automatically. Under abnormal conditions, WebSocket Server will return error message like:
{
"op": "pong"
"ts": "1492420473027",
"err-code": 2011,
"err-msg": “detailed error message”
}
- Websocket Server disconnects automatically During period of building connection and authentication, Websocket Server will disconnect automatically if there is any error. The data structure before closing pushing are as below:
{
"op": "close", // indicate Websocket Server disconnected automatically
"ts": long // The local timestamp of Server push
}
- Server return error but remain connection After successful authentication, Server will return error but not disconnect if Client provides illegal Op or there is any internal error.
{
"op": "error", // indicate that receive illegal Op or internal error
"ts": long// The local timestamp of Server push
}
Order Push Address
- Huobi USDT Margined Contracts uses one official address:
wss://api.hbdm.com/linear-swap-notification
Note
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".
Please note that the WS request connection should not go over 30 normally.
Data Compression
All response data from WebSocket server are compressed into GZIP format. Clients have to decompress them for further use.
Illustration of Request(req and rep) Data
Character Encoding:UTF-8
Case sensitive,including parameter name and return parameter
Data type: use JSON to transmit data
All request data has fixed format. Please note that Huobi USDT Margined Contracts API document will only focus on data illustration in non-fixed format.
Request data format is laid out as below:
{
"op": string, // Required; Client requests operator name (Server will returns the same value), For detailed operator name list, please refer to the appendix
"cid": string, // Optional;Request unique ID( Client generate a unique ID which server will return the same value)
// Others required/ Optional string
}
All responses push data will be returned in fixed format,Huobi USDT Margined Contracts API document will only focus on data illustration, Response data format is laid out as below;
{
"op": string, // Required; Clients request operator name
"cid": string, // optional; Client requests unique ID
"ts": long, // required; Server responds local timestamp
"err-code": integer, // required; return error code, “0” means successfully responded, others means error. For detailed return error code list, please refer to appendix
"err-msg": string, only responds error message when error occurs, detailed error information.
"data": object // optional; return data object, request valid data after error removed
}
Push Data Format is laid out as below:
{
"op": "string", // required;Server pushes operator name, For detailed operator type list, please refer to appendix
"ts": long, // required; Server pushes local timestamp
"data": object // required;return data object
}
Server voluntarily disconnects connection
During making connection and authentication, server will disconnect connection automatically when error occurs. Before disconnecting, server will send notification below,
{
`"op": "close", // represents server disconnect connection voluntarily
`"ts": long // Server pushes local timestamp
}
Server return error code but remain connection
After authentication, if clients encountered internal error or request data out from Operator List, WebSocket server will return error message. But server will remain connection
{
"op": "error", // means server receive data out from Operator List or clients got internal error
"ts": long// Server pushes local timestamp
}
Authentication
Clients can create Access Key and Secret Key on Huobi which Access Key is the API access key kept by the client. The Secret Key is used to sign the request (available only for request). To apply/change API key, please go to “Account-API Management” on Huobi USDT Margined Contracts. Make name for the API Key and click “create” to finish. It’s optional to bind IP address to the API Key.
For the Trade WebSocket interface, server have to do authentication for topics require authentication before making connection.
Note: These two keys are closely related to account security and should not be disclosed to others at any time.
Authentication Format Example:
{
"op": "auth",
"type": "api",
"AccessKeyId": "e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx",
"SignatureMethod": "HmacSHA256",
"SignatureVersion": "2",
"Timestamp": "2017-05-11T15:19:30",
"Signature": "4F65x5A2bLyMWVQj3Aqp+B4w+ivaA7n5Oi2SuYtCJ9o=",
}
Illustration on Authentication Format Data
Field | type | Description |
---|---|---|
op | string | required; Operator type, Requested authentication operator type is auth |
type | string | required; Signature method sign via API means API interface signature, sign via ticket means terminal signature |
cid | string | Optional; Client requests the unique ID |
AccessKeyId | string | required if users use API signature; API Access key is the API AccessKey you applied. |
SignatureMethod | string | required if users use API signature; Signature method, user computes signature basing on the protocol of hash ,the API uses HmacSHA256 |
SignatureVersion | string | required if the users use API signature; the signature protocol version, the API uses 2 |
Timestamp | string | required if users use API signature; timestamp, the time you request(UTC timezone) this value can help to avoid request data interception by the third party for example :2017-05-11T16:22:06 (UTC time zone) |
Signature | string | required if the users use API signature; signature, the value computed is ensure valid authentication without being tampered |
ticket | string | required if users use ticket signature ; return when logged in |
Notice:
To decrease API access rate, the WebSocket server uses the same signature algorithm with that on REST API
All data is case sensitive;
When type is api, In API authentication, parameter op, type, cid, Signature do not participate in operation.
The request method in signature's method is GET, the other parameter please refer to REST api document
Signature Illustration:
Example on Signature Computing Process:,
Request code requirement for signature computing. Because it can return to total different data with different content when using HMAC for signature computing; Before signature computing, clients need to sign by following the standard format.
Request Method (GET or POST), add newline character
\n
after URL
GET\n
- add visit address with lowercase letters, add newline characters
\n
after URL
api.hbdm.com\n
- Access path, adding newline character
\n
after URL
/linear-swap-notification\n
- Sequence the parameter name according to ASCII code (use UTF-8 and transfer into URI encoding, capital letters for hexadecimal characters. E.G.: ‘:’ will be encoded into '%3A', blank will be encoded into '%20'). Here is an encoding example below for request parameters
AccessKeyId=e2xxxxxx-99xxxxxx-84xxxxxx-7xxxx&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30
Connect all parameters with ’&’ according to the sequence above.
The final strings for signature computing created by following the steps as below:
Signature Computing, transmit the two parameters below into cryptographic hash: strings needed to be computed, API SecretKey. Get the signature computing result and get it encoded with Base 64 code standard.
Add computed value into the Signature parameter in API request. Please note the computed value SHOULD NOT be encoded into URL cdoe.
Authentication Response Format Illustration
Field | type | description |
---|---|---|
op | string | required; Operator type, Authentication response type is auth |
type | string | required; Return data according to the requested parameters |
cid | string | optional; Return data when “cid” string requested |
err-code | int | 0 means successfully response, others means response failure return 0 if success , For detailed Response code(Err-Code), please refer to appendix |
err-msg | string | optional, response detailed error code when error occurs |
ts | long | server responds timestamp |
user-id | string | client ID |
Example of A Success Authentication Response
{
"op": "auth",
"type":"api",
"ts": 1489474081631,
"err-code": 0,
"data": {
"user-id": "12345678"
}
}
Example of Authentication Response with Error
{
"op": "auth",
"type":"api",
"ts": 1489474081631,
"err-code": xxxx,
"err-msg": ”Error details “
}
WebSocket Market Interface
[General] Subscribe Kline data
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.
To subscribe Kline data, clients have to connect WebSocket API server and send subscribe request with the format below:
{
"sub": "market.$contract_code.kline.$period",
"id": "id generate by client"
}
Example of a successful subscription request:
{
"sub": "market.BTC-USDT.kline.1min",
"id": "id1"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.kline.$period,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules
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 | Kline Period | 1min, 5min, 15min, 30min, 60min,4hour,1day,1week, 1mon |
After subscription, clients can receive updates upon any change. Example:
{
"ch":"market.BTC-USDT.kline.1min",
"ts":1603707124366,
"tick":{
"id":1603707120,
"mrid":131592424,
"open":13067.7,
"close":13067.7,
"high":13067.7,
"low":13067.7,
"amount":0.004,
"vol":4,
"trade_turnover":52.2708,
"count":1
}
}
Return Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
ch | true | string | Request Parameter |
ts | true | long | Time of Respond Generation,Unit:Millisecond |
<tick> | |||
id | true | long | kline id,the same as kline timestamp, kline start timestamp |
mrid | true | long | ID Order ID |
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 |
</tick> |
[General] Request Kline data
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.
To request Kline data, clients have to make connection to WebSocket API Server and send subscribe request in the format below:
{
"req": "market.$contract_code.kline.$period",
"id": "id generated by client",
"from": " type: long, the time from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00, unit: s",
"to": "type: long, the time from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00, unit: s , the 'to' value should be larger than 'from' value"
}
Example of Kline Data Subscription Request:
{
"req": "market.BTC-USDT.kline.1min",
"id": "id4",
"from": 1571000000,
"to": 1573106298
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
req | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.kline.$period,For parameter details please check req Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
from | true | long | Start Time |
to | true | long | End Time |
req Subscribe Parameter Rules
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 | Kline Period | 1min, 5min, 15min, 30min, 60min,4hour,1day,1week, 1mon |
Note
If between time range [t1, t5], there are t1-t5 KLines in quantity.
from: t1, to: t5, return [t1, t5].
from: t5, to: t1, which t5 > t1, return [].
from: t5, return [t5].
from: t3, return [t3, t5].
to: t5, return [t1, t5].
from: t which t3 < t <t4, return [t4, t5].
to: t which t3 < t <t4, return [t1, t3].
from: t1 and to: t2, should satisfy 1325347200 < t1 < t2 < 2524579200.
Clients can request 2000 Klines at most in one request
Example of a successful return data:
{
"id":"id4",
"rep":"market.BTC-USDT.kline.60min",
"wsid":467277265,
"status":"ok",
"data":[
{
"id":1603270800,
"open":12198,
"close":12196.7,
"low":11715.8,
"high":12300,
"amount":0.276,
"vol":276,
"trade_turnover":3315.9104,
"count":39
},
{
"id":1603274400,
"open":12196.7,
"close":12277.9,
"low":12111,
"high":12289.9,
"amount":0.198,
"vol":198,
"trade_turnover":2420.7728,
"count":21
}
]
}
Return Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
rep | true | string | Request Parameter |
status | true | string | status |
id | true | string | Request ID |
wsid | true | long | wsid |
<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 latest Kline is the last order price |
low | true | decimal | Low Price |
high | true | decimal | High Price |
amount | true | decimal | Trade Amount(Coin), trade amount(coins)=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] Subscribe Market Depth Data
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.
To subscribe market depth data, clients have to make connection to WebSokcet API Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.depth.$type",
"id": "id generated by client"
}
Example of a successful request :
{
"sub": "market.BTC-USDT.depth.step0",
"id": "id5"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.depth.$type,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules
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 |
type | true | string | Depth Type | 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. |
Note:
When clients choose merged depth data, WebSocket server will only display the merged price within price steps in order book. Please note that the merged depth price will not make any change on the actual order price.
step16, step17, step18, and step19 are only for SHIB-USDT contract, and the other contracts is not supported now.
steps between step1 and step5, step14 and step17 are merged orderbook data of step 150. steps between step7 and step13, step18, step19 are merged orderbook data of step 20. Details are below:
Depth | precision |
---|---|
step16、step18 | 0.0000001 |
step17、step19 | 0.000001 |
step1、step7 | 0.00001 |
step2、step8 | 0.0001 |
step3、step9 | 0.001 |
step4、step10 | 0.01 |
step5、step11 | 0.1 |
step14、step12 | 1 |
step15、step13 | 10 |
Clients can receive data if there is any update upon market depth. Example:
{
"ch":"market.BTC-USDT.depth.step6",
"ts":1603707576468,
"tick":{
"mrid":131596447,
"id":1603707576,
"bids":[
[
13071.9,
38
],
[
13068,
5
]
],
"asks":[
[
13081.9,
197
],
[
13099.7,
371
]
],
"ts":1603707576467,
"version":1603707576,
"ch":"market.BTC-USDT.depth.step6"
}
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
ch | true | string | Data channel, Format: market.period | |
<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 | Timestamp for depth generation; generated once every 100ms, unit: millisecond | |
version | true | long | version ID | |
ch | true | string | Data channel, Format: market.period | |
</tick> |
[General] Subscribe Incremental Market Depth Data
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.
To subscribe incremental market depth data, clients have to make connection to WebSokcet API Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.depth.size_${size}.high_freq",
"data_type":"incremental",
"id": "id generated by client"
}
Example of a successful request :
{
"sub": "market.btc-usdt.depth.size_20.high_freq",
"data_type":"incremental",
"id": "id generated by client"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.depth.size_${size}.high_freq,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
data_type | false | string | data type. snapshot by default. incremental : incremental data.snapshot : full data. |
sub Subscribe Parameter Rules
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 |
size | true | int | Depth size | 20 : stands for 20 unmerged data. 150 :stands for 150 unmerged data. |
Response example:
{
"ch":"market.BTC-USDT.depth.size_20.high_freq",
"tick":{
"asks":[
[
13081.9,
206
],
[
13099.7,
371
]
],
"bids":[
[
13071.9,
38
],
[
13060,
400
]
],
"ch":"market.BTC-USDT.depth.size_20.high_freq",
"event":"snapshot",
"id":131597620,
"mrid":131597620,
"ts":1603707712356,
"version":1512467
},
"ts":1603707712357
}
Return Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
ts | true | long | Timestamp of Respond Generation, Unit: Millisecond | |
ch | true | string | Data channel, Format:market.$contract_code.depth.size_${size}.high_freq |
|
<tick> | ||||
mrid | true | long | Order ID | |
id | true | long | tick ID,system timestamp.seconds | |
asks | true | object | Sell,[price(Ask price), vol(Ask orders (cont.) )], price in ascending sequence | |
bids | true | object | Buy,[price(Bid price), vol(Bid orders(Cont.))], Price in descending sequence | |
ts | true | long | Timepoint for system detecting orderbook, unit: millisecond | |
version | true | long | version ID,auto increment ID. | |
event | true | string | event type: update or snapshot |
|
ch | true | string | Data channel, Format: market.$contract_code.depth.size_${size}.high_freq |
|
</tick> |
Note:
- when
data_type
isincremental
,snapshot
data wil be pushed for the first time. When re-connection occurs,snapshort
data will be pushed for the first time. version
: auto increment in single websocket connection.version
may be different among several websocket subscription connections.- orderbook will be pushed if orderbook is updated whenever
incremental
orsnapshot
. - 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.
[General] Subscribe Market Detail Data
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.
To subscribe market details, the clients have to make connection to WebSocket Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.detail",
"id": "id generated by client"
}
Example of Subscribe Market Detail Data:
{
"sub": "market.BTC-USDT.detail",
"id": "id6"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.detail,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | should be unique from user-side |
sub Subscribe Parameter Rules
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 |
Example of a successful return data:
{
"ch":"market.BTC-USDT.detail",
"ts":1603707870528,
"tick":{
"id":1603707840,
"mrid":131599205,
"open":12916.2,
"close":13065.8,
"high":13205.3,
"low":12852.8,
"amount":30.316,
"vol":30316,
"trade_turnover":395073.4918,
"count":2983,
"bid":[
13684.5,
10615
],
"ask":[
13684.6,
3440
]
}
}
Return Parameter
Parameter Name | Required | Type | Description |
---|---|---|---|
ch | true | string | Data channel,Format: market.$contract_code.detail |
ts | true | long | Time of Respond Generation, Unit: Millisecond |
<tick> | |||
id | true | long | ID |
mrid | true | long | Order ID |
open | true | decimal | Open Price |
close | true | decimal | Clos Price, the price from the latest kline is the last order price |
high | true | decimal | High Price |
low | true | decimal | Low Price |
amount | true | decimal | Trade Amount(Coins), Trade amount(Coin)=SUM(quantity(cont.)*face value/ order price. Sum of both buy and sell sides |
vol | true | decimal | Trade volume(Cont.), the sum volume of both buy and sell sides. Sum of both buy and sell sides |
count | true | decimal | fulfilled order quantity. 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 |
ask | true | object | Sell,[price(Ask price), vol(Ask orders (cont.) )] |
bid | true | object | Buy,[price(Bid price), vol(Bid orders(Cont.))] |
</tick> |
Note:
Bid price(p1) and ask price(p1) are not updated in real time, there will be some delay (about 500ms).
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.
[General] Subscribe market BBO data push
Remarks
- The interface supports cross margin mode and isolated margin mode.
clients have to make connection to WebSocket API Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.bbo",
"id": "id generated by client"
}
Example of a successful request:
{
"sub": "market.BTC-USDT.bbo",
"id": "id8"
}
Request Parameter
Parameter Name | Mandotary | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.bbo,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules
Parameter Name | Mandotary | 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 |
Return example:
{
"ch":"market.BTC-USDT.bbo",
"ts":1603707934525,
"tick":{
"mrid":131599726,
"id":1603707934,
"bid":[
13064,
38
],
"ask":[
13072.3,
205
],
"ts":1603707934525,
"version":131599726,
"ch":"market.BTC-USDT.bbo"
}
}
Return Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
ch | true | string | Data channel, Format: market.$contract_code.bbo | |
ts | true | long | Timestamp of Respond Generation, Unit: Millisecond | |
<tick> | true | object | ||
ch | true | string | Data channel, Format: market.$contract_code.bbo | |
mrid | true | string | Order ID | |
id | true | long | tick ID | |
ask | false | array | Best Ask Quotation,[price(Ask price), vol(Ask order (cont.) )] | |
bid | false | array | Best Bid Quotation,[price(Bid price), vol(Bid order(Cont.))] | |
version | true | long | version ID. | |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<\tick> |
Rules:
- When any one of the buy_one price, buy_one quantity, sell_one price and sell_one quantity changes, the system will push BBO price.
- If there are multiple changes in the price or quantity of buy_one or sell_one at the same time, the system will push the latest price and quantity of buy_one and sell one with the intermediate data discarded.
- When the data received by the client is failed or delayed, the old data buffer in the server will be discarded.The latest BBO will be pushed.
- version(version number). Use match id directly to ensure it is globally unique and the value of version number pushed is the largest.
[General] Request Trade Detail Data
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.
To request Trade detail data, Clients have to make connection to the WebSocket Server and send request data in the format below:
{
"req": "market.$contract_code.trade.detail",
"id": "id generated by client"
// “id” string is optional currently. Server will return with null because client ID is not necessary
}
Return to the current trade detail data only
Example of requesting trade detail data:
{
"req": "market.BTC-USDT.trade.detail",
"size": 10,
"id": "id8"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
req | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.trade.detail,For parameter details please check req Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
size | false | int | number of data; no more than 50; default 50 if not filled |
req Subscribe Parameter Rules
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 |
Example of a successful return data:
{
"data":[
{
"amount":"22",
"ts":1603706942240,
"id":1315909380000,
"price":"13068.4",
"direction":"sell",
"quantity": "0.022",
"trade_turnover": "288.334"
},
{
"amount":"2",
"ts":1603706947767,
"id":1315909430000,
"price":"13068.5",
"direction":"buy",
"quantity": "0.002",
"trade_turnover": "26.334"
}
],
"id":"id8",
"rep":"market.BTC-USDT.trade.detail",
"status":"ok",
"ts":1603708046534
}
Return Parameter
Parameter Name | Required | Type | Description | Default |
---|---|---|---|---|
rep | true | string | Data Channel,Format: market.$contract_code.trade.detail | |
status | true | string | Request Status | |
id | true | long | Request ID | |
<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) | |
trade_turnover | true | string | trade turnover(quoted currency) | |
</data> | ||||
ts | true | long | server response time |
Notice
- There are "quantity" parameter in return data only after 21:00:00 on February 3, 2021
[General] Subscribe Trade Detail Data
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.
To subscribe trade detail data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.trade.detail",
"id": "id generated by client"
}
Example of a successful subscribe request:
{
"sub": "market.BTC-USDT.trade.detail",
"id": "id7"
}
Note:
Clients can only access the recent 300 trade detail data
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.trade.detail,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules
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 |
When there is any update upon trade detail data, clients will receive notification from server. Example:
{
"ch":"market.BTC-USDT.trade.detail",
"ts":1603708208346,
"tick":{
"id":131602265,
"ts":1603708208335,
"data":[
{
"amount":2,
"ts":1603708208335,
"id":1316022650000,
"price":13073.3,
"direction":"buy",
"quantity": 0.002,
"trade_turnover": 26.334
}
]
}
}
Return Parameter
Parameter Name | Required | Type | Description | Default |
---|---|---|---|---|
ch | true | string | Data channel,format: market.$contract_code.trade.detail | |
ts | true | long | Request time | |
<tick> | ||||
id | true | long | Unique Order Id(symbol level). | |
ts | true | long | tick time | |
<data> | ||||
amount | true | decimal | quantity(Cont.). Sum of both buy and sell sides | |
ts | true | long | trade timestamp | |
id | true | long | Unique Transaction Id(symbol level) | |
price | true | decimal | Price | |
direction | true | string | The direction to buy or sell is the direction of the taker (active transaction) | |
quantity | true | decimal | trading quantity(coin) | |
trade_turnover | true | decimal | trade turnover(quoted currency) | |
</data> | ||||
</tick> |
WebSocket Index and Basis Interface
- The websocket url of Index and Basis Data is:wss://api.hbdm.com/ws_index
[General] Subscribe Index Kline Data
Remarks
- The interface supports cross margin mode and isolated margin mode.
To subscribe index kline data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.index.$period",
"id": "id generate by client"
}
example of the subscription of index kline data:
{
"sub": "market.BTC-USD.index.1min",
"id": "id1"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.index.$period,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | index symbol | Case-Insenstive.Both uppercase and lowercase are supported.."BTC-USDT","ETH-USDT"... |
period | true | string | kline type | 1min, 5min, 15min, 30min, 60min,4hour,1day, 1mon |
Note
Pushed once the index data is changed.
Periodical Push when the index data hasn't changed according to the kline period.
results pushed by the server
{
"ch":"market.BTC-USDT.index.15min",
"ts":1607309592214,
"tick":{
"id":1607309100,
"open":"19213.505",
"close":"19242.05",
"high":"19248.31",
"low":"19213.505",
"amount":"0",
"vol":"0",
"count":0
}
}
Returning Parameter
parameter name | Required | type | desc | Value Range |
---|---|---|---|---|
ch | true | string | Data channel,Format:market.$contract_code.index.$period | |
tick | true | object array | Details:tick parameters | |
ts | true | long | Time of Respond Generation, Unit: Millisecond |
tick parameters
parameter name | type | desc | |
---|---|---|---|
id | string | index kline id,the same as kline timestamp,kline start timestamp | |
vol | string | Trade Volume. The value is 0. | |
count | decimal | count. The value is 0. | |
open | string | open index price | |
close | string | close index price | |
low | string | lowest index price | |
high | string | highest index price | |
amount | string | amount based on coins. |
[General] Request Index Kline Data
Remarks
- The interface supports cross margin mode and isolated margin mode.
To subscribe index kline data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"req": "market.$contract_code.index.$period",
"id": "id generated by client",
"from": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00",
"to": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00 .Larger than 'from' value. ",
}
example of the subscription of index kline data:
{
"req": "market.btc-usd.index.1min",
"id": "id4",
"from":1571000000,
"to":1573098606
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
req | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.index.$period,For parameter details please check req Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
from | true | long | start time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds |
to | true | long | end time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds. larger than 'from' value |
req Subscribe Parameter Rules:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | index symbol | Case-Insenstive.Both uppercase and lowercase are supported.."BTC-USDT","ETH-USDT"... |
period | true | string | kline type | 1min, 5min, 15min, 30min, 60min,4hour,1day, 1mon |
Note:
- Pushed once the index data is changed.
response example:
{
"id":"id4",
"rep":"market.BTC-USDT.index.15min",
"wsid":3673570133,
"ts":1607310136031,
"status":"ok",
"data":[
{
"id":1607309100,
"open":19213.505,
"close":19207.245,
"low":19207.245,
"high":19248.31,
"amount":0,
"vol":0,
"count":0
},
{
"id":1607310000,
"open":19199.655,
"close":19174.48,
"low":19174.48,
"high":19208.11,
"amount":0,
"vol":0,
"count":0
}
]
}
Returning Parameter
parameter name | Required | type | desc | Value Range |
---|---|---|---|---|
req | true | string | Data channel,Format:market.$contract_code.index.$period | |
status | true | string | Request processing result | "ok" , "error" |
id | true | string | ID | |
wsid | true | long | wsid | |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
data | true | object array | Details:data parameters |
data parameters
parameter name | type | desc | |
---|---|---|---|
id | int | index kline id,the same as kline timestamp,kline start timestamp | |
vol | decimal | Trade Volume. The value is 0. | |
count | decimal | count. The value is 0. | |
open | decimal | open index price | |
close | decimal | close index price | |
low | decimal | lowest index price | |
high | decimal | highest index price | |
amount | decimal | amount based on coins. |
[General] Subscribe Premium Index Kline Data
Remarks
- The interface supports cross margin mode and isolated margin mode.
To subscribe Premium index kline data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.premium_index.$period",
"id": "id generate by client"
}
example of the subscription of premium index kline data:
{
"sub": "market.BTC-USDT.premium_index.1min",
"id": "id1"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.premium_index.$period,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.."BTC-USDT","ETH-USDT"... |
period | true | string | kline type | 1min, 5min, 15min, 30min, 60min,4hour,1day, 1week, 1mon |
Note
Pushed once the index data is changed.
Periodical Push when the index data hasn't changed according to the kline period.
results pushed by the server
{
"ch":"market.BTC-USDT.premium_index.1min",
"ts":1603708380380,
"tick":{
"id":1603708380,
"open":"0.000068125",
"close":"0.000068125",
"high":"0.000068125",
"low":"0.000068125",
"amount":"0",
"vol":"0",
"count":"0"
}
}
Return Parameter
parameter name | Required | type | desc | Value Range |
---|---|---|---|---|
ch | true | string | Data channel,Format: market.period | |
<tick> | true | object array | ||
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 | count. The value is 0. | |
open | true | string | open index price | |
close | true | string | close index price | |
low | true | string | lowest index price | |
high | true | string | highest index price | |
amount | true | string | amount based on coins. | |
</tick> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General] Request Premium Index Kline Data
Remarks
- The interface supports cross margin mode and isolated margin mode.
To subscribe premium index kline data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"req": "market.$contract_code.premium_index.$period",
"id": "id generated by client",
"from": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00",
"to": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00 .Larger than 'from' value. ",
}
Example of a successful subscribe request
{
"req": "market.BTC-USDT.premium_index.1min",
"id": "id4",
"from":1571000000,
"to":1573098606
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
req | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.premium_index.$period,For parameter details please check req Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
from | true | long | start time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds |
to | true | long | end time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds. larger than 'from' value |
req Subscribe Parameter Rules:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.."BTC-USDT","ETH-USDT"... |
period | true | string | kline type | 1min, 5min, 15min, 30min, 60min,4hour,1day, 1week, 1mon |
Note:
- Pushed once the index data is updated.
response example:
{
"id":"id4",
"rep":"market.BTC-USDT.premium_index.15min",
"wsid":1524762738,
"ts":1603782744066,
"status":"ok",
"data":[
{
"id":1603641600,
"open":"0",
"close":"0.0000970833333333",
"low":"0",
"high":"0.0000997916666666",
"amount":"0",
"vol":"0",
"count":"0"
}
]
}
data parameters
parameter name | Required | type | desc | Value Range |
---|---|---|---|---|
rep | true | string | Data channel,Format: market.period | |
status | true | string | Request processing result | "ok" , "error" |
id | true | string | ID | |
wsid | true | long | wsid | |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
<data> | true | object array | ||
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 | count. The value is 0. | |
open | true | string | open index price | |
close | true | string | close index price | |
low | true | string | lowest index price | |
high | true | string | highest index price | |
amount | true | string | amount based on coins. | |
</data> |
[General] Subscribe Estimated Funding Rate Kline Data
Remarks
- The interface supports cross margin mode and isolated margin mode.
To subscribe Estimated Funding Rate kline data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.estimated_rate.$period",
"id": "id generate by client"
}
example of the subscription of estimated funding rate kline data:
{
"sub": "market.BTC-USDT.estimated_rate.1min",
"id": "id1"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.estimated_rate.$period,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.."BTC-USDT","ETH-USDT"... |
period | true | string | kline type | 1min, 5min, 15min, 30min, 60min,4hour,1day, 1week, 1mon |
Note:
Pushed once the kline data is changed.
Periodical Push when the kline data hasn't changed according to the kline period.
results pushed by the server
{
"ch":"market.BTC-USDT.estimated_rate.1min",
"ts":1603708560233,
"tick":{
"id":1603708560,
"open":"0.0001",
"close":"0.0001",
"high":"0.0001",
"low":"0.0001",
"amount":"0",
"vol":"0",
"count":"0",
"trade_turnover":"0"
}
}
parameters
parameter name | Required | type | desc | Value Range |
---|---|---|---|---|
ch | true | string | Data channel,Format: market.period | |
<tick> | true | object array | ||
id | true | long | index kline id,the same as kline timestamp | |
vol | true | string | Trade Volume(Cont.). The value is 0. | |
count | true | string | count. The value is 0. | |
open | true | string | open index price | |
close | true | string | close index price | |
low | true | string | lowest index price | |
high | true | string | highest index price | |
amount | true | string | amount based on coins. | |
trade_turnover | true | string | Transaction amount, the value is 0. | |
</tick> | ||||
ts | true | long | Time of Respond Generation, Unit: Millisecond |
[General] Request Estimated Funding Rate Kline Data
Remarks
- The interface supports cross margin mode and isolated margin mode.
To subscribe Estimated Funding Rate kline data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"req": "market.$contract_code.estimated_rate.$period",
"id": "id generated by client",
"from": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00",
"to": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00 .Larger than 'from' value. ",
}
Example of a successful subscribe request
{
"req": "market.btc-usdt.estimated_rate.1min",
"id": "id4",
"from":1571000000,
"to":1573098606
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
req | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.estimated_rate.$period,For parameter details please check req Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
from | true | long | start time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds |
to | true | long | end time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds. larger than 'from' value |
req Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | Case-Insenstive.Both uppercase and lowercase are supported.."BTC-USDT","ETH-USDT"... |
period | true | string | kline type | 1min, 5min, 15min, 30min, 60min,4hour,1day, 1week, 1mon |
response example:
{
"id":"id4",
"rep":"market.BTC-USDT.estimated_rate.15min",
"wsid":3674722864,
"ts":1603782867314,
"status":"ok",
"data":[
{
"id":1603641600,
"open":"0.0001",
"close":"0.0001",
"low":"0.0001",
"high":"0.0001",
"amount":"0",
"vol":"0",
"count":"0",
"trade_turnover":"0"
}
]
}
parameters
parameter name | Required | type | desc | Value Range |
---|---|---|---|---|
rep | true | string | Data channel, Format: market.period | |
status | true | string | Request status | "ok" , "error" |
id | true | string | ID | |
wsid | true | long | wsid | |
ts | true | long | Time of Respond Generation, unit: millisecond | |
<data> | true | object array | ||
id | true | long | index kline id,the same as kline timestamp | |
vol | true | string | Trade Volume(Cont.). The value is 0. | |
count | true | string | count. The value is 0. | |
open | true | string | open index price | |
close | true | string | close index price | |
low | true | string | lowest index price | |
high | true | string | highest index price | |
amount | true | string | amount based on coins. | |
trade_turnover | true | string | Transaction amount, the value is 0. | |
</data> |
[General] Subscribe Basis Data
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.
To subscribe basis data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"sub": "market.$contract_code.basis.$period.$basis_price_type",
"id": "id generate by client"
}
example of the subscription of basis data:
{
"sub": "market.BTC-USDT.basis.1min.open",
"id": "id1"
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
sub | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.basis.$period.$basis_price_type,For parameter details please check sub Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
sub Subscribe Parameter Rules:
Parameter Name | Mandotary | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code | 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" |
Response Example
{
"ch":"market.BTC-USDT.basis.1min.open",
"ts":1617164081549,
"tick":{
"id":1617164040,
"index_price":"58686.78333333333",
"contract_price":"58765",
"basis":"78.21666666667",
"basis_rate":"0.0013327816285723049700163397705562309"
}
}
Response Parameters
parameter name | Required | Type | Desc | Value Range |
---|---|---|---|---|
ch | string | Data belonged channel Format: market.period | ||
<tick> | object array | |||
id | long | unique id | ||
contract_price | string | contract last price | ||
index_price | string | index price | ||
basis | string | basis=contract_price - index_price | ||
basis_rate | string | basis_rate=basis/index_price | ||
</tick> | ||||
ts | long | Time of Respond Generation, unit: millisecond |
[General] Request Basis Data
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.
To subscribe basis data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"req": "market.$contract_code.basis.$period.$basis_price_type",
"id": "id generated by client",
"from": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00",
"to": "type: long, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00 .Larger than 'from' value. "
}
Example of a successful subscribe request
{
"req": "market.btc-usdt.basis.1min.open",
"id": "id4",
"from":1571000000,
"to":1573098606
}
Request Parameter
Parameter Name | Required | Type | Desc |
---|---|---|---|
req | true | string | the themes that need to be subscribed; the interface is fixed at: market.$contract_code.basis.$period.$basis_price_type,For parameter details please check req Subscribe Parameter Rules |
id | false | string | id automatically generated by the business party |
from | true | long | start time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds |
to | true | long | end time, from 2017-07-28T00:00:00+08:00 to 2050-01-01T00:00:00+08:00. timestamp unit:seconds. larger than 'from' value |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... or BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ | |
period | true | string | kline type | 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" |
Note:
- 2000 data at most per request.
response example:
{
"data":[
{
"basis":"-27.593412766666006",
"basis_rate":"-0.0021317871729511838",
"contract_price":"12916.2",
"id":1603641600,
"index_price":"12943.793412766667"
}
],
"id":"id4",
"rep":"market.BTC-USDT.basis.15min.open",
"status":"ok",
"ts":1603783024207,
"wsid":1308653018
}
Response Parameters
parameter name | Required | Type | Desc | Value Range |
---|---|---|---|---|
rep | true | string | Data belonged channel Format: market.basis | |
status | true | string | Return Statu | "ok" , "error" |
id | true | string | Request ID | |
wsid | true | long | wsid | |
ts | true | long | Time of Respond Generation, unit: millisecond | |
<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> |
[General]Subscribe Kline Data of Mark 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; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
After connected WebSocket API server, send data as follow:
{
"sub": "market.$contract_code.mark_price.$period",
"id": "id generate by client"
}
Example:
{
"sub": "market.BTC-USDT.mark_price.1min",
"id": "id1"
}
Request Parameter
Parameter Name | Required | Type | Description | Default Value |
---|---|---|---|---|
sub | true | string | topic, format as: market.$contract_code.mark_price.$period, too more detail to see sub Subscribe Parameter Rules | |
id | false | string | optional; unique ID in client side |
sub Subscribe Parameter Rules
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | 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 |
When the marked price is updated, the client will receive the data, for example:
{
"ch": "market.BTC-USDT.mark_price.1min",
"ts": 1489474082831,
"tick":
{
"vol": "0",
"close": "9800.12",
"count": "0",
"high": "9800.12",
"id": 1529898780,
"low": "9800.12",
"open": "9800.12",
"trade_turnover": "0",
"amount": "0"
}
}
Returning Parameter
Parameter Name | Required | Type | Description | Default Value | Value Range |
---|---|---|---|---|---|
ch | true | string | channel, format: market.period | ||
<tick> | 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 | ||
</tick> | |||||
ts | true | number | Time of Respond Generation, Unit: Millisecond |
[General]Request Kline Data of Mark 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; and supports contract type: BTC-USDT, BTC-USDT-CW, BTC-USDT-NW, BTC-USDT-CQ, BTC-USDT-NQ.
After connected WebSocket API server, send data as follow:
{
"req": "market.$contract_code.mark_price.$period",
"id": "id generated by client",
"from": " type: long, unit: second "
"to": "type: long, unit: second, must greater than from "
}
Example:
{
"req": "market.BTC-USDT.mark_price.5min",
"id": "id4",
"from": 1579247342,
"to": 1579247342
}
Request Parameter
Parameter Name | Required | Type | Description | Default Value |
---|---|---|---|---|
req | true | string | topic, format as: market.$contract_code.mark_price.$period, too more detail to see req Request Parameter Rules | |
id | false | string | optional; unique ID in client side | |
from | true | long | start time | |
to | true | long | end time |
req Request Parameter Rules
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | 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 |
Note
- At one time 2000 at most
- from and to both are Required
Example of successful response:
{
"rep": "market.BTC-USDT.mark_price.1min",
"status": "ok",
"id": "id4",
"wsid": 1231323423,
"ts": 1579489028884,
"data": [
{
"vol": "0",
"close": "9800.12",
"count": "0",
"high": "9800.12",
"id": 1529898780,
"low": "9800.12",
"open": "9800.12",
"trade_turnover": "0",
"amount": "0"
}
]
}
Returning Parameter
Parameter Name | Required | Type | Description | Default Value | Value Range |
---|---|---|---|---|---|
req | true | string | channel, format: market.period | ||
status | true | string | status | "ok" , "error" | |
id | true | string | id | ||
wsid | true | long | wsid | ||
ts | true | number | Time of Respond Generation, Unit: Millisecond | ||
<data> | true | object array | |||
id | true | long | kline 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> |
Orders and Accounts WebSocket Interfaces
[Isolated] Subscribe Order Data(sub)
Remarks
- This interface only supports isolated margin mode.
To subscribe order data, Clients have to make connection to the Server and send subscribe request in the format below:
Subscribe Request Format
{
“op”: “sub”,
"cid": "id generated by client”,
“topic": "orders.$contract_code”
}
Example of a successful subscribe request:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "orders.BTC-USDT"
}
Data format illustration of orders subscription
Field Name | Type | Description |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required;format: orders.$contract_code; For parameter details please check req Subscribe Parameter |
sub Subscribe Parameter Rules
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to subscribe the all orders) "BTC-USDT","ETH-USDT"... |
Illustration on detailed data format of orders Notification
{
"op": "notify",
"topic": "orders.btc-usdt",
"ts": 1489474082831,
"uid": "123456789",
"symbol": "BTC",
"contract_code": "BTC-USDT",
"volume": 111,
"price": 1111,
"order_price_type": "limit",
"direction": "buy",
"offset": "open",
"status": 6,
"lever_rate": 10,
"order_id":758684042347171840,
"order_id_str":"758684042347171840",
"client_order_id": 10683,
"order_source": "web",
"order_type": 1,
"created_at": 1408076414000,
"trade_volume": 1,
"trade_turnover": 1200,
"fee": 0,
"liquidation_type": "0",
"trade_avg_price": 10,
"margin_asset": "USDT",
"margin_frozen": 10,
"profit": 2,
"canceled_at": 1408076414000,
"fee_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0,
"trade": [{
"trade_id":14469,
"id":"14469-758684042347171840-1",
"trade_volume": 1,
"trade_price": 123.4555,
"trade_fee": 0.234,
"fee_asset": "USDT",
"trade_turnover": 34.123,
"created_at": 1490759594752,
"real_profit": 0,
"profit": 2,
"role": "maker"
}]
}
Format Illustration on return data of order push
Filed Name | Type | Description |
---|---|---|
op | string | Required;Operator Name,Order push value is notify ; |
topic | string | Required; Order push topic |
uid | string | account uid |
ts | long | Server responses timestamp |
symbol | string | symbol |
contract_code | string | Contract Code |
volume | decimal | Order quantity |
price | decimal | Order price |
order_price_type | string | "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 |
direction | string | "buy" Long "sell": Short |
offset | string | "open": Open "close": Close, "both" |
status | int | Order status(1. Placing orders to order book; 2 Placing orders to order book; 3. Placed to order book 4. Partially filled; 5 partially filled but cancelled by client; 6. Fully filled; 7. Cancelled; 11Cancelling) |
lever_rate | int | Leverage |
order_id | long | Order ID |
order_id_str | string | Order ID |
client_order_id | long | Client ID |
order_source | string | Order source(system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl) |
order_type | int | Order type 1Requested orders; 2. Cancelled orders; 3. Liquidated orders; 4. Delivered orders |
created_at | long | order creation time |
trade_volume | decimal | trade volume(coin)) |
trade_turnover | decimal | Turnover |
fee | decimal | Fees |
trade_avg_price | decimal | Average order price |
margin_frozen | decimal | Frozen Margin |
margin_asset | string | margin_asset |
profit | decimal | total profit or loss of order when close position (calculated with the average price of position, exclude profit in history settlement.) |
liquidation_type | string | Liquidation type, 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
canceled_at | long | Canceled time |
fee_asset | string | the corresponding cryptocurrency to the given fee |
margin_mode | string | margin mode isolated : "isolated" |
margin_account | string | margin account "BTC-USDT"... |
is_tpsl | int | whether to set take-profit and stop-loss order 1:yes;0:no |
real_profit | decimal | total real profit of order (calculated with the opening average price, include profit in history settlement.) |
reduce_only | int | reduce only 0: no, 1: yes |
<trade> | ||
id | string | the global unique ID of the trade. |
trade_id | long | In this interface, trade_id is the same with match_id of linear-swap-api/v1/swap_matchresults. trade_id is the result of sets of order execution and trade confirmation. NOTE: trade_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same trade_id. |
trade_volume | decimal | trade volume |
trade_price | decimal | trade price |
trade_fee | decimal | trading fees |
trade_turnover | decimal | turnover |
created_at | long | trade creation time |
role | string | taker or maker |
real_profit | decimal | real profit of the transaction (calculated with the opening average price, include profit in history settlement.) |
profit | decimal | profit or loss of the transaction (calculated with the average price of position, exclude profit in history settlement.) |
fee_asset | string | the corresponding cryptocurrency to the given fee |
</trade> |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And the real profit (real_profit) of the transaction information that orders traded after December 10, 2020 has a value.
[Isolated] Unsubscribe Order Data(unsub)
Remarks
- This interface only supports isolated margin mode.
To unsubscribe order data, the clients have to make connection to the server and send unsubscribe request in the format below:
Format of Unsubscribe order data
{
“op”: “unsub”,
“topic": "orders.$contract_code”,
"cid": "id generated by client”,
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "orders.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format illustration of unsubscribe order data
Field Name | Type | Description |
---|---|---|
op | string | Required; Operator Name,value for unsubscribe is unsub; |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required;Unsubscribe Topic Name, format: orders.$contract_code; For parameter details please check req Subscribe Parameter |
sub Subscribe Parameter Rules
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to unsubscribe the all orders) "BTC-USDT","ETH-USDT"... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe( unsub ) | Rule |
---|---|---|
orders.* | orders.* | Allowed |
orders.contract_code1 | orders.* | Allowed |
orders.contract_code1 | orders.contract_code2 | Allowed |
orders.contract_code1 | orders.contract_code2 | Not Allowed |
orders.* | orders.contract_code1 | Not Allowed |
[Cross] Subscribe Order Data(sub)
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.
To subscribe order data, Clients have to make connection to the Server and send subscribe request in the format below:
Subscribe Request Format
{
"op": "sub",
"cid": "cid",
"topic": "orders_cross.$contract_code"
}
Example of a successful subscribe request:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "orders_cross.btc-usdt"
}
Data format illustration of orders subscription
Field Name | Type | Description |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required;format: orders_cross.$contract_code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: * (swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Illustration on detailed data format of orders Notification
{
"contract_type":"swap",
"pair":"BTC-USDT",
"business_type":"swap",
"op":"notify",
"topic":"orders_cross.btc-usdt",
"ts":1639107468139,
"symbol":"BTC",
"contract_code":"BTC-USDT",
"volume":1,
"price":48284.9,
"order_price_type":"opponent",
"direction":"buy",
"offset":"open",
"status":6,
"lever_rate":5,
"order_id":918828846806306816,
"order_id_str":"918828846806306816",
"client_order_id":null,
"order_source":"api",
"order_type":1,
"created_at":1639107468086,
"trade_volume":1,
"trade_turnover":48.2849,
"fee":-0.01931396,
"trade_avg_price":48284.9,
"margin_frozen":0,
"profit":0,
"trade":[
{
"trade_fee":-0.01931396,
"fee_asset":"USDT",
"real_profit":0,
"profit":0,
"trade_id":86875552122,
"id":"86875552122-918828846806306816-1",
"trade_volume":1,
"trade_price":48284.9,
"trade_turnover":48.2849,
"created_at":1639107468102,
"role":"taker"
}
],
"canceled_at":0,
"fee_asset":"USDT",
"margin_asset":"USDT",
"uid":"123456789",
"liquidation_type":"0",
"margin_mode":"cross",
"margin_account":"USDT",
"is_tpsl":1,
"real_profit":0,
"reduce_only": 0
}
Pushed Data Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
op | true | string | operation name, fixed as notify | |
topic | true | string | topic | |
ts | true | long | server response timestamp | |
uid | true | string | uid | |
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 | place volume | |
price | true | decimal | place price | |
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 |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
status | true | int | order status | 1. Placing orders to order book; 2 Placing orders to order book; 3. Placed to order book 4. Partially filled; 5 partially filled but cancelled by client; 6. Fully filled; 7. Cancelled; 11Cancelling |
lever_rate | true | int | leverage | |
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
client_order_id | true | long | client order ID | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_type | true | int | order type | 1. Requested orders; 2. Cancelled orders; 3. Liquidated orders; 4. Delivered orders |
created_at | true | long | created time | |
trade_volume | true | decimal | trade total amount | |
trade_turnover | true | decimal | trade amount | |
fee | true | decimal | service fee | |
trade_avg_price | true | decimal | trade average price | |
margin_asset | true | string | margin asset | |
margin_frozen | true | decimal | frozen margin | |
profit | true | decimal | total profit or loss of order when close position (calculated with the average price of position, exclude profit in history settlement.) | |
liquidation_type | true | decimal | liquidation type 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated | |
canceled_at | true | long | canceled time | |
fee_asset | true | string | fee asset | “USDT” |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | total real profit of order (calculated with the opening average price, include profit in history 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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
<trade> | true | object array | ||
id | true | string | the global unique ID of the trade. | |
trade_id | true | long | In this interface, trade_id is the same with match_id of linear-swap-api/v1/swap_cross_matchresults. trade_id is the result of sets of order execution and trade confirmation. NOTE: trade_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same trade_id. | |
trade_volume | true | decimal | trade quantity | |
trade_price | true | decimal | trade price | |
trade_fee | true | decimal | trade fee | |
trade_turnover | true | decimal | trade amount | |
created_at | true | long | trade time | |
role | true | string | taker/maker | |
real_profit | true | decimal | real profit of the transaction (calculated with the opening average price, include profit in history settlement.) | |
profit | true | decimal | profit or loss of the transaction (calculated with the average price of position, exclude profit in history settlement.) | |
fee_asset | true | string | fee asset | “USDT” |
</trade> |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And the real profit (real_profit) of the transaction information that orders traded after December 10, 2020 has a value.
[Cross] Unsubscribe Order Data(unsub)
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.
To unsubscribe order data, the clients have to make connection to the server and send unsubscribe request in the format below:
Format of Unsubscribe order data
{
"op": "unsub",
"topic": "orders_cross.$contract_code",
"cid": "id generated by client",
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "orders_cross.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format illustration of unsubscribe order data
Filed | Type | Description |
---|---|---|
op | string | Required;Operator Name,value for unsubscribe is unsub; |
cid | string | Optional; Client requests unique ID |
topic | string | Required; Unsubscribe Topic Name,format: orders_cross.$contract_code; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe( unsub ) | Rule |
---|---|---|
orders_cross.* | orders_cross.* | Allowed |
orders_cross.contract_code1 | orders_cross.* | Allowed |
orders_cross.contract_code1 | orders_cross.contract_code2 | Allowed |
orders_cross.contract_code1 | orders_cross.contract_code2 | Not Allowed |
orders_cross.* | orders_cross.contract_code1 | Not Allowed |
[Isolated] Subscribe Match Order Data(sub)
Remarks
- This interface only supports isolated margin mode.
To subscribe order data, Clients have to make connection to the Server and send subscribe request in the format below:
Subscribe Request Format
{
“op”: “sub”,
"cid": "cid”,
“topic": "matchOrders.$contract_code”
}
sub example:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "matchOrders.btc-usdt"
}
Format of subscribe match order data
attr | type | desc |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; subscribe Topic Name,format: matchOrders.$contract_code; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to subscribe the all match orders) "BTC-USDT"... |
Note:
- The order status of 'post_only' type pushed by ws is ethier '7:canceled' or '3:submitted'.
- The orders will be pushed when matched by matching engine.
- The delivery orders will not be pushed.
- The orders transfered from future or to future will not be pushed.
- The netting and forced liquidation orders will not be pushed.
- The orders will generally be pushed faster than the normal orders subscription.But It's not guranted.
- If there is an order with N trades,including 1 taker and N maker,it will push N+1 trades at most.
Illustration on detailed data format of orders Notification
response
{
"op":"notify",
"topic":"matchOrders.btc-usdt",
"ts":1600926986125,
"symbol":"BTC",
"contract_code":"BTC-USDT",
"status":6,
"order_id":758688290195656704,
"order_id_str":"758688290195656704",
"client_order_id":null,
"order_type":1,
"created_at":1600926984112,
"trade":[
{
"trade_id":14470,
"id":"14470-758688290195656704-1",
"trade_volume":1,
"trade_price":10329.11,
"trade_turnover":103.2911,
"created_at":1600926986046,
"role":"taker"
}
],
"uid":"123456789",
"volume":1,
"trade_volume":1,
"direction":"buy",
"offset":"open",
"lever_rate":5,
"price":10329.11,
"order_source":"web",
"order_price_type":"opponent",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"is_tpsl": 0,
"reduce_only": 0
}
format of order data pushed
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
op | true | string | notify | |
topic | true | string | topic | |
ts | true | long | server response timestamp | |
uid | true | string | account uid | |
symbol | true | string | symbol | "BTC","ETH"... |
contract_code | true | string | contract code | |
status | true | int | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; | |
order_id | true | long | order id | |
order_id_str | true | string | order id | |
client_order_id | true | long | client order id | |
order_type | true | int | order_type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
trade_volume | true | decimal | trade volume | |
volume | true | decimal | volume | |
direction | true | string | direction | "buy" : "sell" |
offset | true | string | offset | "open", "close", "both" |
lever_rate | true | int | lever rate | |
price | true | decimal | price | |
created_at | true | long | created time | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | "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 |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
reduce_only | true | int | reduce only | 0: no, 1: yes |
<trade> | true | object array | ||
id | true | string | the global unique id of the trade. | |
trade_id | true | long | In this interface, trade_id is the same with match_id of linear-swap-api/v1/swap_matchresults. trade_id is the result of sets of order execution and trade confirmation. NOTE: trade_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same trade_id. | |
trade_price | true | decimal | trade price | |
trade_volume | true | decimal | trade volume(cont) | |
trade_turnover | true | decimal | trade turnover | |
created_at | true | long | created time | |
role | true | string | taker or maker | |
</trade> |
[Isolated] Unsubscribe Match Order Data(unsub)
Remarks
- This interface only supports isolated margin mode.
To unsubscribe order data, the clients have to make connection to the server and send unsubscribe request in the format below:
Format of Unsubscribe order data
{
“op”: “unsub”,
“topic": "matchOrders.$contract_code”,
"cid": "id generated by client”,
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "matchOrders.btc-usdt",
"cid": "40sG903yz80oDFWr"
}
Format illustration of unsubscribe order data
attr | type | desc |
---|---|---|
op | string | Required; Operator Name,value for unsubscribe is unsub; |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; Unsubscribe Topic Name,format: matchOrders.$contract_code; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to unsubscribe the all match orders) "BTC-USDT"... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe( unsub) ) | Rule |
---|---|---|
matchOrders.* | matchOrders.* | allowed |
matchOrders.contract_code1 | matchOrders.* | Allowed |
matchOrders.contract_code1 | matchOrders.contract_code1 | allowed |
matchOrders.contract_code1 | matchOrders.contract_code2 | Not Allowed |
matchOrders.* | matchOrders.contract_code1 | Not Allowed |
[Cross] Subscribe Match Order Data(sub)
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.
To subscribe order data, Clients have to make connection to the Server and send subscribe request in the format below:
Subscribe Request Format
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "matchOrders_cross.$contract_code"
}
Example of a successful ubscribe request:
{
"op": "sub",
"topic": "matchOrders_cross.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format of subscribe match order data
attr | type | desc |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required;format: matchOrders_cross.$contract_code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Note:
- The order status of 'post_only' type pushed by ws is ethier '7:canceled' or '3:submitted'.
- The orders will be pushed when matched by matching engine.
- The delivery orders will not be pushed.
- The orders transfered from future or to future will not be pushed.
- The netting and forced liquidation orders will not be pushed.
- The orders will generally be pushed faster than the normal orders subscription.But It's not guranted.
- If there is an order with N trades,including 1 taker and N maker,it will push N+1 trades at most.
response
{
"contract_type":"swap",
"pair":"BTC-USDT",
"business_type":"swap",
"op":"notify",
"topic":"matchOrders_cross.btc-usdt",
"ts":1639705640671,
"uid":"123456789",
"symbol":"BTC",
"contract_code":"BTC-USDT",
"status":6,
"order_id":921337601229725696,
"order_id_str":"921337601229725696",
"client_order_id":null,
"order_type":1,
"volume":1,
"trade_volume":1,
"created_at":1639705601752,
"direction":"sell",
"offset":"open",
"lever_rate":5,
"price":47800,
"order_source":"web",
"order_price_type":"limit",
"trade":[
{
"trade_id":87890603387,
"id":"87890603387-921337601229725696-1",
"trade_volume":1,
"trade_price":47800,
"trade_turnover":47.8,
"created_at":1639705640641,
"role":"maker"
}
],
"margin_mode":"cross",
"margin_account":"USDT",
"is_tpsl":1,
"reduce_only": 0
}
Pushed Data Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
op | true | string | operaton name, fixed as notify; | |
topic | true | string | topic | |
ts | true | long | server response timestamp | |
uid | true | string | uid | |
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"... |
status | true | int | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; | |
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
client_order_id | true | long | client order ID | |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
trade_volume | true | decimal | trade volume | |
volume | true | decimal | order volume | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
lever_rate | true | int | leverage | |
price | true | decimal | place price | |
created_at | true | long | created time | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
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 |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
<trade> | true | object array | ||
id | true | string | the global unique id of the trade | |
trade_id | true | long | In this interface, trade_id is the same with match_id of linear-swap-api/v1/swap_cross_matchresults. trade_id is the result of sets of order execution and trade confirmation. NOTE: trade_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same trade_id. | |
trade_price | true | decimal | trade price | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade amount | |
created_at | true | long | created time | |
role | true | string | taker/maker | |
</trade> |
[Cross] Unsubscribe Match Order Data(unsub)
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.
To unsubscribe order data, the clients have to make connection to the server and send unsubscribe request in the format below:
Format of Unsubscribe order data
{
"op": "unsub",
"topic": "matchOrders_cross.$contract_code",
"cid": "id generated by client",
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "matchOrders_cross.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format illustration of unsubscribe order data
Filed | Type | Description |
---|---|---|
op | string | Required;Operator Name,value for unsubscribe is unsub; |
cid | string | Optional; Client requests unique ID |
topic | string | Required;Unsubscribe Topic Name, format: matchOrders_cross.$contract_code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe( unsub) ) | Rule |
---|---|---|
matchOrders_cross.* | matchOrders_cross.* | allowed |
matchOrders_cross.contract_code1 | matchOrders_cross.* | allowed |
matchOrders_cross.contract_code1 | matchOrders_cross.contract_code1 | allowed |
matchOrders_cross.contract_code1 | matchOrders_cross.contract_code2 | Not Allowed |
matchOrders_cross.* | matchOrders_cross.contract_code1 | Not Allowed |
[Isolated] Subscribe Account Equity Updates Data(sub)
Remarks
- This interface only supports isolated margin mode.
To subscribe accounts equity data updates, the client has to make connection to the server and send subscribe request in the format below:
Request Format for Subscribe Account Equity Updates Data
{
"op": "sub",
"cid": "id generated by client”,
“topic": "accounts.$contract_code”
}
Example of a successful subscribe request:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "accounts.BTC-USDT"
}
Format illustration on request subscribe account equity updates data
Filed | Type | Description |
---|---|---|
op | string | Required;Operator Name,Operator Name,Subscribe value is sub |
cid | string | Optional; Client requests unique ID |
topic | string | Required;subscribe Topic Name, format: accounts.$contract_code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to subscribe the balance change of all coins), "BTC-USDT"... |
Note:
- A regular push of account is performed every 5 sedconds.The event field of the reponse is "snapshot".If there is a push in 5 seconds, snapshot push will be skipped.
When there is any balance change, the Server will send a notification with the return parameter. For example:
{
"op":"notify",
"topic":"accounts.btc-usdt",
"ts":1603711370689,
"event":"order.open",
"data":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"margin_balance":79.72434662,
"margin_static":79.79484662,
"margin_position":1.31303,
"margin_frozen":4.0662,
"margin_available":74.34511662,
"profit_real":0.03405608,
"profit_unreal":-0.0705,
"withdraw_available":74.34511662,
"risk_rate":14.745772976801512484,
"liquidation_price":92163.420962779156327543,
"lever_rate":10,
"adjust_factor":0.075,
"margin_asset":"USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"uid":"123456789"
}
Format Illustration of Notification
Field Name | Type | Description |
---|---|---|
op | string | Operator Name,Subscribe value is sub |
topic | string | Subscribe Topic Name |
uid | string | account uid |
ts | long | Time of Respond Generation, Unit: Millisecond |
event | string | notification on account asset change such as commit order(order.open), fulfill order(order.match)(excluding liquidated order and settled orders), settlement and delivery(settlement), fulfill liquidation order(order.liquidation)(including voluntarily fulfilled liquidation order and the fulfilled liquidation order taken over by system ) , cancel order(order.cancel), asset transfer(contract.transfer) (ncluding transfer with exchange accounts, transfer between main account and sub-account, and tranfer between different margin accounts.), system (contract.system), other asset change(other), switch leverage(switch_lever_rate), initial margin(init), ADL trade |
<data> | ||
symbol | string | Coins. "BTC","ETH"... |
contract_code | string | Contract Code |
margin_asset | string | margin asset |
margin_balance | decimal | Account Equity |
margin_static | decimal | Static Equity |
margin_position | decimal | Position Margi(the margin for holding currenty positions) |
margin_frozen | decimal | Frozen Margin |
margin_available | decimal | Available Margin |
profit_real | decimal | Realized Profits&Losses |
profit_unreal | decimal | Unrealized Profits&Losses |
risk_rate | decimal | Margin Ratio |
liquidation_price | decimal | Liquidation Price |
withdraw_available | decimal | Assets available to withdraw |
lever_rate | int | Leverage |
adjust_factor | decimal | Adjustment Factor |
margin_mode | string | margin mode isolated : "isolated" |
margin_account | string | margin account "BTC-USDT"... |
position_mode | string | position mode single_side,dual_side |
</data> |
[Isolated] Unsubscribe Account Equity Updates Data (ubsub)
Remarks
- This interface only supports isolated margin mode.
To unsubscribe account equity updates data, the client has to make connection to the server and send unsubscribe request in the format below:
Request Format of Unsubscribe Account Equity Updates Data
{
“op”: “unsub”,
“topic": "accounts.$contract_code”,
"cid": "id generated by client”,
}
Example of a successful subscription request
{
"op": "unsub",
"topic": "accounts.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format Illustration on Unsubscribe Account Equity Updates
Filed | Type | Description |
---|---|---|
op | string | Required;Operator Name,value for unsubscribe is unsub; |
cid | string | Optional; Client requests unique ID |
topic | string | Required;unsubscribe Topic Name, format: accounts.$contract_code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to unsubscribe the balance change of all coins), "BTC-USDT"... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe(unsub) | Rule |
---|---|---|
accounts.* | accounts.* | Allowed |
accounts.contract_code1 | accounts.* | Allowed |
accounts.contract_code1 | accounts.contract_code1 | Allowed |
accounts.contract_code1 | accounts.contract_code2 | Not Allowed |
accounts.* | accounts.contract_code1 | Not Allowed |
[Cross] Subscribe Account Equity Updates Data(sub)
Remarks
- The interface only supports cross margin mode.
To subscribe accounts equity data updates, the client has to make connection to the server and send subscribe request in the format below:
Request Format for Subscribe Account Equity Updates Data
{
"op": "sub",
"topic": "accounts_cross.$margin_account",
"cid": "id generated by client",
}
Example of a successful subscribe request:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "accounts_cross.USDT"
}
Subscribe Request Parameter
Filed | Type | Description |
---|---|---|
op | string | Required;Operator Name,Subscribe value is sub |
cid | string | Optional; Client requests unique ID |
topic | string | Required;subscribe Topic Name, format: accounts_cross.$margin_account; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
margin_account | true | string | margin account | "*" all(it means to subscribe the balance change of all coins), "USDT"... |
Note:
- A regular push of account is performed every 5 sedconds.The event field of the reponse is "snapshot".If there is a push in 5 seconds, snapshot push will be skipped.
When there is any balance change, the Server will send a notification with the return parameter. For example:
{
"op":"notify",
"topic":"accounts_cross",
"ts":1640756528985,
"event":"snapshot",
"data":[
{
"margin_mode":"cross",
"margin_account":"USDT",
"margin_asset":"USDT",
"margin_balance":20.60340161555383535,
"margin_static":20.47570161555383535,
"margin_position":19.30352,
"margin_frozen":0,
"profit_real":-0.01911684,
"profit_unreal":0.1277,
"withdraw_available":1.17218161555383535,
"risk_rate":25.683477437733940947,
"position_mode": "dual_side",
"contract_detail":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"margin_position":9.55638,
"margin_frozen":0,
"margin_available":1.29988161555383535,
"profit_unreal":-0.0102,
"liquidation_price":27790.709661740085332661,
"lever_rate":5,
"adjust_factor":0.04,
"contract_type":"swap",
"pair":"BTC-USDT",
"business_type":"swap"
}
],
"futures_contract_detail":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT-220325",
"margin_position":9.74714,
"margin_frozen":0,
"margin_available":1.29988161555383535,
"profit_unreal":0.1379,
"liquidation_price":28744.509661740085332661,
"lever_rate":5,
"adjust_factor":0.04,
"contract_type":"quarter",
"pair":"BTC-USDT",
"business_type":"futures"
}
]
}
],
"uid":"123456789"
}
Pushed Data Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
op | true | string | operaton name, fixed as notify; | |
topic | true | string | topic | |
ts | true | long | server response timestamp | |
uid | true | string | uid | |
event | true | string | event of margin account update | order.open 、order.match 、settlement、order.liquidation、order.cancel 、contract.transfer、ontract.system、other 、init、napshot 、ADL trade |
<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-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> |
[Cross] Unsubscribe Account Equity Updates Data(unsub)
Remarks
- The interface only supports cross margin mode.
To unsubscribe account equity updates data, the client has to make connection to the server and send unsubscribe request in the format below:
Request Format of Unsubscribe Account Equity Updates Data
{
"op": "unsub",
"topic": "accounts_cross.$margin_account",
"cid": "id generated by client",
}
Example of a successful subscription request
{
"op": "unsub",
"topic": "accounts_cross.USDT",
"cid": "40sG903yz80oDFWr"
}
Unsubscribe Request Parameter
Filed | Type | Description |
---|---|---|
op | string | Required;Operator Name,Unsubscribe value is unsub |
cid | string | Optional; Client requests unique ID |
topic | string | Required;unsubscribe Topic Name, format: accounts_cross.$margin_account; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
margin_account | true | string | margin account | "*" all(it means to unsubscribe the balance change of all coins), "USDT"... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe(unsub) | Rule |
---|---|---|
accounts_cross.* | accounts_cross.* | Allowed |
accounts_cross.margin_account1 | accounts_cross.* | Allowed |
accounts_cross.margin_account1 | accounts_cross.margin_account1 | Allowed |
accounts_cross.margin_account1 | accounts_cross.margin_account2 | Not Allowed |
accounts_cross.* | accounts_cross.margin_account1 | Not Allowed |
[Isolated] Subscribe Position Updates(sub)
Remarks
- This interface only supports isolated margin mode.
To subscribe position updates data, the client has to make connection to the server and send subscribe request in the format below:
Subscribe Request Format
{
“op”: “sub”,
"cid": "id generated by client”,
“topic": "positions.$contract_code”
}
Example of a successful subscribe request:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "positions.BTC-USDT"
}
Format Illustration of Subscribe Position Updates
Filed Name | type | desc |
---|---|---|
op | string | Required; Operator Name,Subscribe value is sub; |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; subscribe Topic Name,format: positions.$contract_code; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to subscribe the all positions) "BTC-USDT"... |
When there is any position update, the server will send notification with return parameter. For example:
{
"op":"notify",
"topic":"positions",
"ts":1603711371803,
"event":"snapshot",
"data":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"volume":1,
"available":0,
"frozen":1,
"cost_open":13059.8,
"cost_hold":13059.8,
"profit_unreal":-0.0705,
"profit_rate":-0.05398244996094886,
"profit":-0.0705,
"position_margin":1.31303,
"lever_rate":10,
"direction":"sell",
"last_price":13130.3,
"margin_asset":"USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"position_mode": "dual_side"
}
],
"uid":"123456789"
}
Return Parameter Illustration
Filed Name | Type | Description |
---|---|---|
op | string | Required;Operator Name ; |
topic | string | Required; topic |
uid | string | account uid |
ts | long | Time of Respond Generation, Unit: Millisecond |
event | string | Related events of position change notification, such as order creation and position closing (order.close), order filled (order.match) (except for liquidation, settlement and delivery), settlement and delivery (settlement), order liquidation (order.liquidation), order cancellation (order.cancel), switch leverage(switch_lever_rate), initial positions (init), triggered by system periodic push (snapshot). , ADL trade |
<data> | ||
symbol | string | Coin. "BTC","ETH"... |
contract_code | string | Contract Code |
volume | decimal | Open Interest |
available | decimal | Positions available to close |
frozen | decimal | Frozen Margin |
cost_open | decimal | Open price |
cost_hold | decimal | Position Price |
profit_unreal | decimal | Unrealized Profits&Losses |
profit_rate | decimal | Profit/Losses Ratio |
profit | decimal | Profits/Losses |
position_margin | decimal | Position Margin |
lever_rate | int | Leverage |
direction | string | transaction direction of positions "buy":long "sell":short |
last_price | decimal | Last Price |
margin_asset | string | Margin Asset |
margin_mode | string | margin mode isolated : "isolated" |
margin_account | string | margin account "BTC-USDT"... |
position_mode | string | position mode single_side,dual_side |
</data> |
Note:
A regular push of position is performed every 5 sedconds.The event field of the reponse is "snapshot".If there is a push in 5 seconds, snapshot push will be skipped.
When switching leverage with no positions, the event "switch_lever_rate" will not be pushed by the position topic.
In the one-way position mode: only push the data of contract which with the position (that is, only push the data of the one-way non-empty position), if there is no position, it will not be pushed
[Isolated] Unsubscribe Position Updates Data(unsub)
Remarks
- This interface only supports isolated margin mode.
To unsubscribe, the client has to make connection to the server and send unsubscribe request in the format below:
Request Format of Unsubscribe Position Updates
{
“op”: “unsub”,
“topic": "positions.$contract_code”,
"cid": "id generated by client”,
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "positions.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format Illustration of Unsubscribe Position Updates
Filed Name | type | desc |
---|---|---|
op | string | Required; Operator Name,unsubscribe value is unsub; |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; unsubscribe Topic Name,format: positions.$contract_code; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to unsubscribe the all positions) "BTC-USDT"... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe(ubsub) | Rule |
---|---|---|
positions.* | positions.* | Allowed |
positions.contract_code1 | positions.* | Allowed |
positions.contract_code1 | positions.contract_code1 | Allowed |
positions.contract_code1 | positions.contract_code2 | Not Allowed |
positions.* | positions.symbol1 | Not Allowed |
[Cross] Subscribe Position Updates(sub)
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.
To subscribe position updates data, the client has to make connection to the server and send subscribe request in the format below:
Subscribe Request Format
{
"op": "sub",
"topic": "positions_cross.$contract_code",
"cid": "topic to sub"
}
Example of a successful subscribe request:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "positions_cross.BTC-USDT"
}
Format Illustration of Subscribe Position Updates
Filed Name | Type | Description |
---|---|---|
op | string | Required;Operator Name,Subscribe value is sub |
cid | string | Optional ; Client requests unique ID |
topic | string | Required; Subscribe Topic, Subscribe (positions_cross.$contract_code) Required Subscribe/unsubscribe the position data of a single coin, For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
When there is any position update, the server will send notification with return parameter. For example:
{
"op":"notify",
"topic":"positions_cross.btc-usdt",
"ts":1639107468139,
"event":"order.match",
"data":[
{
"contract_type":"swap",
"pair":"BTC-USDT",
"business_type":"swap",
"symbol":"BTC",
"contract_code":"BTC-USDT",
"volume":1,
"available":1,
"frozen":0,
"cost_open":48284.9,
"cost_hold":48284.9,
"profit_unreal":-0.0001,
"profit_rate":-0.000010355204214985,
"profit":-0.0001,
"margin_asset":"USDT",
"position_margin":9.65696,
"lever_rate":5,
"direction":"buy",
"last_price":48284.8,
"margin_mode":"cross",
"margin_account":"USDT",
"position_mode": "dual_side"
}
],
"uid":"123456789"
}
Pushed Data Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
op | true | string | operaton name, fixed as notify; | |
topic | true | string | topic | |
ts | true | long | server response timestamp | |
uid | true | string | uid | |
event | true | string | event | order.close 、order.match、settlement、order.liquidation、order.cancel、init、snapshot、ADL trade |
<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 | positions available to close | |
frozen | true | decimal | positions frozen | |
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 | leverage | |
direction | true | string | transaction direction of positions | "buy":long "sell":short |
last_price | true | decimal | latest trade 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> |
Note:
A regular push of position is performed every 5 sedconds.The event field of the reponse is "snapshot".If there is a push in 5 seconds, snapshot push will be skipped.
When switching leverage with no positions, the event "switch_lever_rate" will not be pushed by the position topic.
In the one-way position mode: only push the data of contract which with the position (that is, only push the data of the one-way non-empty position), if there is no position, it will not be pushed
[Cross] Unsubscribe Position Updates Data(unsub)
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.
To unsubscribe, the client has to make connection to the server and send unsubscribe request in the format below:
Request Format of Unsubscribe Position Updates
{
"op": "unsub",
"topic": "positions_cross.$contract_code",
"cid": "id generated by client",
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "positions_cross.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format Illustration of Unsubscribe Position Updates
Field Name | Type | Description |
---|---|---|
op | string | Required; Operator Name,Subscribe value is unsub; |
cid | string | Optional; Client requests unique ID |
topic | string | Required;Required;Required;Subscribe topic,Subscribe positions_cross.$contract_code required Subscribe or unsubscribe the position updates of a single coin; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe(ubsub) | Rule |
---|---|---|
positions_cross.* | positions_cross.* | Allowed |
positions_cross.contract_code1 | positions_cross.* | Allowed |
positions_cross.contract_code1 | positions_cross.contract_code1 | Allowed |
positions_cross.contract_code1 | positions_cross.contract_code2 | Not Allowed |
positions_cross.* | positions_cross.contract_code1 | Not Allowed |
[General] Subscribe Liquidation Orders (no authentication) (sub)
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.
Subscription Request Format of Liquidation order data
{
“op”: “sub”,
“topic": "public.$contract_code.liquidation_orders”,
"cid": "id generated by client”,
}
Example of a successful subscription request:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "public.BTC-USDT.liquidation_orders"
}
Data format illustration of orders subscription
Field Name | Type | Description |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required;Topic name format: public.$contract_code.liquidation_orders. For parameter details please check req Subscribe Parameter |
business_type | string | business type, default is swap: futures, swap, all |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: *(more see remarks), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Remarks
subscripting * is ok under business_type filled in. when business_type is swap, subscripting * returns all swap contracts; when business_type is futures, subscripting * returns all futures contracts; when business_type is all, subscripting * returns all swap contracts and all futures contracts.
when business_type is swap, subscripting contract code and will get an error msg with 2011 error code. when you have subscribed * and business_type is swap (it means subscripting all swap contracts), which allows you to subscribe * and business_type is all(it means subscripting all swap contracts and all futures contracts). but if the steps reversed, you will get error msg with 2014 error code ; It means that you are allowed to subscribe to a small scope first and then to a large scope, but you are not allowed to subscribe to a large scope and then continue to subscribe to a small scope, because it is meaningless. A large scope already includes a small scope.
When there commences any liquidation order, the server will send notification with return parameter. For example:
{
"op":"notify",
"topic":"public.O3-USDT.liquidation_orders",
"ts":1639122193214,
"data":[
{
"symbol":"O3",
"contract_code":"O3-USDT",
"direction":"sell",
"offset":"close",
"volume":432,
"price":0.7858,
"created_at":1639122193172,
"amount":432,
"trade_turnover":339.4656,
"contract_type":"swap",
"pair":"O3-USDT",
"business_type":"swap"
}
]
}
Return Parameter
Field Name | Type | Description |
---|---|---|
op | string | value: 'notify'; |
topic | string | topic subscribed |
ts | long | Time of Respond Generation,Unit:Millisecond |
<data> | object array | |
symbol | string | symbol |
contract_code | string | swap code swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
direction | string | Long or short |
offset | string | Open, close, both |
volume | decimal | liquidation volume (Cont.) |
amount | decimal | liquidation amount (token) |
trade_turnover | decimal | liquidation amount (quotation token) |
price | decimal | bankruptcy price |
created_at | long | Order Creation Time |
contract_type | string | contract type: swap, this_week, next_week, quarter, next_quarter |
pair | string | pair, such as: “BTC-USDT” |
business_type | string | business type: futures, swap |
</data> | object array |
[General] Unsubscribe Liquidation Order Data (unsub)
Remarks
- The interface supports cross margin mode and isolated margin mode.
Unsubscribe Request Format
{
“op”: “unsub”,
“topic": "public.$contract_code.liquidation_orders”,
"cid": "id generated by client”,
}
Example of a successful unsubscribe request :
{
"op": "unsub",
"topic": "public.BTC-USDT.liquidation_orders”",
"cid": "40sG903yz80oDFWr"
}
Format Illustration of Unsubscribe Position Updates
Field Name | Type | Description |
---|---|---|
op | string | Required; Operator Name,subscribe value is unsub; |
cid | string | Optional; Client requests unique ID |
topic | string | Subscribe topic name,Require subscribe public.$contract_code.liquidation_orders Subscribe/unsubscribe the data of a given coin; For parameter details please check req Subscribe Parameter |
business_type | string | business type, default swap: futures,swap,all |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | all: *(more see remarks), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Note
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
unsubscripting * is ok under business_type filled in. when business_type is swap, unsubscripting * means to unsubscripting all swap contracts; when business_type is futures, unsubscripting * means to unsubscripting all futures contracts;
unsubscription scope must be greater than or equal to the subscription scope and in that it just can be success.
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe(unsub) | Rule |
---|---|---|
public.*.liquidation_orders | public.*.liquidation_orders | Allowed |
public.contract_code1.liquidation_orders | public.*.liquidation_orders | Allowed |
public.contract_code1.liquidation_orders | public.contract_code1.liquidation_orders | Allowed |
public.contract_code1.liquidation_orders | public.contract_code2. liquidation_orders | Not Allowed |
public.*.liquidation_orders | public.contract_code1.liquidation_orders | Not Allowed |
[General] Subscribe funding rate (no authentication)(sub)
Remarks
- The interface supports cross margin mode and isolated margin mode.
To subscribe funding rate data, the client has to make connection to the server and send subscribe request in the format below:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "public.$contract_code.funding_rate"
}
Request
{
"op": "sub",
"topic": "public.BTC-USDT.funding_rate",
"cid": "40sG903yz80oDFWr"
}
Data format illustration of orders subscription
Filed Name | type | desc |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; subscribe Topic Name,format: public.$contract_code.funding_rate; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to subscribe the all funding rate) "BTC-USDT"... |
Response example when funding_rate is updated:
{
"op":"notify",
"topic":"public.BTC-USDT.funding_rate",
"ts":1603778748166,
"data":[
{
"symbol":"BTC",
"contract_code":"BTC-USDT",
"fee_asset":"USDT",
"funding_time":"1603778700000",
"funding_rate":"-0.000220068774978695",
"estimated_rate":"-0.000684397270167616",
"settlement_time":"1603785600000"
}
]
}
Response data fields
Field Name | Type | Description |
---|---|---|
op | string | value: "notify"; |
topic | string | topic subscribed |
ts | long | timestamp of server response.unit: millionseconds |
<data> | object array | |
symbol | string | symbol,"BTC","ETH"... |
contract_code | string | contract_code,"BTC-USDT" |
fee_asset | string | fee asset,"USDT"... |
funding_time | string | current funding time |
funding_rate | string | current funding rate |
estimated_rate | string | estimated funding rate of next period |
settlement_time | string | settlement timestamp.eg:"1490759594752" |
</data> |
[General] Unsubscribe Funding Rate Data(no authentication)(unsub)
Remarks
- The interface supports cross margin mode and isolated margin mode.
To unsubscribe funding rate data, the client has to make connection to the server and send subscribe request in the format below:
request format of unsubscribing funding rate
{
"op": "unsub",
"topic": "public.$contract_code.funding_rate",
"cid": "id generated by client",
}
example of unsubscribing funding rate::
{
"op": "unsub",
"topic": "public.BTC-USDT.funding_rate",
"cid": "40sG903yz80oDFWr"
}
request field desc of unsubscrbing funding rate
Filed Name | type | desc |
---|---|---|
op | string | Required; Operator Name,required unsubscribe value is unsub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; unsubscribe Topic Name,format: public.$contract_code.funding_rate; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to unsubscribe the all funding rate) "BTC-USDT"... |
Data format of subscription and unsubscription of funding rate
subscribe(sub) | unsubscribe(unsub) | rules |
---|---|---|
public.*.funding_rate | pubic.*.funding_rate | allowd |
public.contract_code1.funding_rate | public.*.funding_rate | allowed |
public.contract_code1.funding_rate | public.contract_code1.funding_rate | allowed |
public.contract_code1.funding_rate | public.contract_code2.funding_rate | not allowed |
public.*.funding_rate | public.contract_code1.funding_rate | not allowed |
Note
- Funding rate will be pushed every 60 seconds by default.Funding rate will not be calculated under conditions below:
- the contract can't be traded.eg:Pending Listing、Suspension、Delisting、In settlement、Delivering、Settlement Completed、Delivered,etc.
- the 'update_time' field of index data hasn't been changed over 5 minutes.
- the 'update_time' field of orderbook data hasn't been changed over 5 minutes.
- If the value is equal to last value over 5 continuous counts calculated by md5 of 150 bids data and 150 asks data.
[General] Subscribe Contract Info (no authentication)(sub)
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.
To subscribe contract infodata, the client has to make connection to the server and send subscribe request in the format below:
{
"op": "sub",
"cid": "40sG903yz80oDFWr",
"topic": "public.$contract_code.contract_info"
}
example of unsubscribing funding rate::
{
"op": "sub",
"topic": "public.btc-usdt.contract_info",
"cid": "40sG903yz80oDFWr"
}
Data format illustration of orders subscription
Field Name | Type | Description |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required;Topic name format: public.$contract_code.contract_info. For parameter details please check req Subscribe Parameter |
business_type | string | business type, default is swap , futures, swap, all |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Remarks
subscripting * is ok when business_type filled in. when business_type is swap, subscripting * returns all swap contracts; when business_type is futures, subscripting * returns all futures contracts; when business_type is all, subscripting * returns all swap contracts and all futures contracts.
when business_type is swap, subscripting contract code and will get an error msg with 2011 error code. when you have subscribed * and business_type is swap (it means subscripting all swap contracts), which allows you to subscribe * and business_type is all(it means subscripting all swap contracts and all futures contracts). but if the steps reversed, you will get error msg with 2014 error code ; It means that you are allowed to subscribe to a small scope first and then to a large scope, but you are not allowed to subscribe to a large scope and then continue to subscribe to a small scope, because it is meaningless. A large scope already includes a small scope.
Response example:
{
"op":"notify",
"topic":"public.*.contract_info",
"ts":1639122053894,
"event":"init",
"data":[
{
"symbol":"MANA",
"contract_code":"MANA-USDT",
"contract_size":10,
"price_tick":0.0001,
"settlement_date":"1639123200000",
"create_date":"20210129",
"contract_status":1,
"support_margin_mode":"all",
"delivery_time":"",
"contract_type":"swap",
"business_type":"swap",
"pair":"MANA-USDT",
"delivery_date":""
},
{
"symbol":"NKN",
"contract_code":"NKN-USDT",
"contract_size":10,
"price_tick":0.00001,
"settlement_date":"1639123200000",
"create_date":"20210810",
"contract_status":1,
"support_margin_mode":"all",
"delivery_time":"",
"contract_type":"swap",
"business_type":"swap",
"pair":"NKN-USDT",
"delivery_date":""
}
]
}
Response data fields
Field Name | Type | Description |
---|---|---|
op | string | value: "notify"; |
topic | string | topic subscribed |
ts | long | timestamp of server response.unit: millionseconds |
event | string | event: "init", "update", "snapshot" |
<data> | object array | |
symbol | string | symbol,"BTC","ETH"... |
contract_code | string | contract_code, swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
contract_size | decimal | Contract Value (USDT of one contract). such as 10,100 |
price_tick | decimal | Minimum Variation of Contract Price |
settlement_date | string | settlement date:such as "1490759594752" |
create_date | string | Contract Listing Date :such as "20180706" |
delivery_time | string | delivery time(When the contract does not need to be delivered, the field value is an empty string),millesecond timestamp |
contract_status | 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 | string | support margin mode cross:"cross";isolated:"isolated";all:"all" |
contract_type | string | contract type swap, this_week, next_week, quarter, next_quarter |
pair | string | pair such as: “BTC-USDT” |
business_type | string | business type futures, swap |
delivery_date | string | delivery date, empty string when swap , such as: "20180720" |
</data> | object array |
Note:
- The websocket subscription of contract info event is pushed every 60 seconds, and the event is "snapshot".
- When the subscription is successful, the latest contract information will be pushed immediately, and the event is "init".
- After the subscription is successful, when the contract information changes, the latest contract information will be pushed. When multiple fields changes simultaneously, only the latest contract information will be pushed, and the event is update.
- When the contract status is "delivery completed", the next settlement time of the contract is an empty string.
- Only when the status is 1(Listing), can it be traded normally, other statuses are not tradable;
[General] Unsubscribe Contract Info Data(no authentication)(unsub)
Remarks
- The interface supports cross margin mode and isolated margin mode.
To unsubscribe contract info data, the client has to make connection to the server and send subscribe request in the format below:
request format of unsubscribing contract info
{
"op": "unsub",
"topic": "public.$contract_code.contract_info",
"cid": "id generated by client",
}
example of unsubscribing contract info::
{
"op": "unsub",
"topic": "public.BTC-USDT.contract_info",
"cid": "40sG903yz80oDFWr"
}
request field desc of unsubscrbing contract info
field | datatype | desc |
---|---|---|
op | string | Required; Operator Name,unsubscribe value is unsub; |
cid | string | Optional; Client requests unique ID |
topic | string | Subscribe topic name,Require subscribe public.$contract_code.contract_info Subscribe/unsubscribe the data of a given contract code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Note:
The request parameter "contract_code" supports the contract code of futures, in that the format is BTC-USDT-210625.
unsubscripting * is ok under business_type filled in. when business_type is swap, unsubscripting * means to unsubscripting all swap contracts; when business_type is futures, unsubscripting * means to unsubscripting all futures contracts;
unsubscription scope must be greater than or equal to the subscription scope and in that it just can be success.
Data format of subscription and unsubscription of contract info
subscribe(sub) | unsubscribe(unsub) | rules |
---|---|---|
public.*.contract_info | pubic.*.contract_info | Allowed |
public.contract_code1.contract_info | public.*.contract_info | Allowed |
public.contract_code1.contract_info | public.contract_code1.contract_info | Allowed |
public.contract_code1.contract_info | public.contract_code2.contract_info | Not Allowed |
public.*.contract_info | public.contract_code1.contract_info | Not Allowed |
[Isolated] Subscribe trigger orders updates(sub)
Remarks
- This interface only supports isolated margin mode.
To subscribe basis data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"op": "sub",
"cid": "id generated by client",
"topic": "trigger_order.$contract_code"
}
Example of a successful return data:
{
"op": "sub",
"topic": "trigger_order.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Request Parameter
Filed Name | type | desc |
---|---|---|
op | string | Required; Operator Name,required subscribe value is sub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; subscribe Topic Name,format: trigger_order.$contract_code; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to subscribe the all trigger order) "BTC-USDT"... |
Return example:
{
"op":"notify",
"topic":"trigger_order.btc-usdt",
"ts":1603778055069,
"event":"order",
"uid":"123456789",
"data":[
{
"symbol":"BTC-USDT",
"contract_code":"BTC-USDT",
"trigger_type":"ge",
"volume":1,
"order_type":1,
"direction":"sell",
"offset":"open",
"lever_rate":10,
"order_id":5,
"order_id_str":"5",
"relation_order_id":"-1",
"order_price_type":"limit",
"status":2,
"order_source":"web",
"trigger_price":15000,
"triggered_price":null,
"order_price":15000,
"created_at":1603778055064,
"triggered_at":0,
"order_insert_at":0,
"canceled_at":0,
"fail_code":null,
"fail_reason":null,
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"reduce_only": 0
}
]
}
Format Illustration on return data of order push:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
op | true | string | Required;Operator Name,Order push value is notify | |
topic | true | string | Required; Order push topic | |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
uid | true | string | account uid | |
event | true | string | Event notification description | trigger order placed successfully(order),trigger order canceled successfully(cancel),order triggered successfully(trigger_success),order failed to be triggered(trigger_fail) |
<data> | true | object array | ||
symbol | true | string | Variety code | |
contract_code | true | string | contract code | "BTC-USDT" ... |
trigger_type | true | string | trigger type: ge great than or equal to;le less than or equal to |
|
volume | true | decimal | trigger order volume | |
order_type | true | int | Transaction Type | 1. Place orders |
direction | true | string | order direction | [buy,sell] |
offset | true | string | offset direction | [open,close,both] |
lever_rate | true | int | Leverage | |
order_id | true | decimal | trigger order ID | |
order_id_str | true | string | the order ID with string | |
relation_order_id | true | string | Relation order ID is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
order_price_type | true | string | Order price type | "limit": limit order,"optimal_5":optimal 5,"optimal_10":optimal 10,"optimal_20":optimal 20 |
status | true | int | order status | 2. Ready to submit the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; |
order_source | true | string | Order Source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_price | true | decimal | trigger price | |
triggered_price | true | decimal | the price when trigger orders executed | |
order_price | true | decimal | the preset price by the client | |
created_at | true | long | order creation time | |
triggered_at | true | long | the execution time when orders getting triggered | |
order_insert_at | true | long | the time when the triggered orders filled successfully | |
canceled_at | true | long | Order cancelation time | |
fail_code | true | int | the error code when the triggered orders failed to be filled | |
fail_reason | true | string | the error message with failure reason when triggered orders failed to filled | |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
Rules:
- The intermediate states processed by the order status system will not be pushed, such as in the progress of placing an order, The descriptions of specific event notifications are as below:
- when the order status is 2(Submitted),event notification is order(trigger order placed successfully);
- when the order status is 4(Order placed successfully),event notification is trigger_success(trigger order triggered successfully);
- when the order status is 6(Canceled),event notification is cancel(trigger order canceled successfully);
- when the order status is 5(Order failed to be placed),event notification is trigger_fail(trigger order failed to be triggered);
- Single coin cannot be re-suscribed, and all coins subscription can cover single coin subscription; single coin cannot be subscribed after subscribing all coins.
[Isolated] Unsubscribe trigger orders updates(unsub)
Remarks
- This interface only supports isolated margin mode.
To subscribe basis data, the Client has to make connection to the Server and send subscribe request in the format below:
Format of Unsubscribe order data
{
"op": "unsub",
"topic": "trigger_order.$contract_code",
"cid": "id generated by client",
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "trigger_order.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format illustration of unsubscribe order data
Filed Name | type | desc |
---|---|---|
op | string | Required; Operator Name,required unsubscribe value is unsub |
cid | string | Optional; ID Client requests unique ID |
topic | string | Required; unsubscribe Topic Name,format: trigger_order.$contract_code; For parameter details please check req unsubscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | true | string | contract code | "*" all(it means to unsubscribe the all trigger order) "BTC-USDT"... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe( unsub) | Rule |
---|---|---|
trigger_order.* | trigger_order.* | Allowed |
trigger_order.contract_code1 | trigger_order.* | Allowed |
trigger_order.contract_code1 | trigger_order.contract_code1 | Allowed |
trigger_order.contract_code1 | trigger_order.contract_code2 | Not Allowed |
trigger_order.* | trigger_order.contract_code1 | Not Allowed |
[Cross] Subscribe trigger orders updates(sub)
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.
To subscribe basis data, the Client has to make connection to the Server and send subscribe request in the format below:
{
"op": "sub",
"cid": "id generated by client",
"topic": "trigger_order_cross.$contract_code"
}
Example of a successful return data:
{
"op": "sub",
"topic": "trigger_order_cross.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Request Parameter
Parameter Name | Mandotary | Type | Desc | Value Range |
---|---|---|---|---|
op | true | string | Required; Operator Name,required subscribe value is sub | |
cid | false | string | Optional; ID Client requests unique ID | |
topic | true | string | Required;format: trigger_order_cross.$contract_code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Return example:
{
"op":"notify",
"topic":"trigger_order_cross.*",
"ts":1639123353369,
"event":"order",
"uid":"123456789",
"data":[
{
"contract_type":"swap",
"pair":"BTC-USDT",
"business_type":"swap",
"symbol":"BTC",
"contract_code":"BTC-USDT",
"trigger_type":"le",
"volume":1,
"order_type":1,
"direction":"buy",
"offset":"open",
"lever_rate":1,
"order_id":918895474461802496,
"order_id_str":"918895474461802496",
"relation_order_id":"-1",
"order_price_type":"limit",
"status":2,
"order_source":"api",
"trigger_price":40000,
"triggered_price":null,
"order_price":40000,
"created_at":1639123353364,
"triggered_at":0,
"order_insert_at":0,
"canceled_at":0,
"fail_code":null,
"fail_reason":null,
"margin_mode":"cross",
"margin_account":"USDT",
"reduce_only": 0
}
]
}
Pushed Data Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
op | true | string | operaton name, fixed as notify | |
topic | true | string | topic | |
ts | true | long | Time of Respond Generation, Unit: Millisecond | |
uid | true | string | uid | |
event | true | string | event | order,cancel,trigger_success,trigger_fail |
<data> | true | object array | ||
symbol | true | string | symbol | |
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"... |
trigger_type | true | string | trigger type: ge great than or equal to;le less than or equal to | |
volume | true | decimal | place volume | |
order_type | true | int | order type | 1. Place orders |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | "open", "close" | "open","close",both |
lever_rate | true | int | leverage | |
order_id | true | decimal | order ID | |
order_id_str | true | string | order ID | |
relation_order_id | true | string | Relation order ID is the string related to the limit orders, The value is -1 before the trigger orders executed. | |
order_price_type | true | string | type of order price | "limit","optimal_5","optimal_10","optimal_20" |
status | true | int | order status | 2. Ready to submit the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger |
trigger_price | true | decimal | trigger price | |
triggered_price | true | decimal | triggered price | |
order_price | true | decimal | order price | |
created_at | true | long | created time | |
triggered_at | true | long | triggered time | |
order_insert_at | true | long | insert time | |
canceled_at | true | long | canceled time | |
fail_code | true | int | fail code | |
fail_reason | true | string | fail reason | |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</data> |
Rules:
- The intermediate states processed by the order status system will not be pushed, such as in the progress of placing an order, The descriptions of specific event notifications are as below:
- when the order status is 2(Submitted),event notification is order(trigger order placed successfully);
- when the order status is 4(Order placed successfully),event notification is trigger_success(trigger order triggered successfully);
- when the order status is 6(Canceled),event notification is cancel(trigger order canceled successfully);
- when the order status is 5(Order failed to be placed),event notification is trigger_fail(trigger order failed to be triggered);
- Single coin cannot be re-suscribed, and all coins subscription can cover single coin subscription; single coin cannot be subscribed after subscribing all coins.
[Cross] Unsubscribe trigger orders updates(unsub)
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.
To subscribe basis data, the Client has to make connection to the Server and send subscribe request in the format below:
Format of Unsubscribe order data
{
"op": "unsub",
"topic": "trigger_order_cross.$contract_code",
"cid": "id generated by client",
}
Example of a successful unsubscribe request:
{
"op": "unsub",
"topic": "trigger_order_cross.BTC-USDT",
"cid": "40sG903yz80oDFWr"
}
Format illustration of unsubscribe order data
Filed | Type | Description |
---|---|---|
op | string | Required;Operator Name,value for unsubscribe is unsub; |
cid | string | Optional; Client requests unique ID |
topic | string | Optional; Unsubscribe Topic Name,format: trigger_order_cross.$contract_code; For parameter details please check req Subscribe Parameter |
Request Parameter:
Parameter Name | Mandotary | Type | Desc | Default | Value Range |
---|---|---|---|---|---|
contract_code | true | string | contract code | all: *(swap and future), swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
Rules on Subscribe and Unsubscribe
Subscribe(sub) | Unsubscribe( unsub) | Rule |
---|---|---|
trigger_order_cross.* | trigger_order_cross.* | Allowed |
trigger_order_cross.contract_code1 | trigger_order_cross.* | Allowed |
trigger_order_cross.contract_code1 | trigger_order_cross.contract_code1 | Allowed |
trigger_order_cross.contract_code1 | trigger_order_cross.contract_code2 | Not Allowed |
trigger_order_cross.* | trigger_order_cross.contract_code1 | Not Allowed |
WebSocket interface for system status updates
- The websocket url of system status updates is : wss://api.hbdm.com/center-notification
[General]Subscribe system status updates
After successfully establishing a connection with the WebSocket API, users could send data in the following format to the server to request data:
{
"op": "sub",
"cid": "id generated by client",
"topic": "public.$service.heartbeat"
}
Example on using parameters to request data:
{
"op": "sub",
"cid": "id generated by client",
"topic": "public.linear-swap.heartbeat"
}
Request Parameter:
Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
op | true | string | The fixed value of subscription is sub | |
cid | false | string | Client requests a unique ID | |
topic | true | string | Subscription topic name is required (public.$service.heartbeat), Subscribe system status information of a certain business |
subscription parameter description:
Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
service | true | string | Business Code | linear-swap : USDT Margined Contracts |
Return Parameter Example:
{
"op": "notify",
"topic": "public.linear-swap.heartbeat",
"event": "init",
"ts":1580815422403,
"data":{
"heartbeat": 0,
"estimated_recovery_time": 1408076414000
}
}
Return Parameter Rules:
Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
op | true | string | Operation name, the fixed value of push is notify; | |
topic | true | string | Push topic | |
event | true | string | Description on notification related event | The initial system status information returned by a successful subscription (init), triggered by system status change (update) |
ts | true | long | Server response timestamp | |
<data> | ||||
heartbeat | true | int | System Status | 1 is available, 0 is not available(maintenance with service suspended) |
estimated_recovery_time | true | long | Estimated system recovery time, unit: millisecond | When the system status is available, return NULL |
</data> |
Note
- Since this push is a poll query status, there may be a delay of 1-2 seconds.
Appendix
Operator Type(OP)
Type | Description |
---|---|
ping | Server sends heatbeat with a Ping |
pong | Clients responds heatbeat with a Pong |
auth | Authentication |
sub | Subscribe Message |
unsub | Unsubscribe Message |
notify | Server pushes subscribe message |
Topic Type
Type | applicative operator type | Description |
---|---|---|
orders.$contract_code | sub,ubsub | Subscribe/unsubscribe the order data of a given pair; when the $contract_code value is *, it stands for subscribing/unsubscribing the data of all pairs |
Response code(Err-Code)
Return Error Code | Return description |
---|---|
0 | Request successfully. |
2001 | Invalid authentication. |
2002 | Authentication required. |
2003 | Authentication failed. |
2004 | Number of visits exceeds limit. |
2005 | Connection has been authenticated. |
2007 | You don’t have access permission as you have not opened contracts trading. |
2010 | Topic error. |
2011 | Contract doesn't exist. |
2012 | Topic not subscribed. |
2013 | Authentication type doesn't exist. |
2014 | Repeated subscription. |
2020 | This contract does not support cross margin mode. |
2021 | Illegal parameter margin_account. |
2030 | Exceeds connection limit of single user. |
2040 | Missing required parameter. |
Will be offline
[General] Query account financial records
- POST
/linear-swap-api/v1/swap_financial_record
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 Parameters
Parameter name | Must fill or not | Type | Description | Value range |
---|---|---|---|---|
margin_account | true | string | Margin currency | "BTC-USDT","USDT"(in cross mode)... |
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
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 in from another margin account; 39:Transfer out to another margin account; 46:ADL close long; 47:ADL close short |
create_date | false | int | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. | |
page_index | false | int | which page, default value is "1st page" when not fill this parameter | |
page_size | false | int | the default value is "20" when not fill this parameter, should ≤50 |
Note:
- It needs contract_code parameter for request in cross margin mode when query the trading financial records of a certain contract market. And it not need contract_code parameter in other scenarios.
Response:
{
"status": "ok",
"data": {
"total_page": 1,
"current_page": 1,
"total_size": 2,
"financial_record": [
{
"id": 117840,
"type": 5,
"amount": -0.024464850000000000,
"ts": 1638758435635,
"contract_code": "BTC-USDT-211210",
"asset": "USDT",
"margin_account": "USDT",
"face_margin_account": ""
},
{
"id": 10328,
"type": 29,
"amount": 10000.000000000000000000,
"ts": 1638517931516,
"contract_code": "",
"asset": "USDT",
"margin_account": "USDT",
"face_margin_account": ""
}
]
},
"ts": 1638759621932
}
Return parameters
Parameter name | Must fill or not | Type | Description | Value range |
---|---|---|---|---|
status | true | string | processing result of requests | "ok" , "error" |
ts | true | long | response create time point,unit:ms | |
<data> | dicitionary type | |||
<financial_record> | ||||
id | true | long | Financial record ID (contract code unqiue) | |
ts | true | long | create time | |
asset | true | string | asset | "USDT"... |
contract_code | true | string | contract type 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 type transaction type are 34, 35, 36, 37, 38, 39; for other types, the field values 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 in from another margin account; 39:Transfer out to another margin account; 46:ADL close long; 47:ADL close short |
amount | true | decimal | amount | |
</financial_record> | ||||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
</data> |
[General]Query account financial records via Multiple Fields
- POST
/linear-swap-api/v1/swap_financial_record_exact
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.
Request Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
margin_account | true | string | margin account | "BTC-USDT","USDT"(in cross mode)... |
contract_code | false | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
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; 46:ADL close long; 47:ADL close short |
start_time | false | long | start time(timestamp in millisecond) | more detail sees the follow note |
end_time | false | long | end time(timestamp in millisecond) | more detail sees the follow note |
from_id | false | long | from id(value from the query_id in return data) | |
size | false | int | size | default is 20, 50 at most |
direct | false | string | direct | prev/next;default is prev |
Note:
- Value range description of start_time and end_time:
- start_time: value range is [(current time - 90 days),current time] ;default value is clamp(end_time - 10 days,current time -90 days,current time -10 days)which means the furthest time is the current time minus 90 days and the most recent time is current time minus 10 days.
- end_time: value range is [(current day - 90 days),above++),if the end_time is greater than the current time, use current time; if start_time is filled,the end_time shall be greater than start_time. The system will use current time by default.
- if from_id is not filled and the query direction is prev, query from back to front from the end time; if from_id is not filled and the query direction is next, query from front to back from the start time. Query financial records with creation time greater than or equal to the start time but less than or equal to the end time.
- if start_time, end_time and from_id all filled in,query according to from_id (but the data must between start_time and end_time)
- Regardless the query direction is prev or next, the data returned is reverse sorted by id.
- If the value of start_time or end_time filled in is not within the value range, the system will report that the parameter is invalid.
- Only data within 90 days are available to query.
- It needs contract_code parameter for request in cross margin mode when query the trading financial records of a certain contract market. And it not need contract_code parameter in other scenarios.
Query cases are as below (special cases are not included):
start_time | end_time | from_id | size | direct | Query Result |
---|---|---|---|---|---|
Default 10 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | prev | Query data between 60 days ago and 50 days ago; query 20 data from back to front from 50 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 5 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | prev | Query data between 20 days ago and 10 days ago; query 20 data from back to front from 10 days ago.The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | Default | 20 | next | Query the data within the last 10 days; query 20 data from front to back from 10 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | next | Query data between 60 days ago and 50 days ago, query 20 data from front to back from 60 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | next | Query the data within the last 5 days; query 20 data from 5 days ago. query 20 data from front to back from 5 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | next | Query data between 20 days ago and 10 days ago; query 20 data from front to back from 20 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | 1000 | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the data with transaction id 1000 and the data with transaction id 1000 is in the first line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | 1000 | 20 | next | Query data between 20 days ago and 10 days ago, query 20 data from front to back from the data with transaction id 1000 and the data with transaction id 1000 is in the last line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Response:
{
"status": "ok",
"data": {
"financial_record": [
{
"id": 117840,
"type": 5,
"amount": -0.024464850000000000,
"ts": 1638758435635,
"contract_code": "BTC-USDT-211210",
"asset": "USDT",
"margin_account": "USDT",
"face_margin_account": ""
},
{
"id": 10328,
"type": 29,
"amount": 10000.000000000000000000,
"ts": 1638517931516,
"contract_code": "USDT-USD",
"asset": "USDT",
"margin_account": "USDT",
"face_margin_account": ""
}
],
"remain_size": 0,
"next_id": null
},
"ts": 1638759705140
}
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 | ||
<financial_record> | true | object array | ||
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; 46:ADL close long; 47:ADL close short |
amount | true | decimal | amount(quote currency) | |
</financial_record> | ||||
remain_size | true | int | remain size(In the time range, the size that was not queried due to size restrictions) | |
next_id | true | long | query_id for next data(It only has a value when the query result exceeds the size limit) | |
</data> |
Note:
- if type in (34, 35, 36, 37, 38, 39),contract_code is empty string.
- if the query result exceeds the data limit, next_id is the id of next data. ( when the query direction is prev, next_id presents the first data on the next page; when the query direction is next, next_id presents the last data on the next page.)
[Cross]Get History Match Results via Multiple Fields
- POST
linear-swap-api/v1/swap_cross_matchresults_exact
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 and contract_code filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
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 | start time(timestamp in millisecond) | more detail sees the follow note |
end_time | false | long | end time(timestamp in millisecond) | more detail sees the follow note |
from_id | false | long | from id(value from the query_id in return data) | |
size | false | int | size | default is 20, 50 at most |
direct | false | string | direct | prev/next;default is prev |
Note:
- Value range description of start_time and end_time:
- start_time: value range is [(current time - 90 days),current time] ;default value is clamp(end_time - 10 days,current time -90 days,current time -10 days)which means the furthest time is the current time minus 90 days and the most recent time is current time minus 10 days.
- end_time: value range is [(current day - 90 days),above++),if the end_time is greater than the current time, use current time; if start_time is filled,the end_time shall be greater than start_time. The system will use current time by default.
- if from_id is not filled and the query direction is prev, query from back to front from the end time; if from_id is not filled and the query direction is next, query from front to back from the start time. Query financial records with creation time greater than or equal to the start time but less than or equal to the end time.
- Regardless the query direction is prev or next, the data returned is reverse sorted by query_id.
- If the value of start_time or end_time filled in is not within the value range, the system will report that the parameter is invalid.
- Only data within 90 days are available to query.
Query cases are as below (special cases are not included):
start_time | end_time | from_id | size | direct | Query Result |
---|---|---|---|---|---|
Default 10 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | prev | Query data between 60 days ago and 50 days ago; query 20 data from back to front from 50 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 5 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | prev | Query data between 20 days ago and 10 days ago; query 20 data from back to front from 10 days ago.The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | Default | 20 | next | Query the data within the last 10 days; query 20 data from front to back from 10 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | next | Query data between 60 days ago and 50 days ago, query 20 data from front to back from 60 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | next | Query the data within the last 5 days; query 20 data from 5 days ago. query 20 data from front to back from 5 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | next | Query data between 20 days ago and 10 days ago; query 20 data from front to back from 20 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | 1000 | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the data with transaction id 1000 and the data with transaction id 1000 is in the first line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | 1000 | 20 | next | Query data between 20 days ago and 10 days ago, query 20 data from front to back from the data with transaction id 1000 and the data with transaction id 1000 is in the last line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Response:
{
"status": "ok",
"data": {
"trades": [
{
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"query_id": 136966,
"match_id": 2902136,
"order_id": 918800256249405440,
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"direction": "buy",
"offset": "open",
"trade_volume": 100.000000000000000000,
"trade_price": 48555.600000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_fee": -2.427780000000000000,
"offset_profitloss": 0E-18,
"create_date": 1639100651577,
"role": "Taker",
"order_source": "api",
"order_id_str": "918800256249405440",
"id": "2902136-918800256249405440-1",
"fee_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"real_profit": 0E-18,
"reduce_only": 0
}
],
"remain_size": 0,
"next_id": null
},
"ts": 1639102308193
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | |
<data> | true | object | ||
<trades> | true | object array | ||
id | true | string | unique id of the trade, and match_id is not unique id. The specific method of use is to use match_id and id as the joint primary key to form a unique transaction ID. | |
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
match_id | true | long | matching result id, not unique, may be repeated | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
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” |
direction | true | string | direction向 | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
trade_volume | true | decimal | trade volume | |
trade_price | true | decimal | trade price | |
trade_turnover | true | decimal | trade turnover | |
create_date | true | long | create date | |
offset_profitloss | true | decimal | profit or loss when cloase position | |
real_profit | true | decimal | real profit | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker or maker | |
fee_asset | true | string | fee asset | ("USDT"...) |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</trades> | ||||
remain_size | true | int | remain size(In the time range, the size that was not queried due to size restrictions) | |
next_id | true | long | query_id for next data(It only has a value when the query result exceeds the size limit) | |
</data> | ||||
ts | true | long | timestamp |
Note:
- if the query result exceeds the data limit, next_id is the id of next data. ( when the query direction is prev, next_id presents the first data on the next page; when the query direction is next, next_id presents the last data on the next page.)
[Cross] Get History Match Results
- POST
/linear-swap-api/v1/swap_cross_matchresults
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 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 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 |
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) |
create_date | true | int | date | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. |
page_index | false | int | page index, default 1st page | |
page_size | false | int | default 20,no more than 50 |
Response
{
"status": "ok",
"data": {
"trades": [
{
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"match_id": 2902136,
"order_id": 918800256249405440,
"symbol": "BTC",
"contract_code": "BTC-USDT-211210",
"direction": "buy",
"offset": "open",
"trade_volume": 100.000000000000000000,
"trade_price": 48555.600000000000000000,
"trade_turnover": 4855.560000000000000000,
"trade_fee": -2.427780000000000000,
"offset_profitloss": 0E-18,
"create_date": 1639100651577,
"role": "Taker",
"order_source": "api",
"order_id_str": "918800256249405440",
"id": "2902136-918800256249405440-1",
"fee_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"real_profit": 0E-18,
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 5
},
"ts": 1639102170045
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | |
<data> | true | object | ||
<trades> | true | object array | ||
margin_mode | true | string | margin mode | cross: cross margin mode |
margin_account | true | string | margin account | "USDT"... |
id | true | string | the global unique ID of the trade. | |
match_id | true | long | match_id is the same with trade_id of the websocket subscriptions: orders_cross.$contract_code match_id is the result of sets of order execution and trade confirmation. NOTE: match_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same match_id. | |
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
symbol | true | string | symbol | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
contract_code | true | string | contract code | swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
trade_volume | true | decimal | trade quantity | |
trade_price | true | decimal | trade price | |
trade_turnover | true | decimal | trade amount | |
create_date | true | long | trade time | |
offset_profitloss | true | decimal | profits and losses generated from closing positions(calculated with the average price of position, exclude profit in history settlement.) | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker/maker | |
fee_asset | true | string | fee asset | ("USDT"...) |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history 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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</trades> | ||||
current_page | true | int | current page | |
total_page | true | int | total page | |
total_size | true | int | total size | |
</data> | ||||
ts | true | long | timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- The real profit (real_profit) parameter that orders created after December 10, 2020 has a value. And before that time it is 0.
[Isolated]Get History Match Results via Multiple Fields
- POST
/linear-swap-api/v1/swap_matchresults_exact
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"... |
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 | start time(timestamp in millisecond) | more detail sees the follow note |
end_time | false | long | end time(timestamp in millisecond) | more detail sees the follow note |
from_id | false | long | from id(value from the query_id in return data) | |
size | false | int | size | default is 20, 50 at most |
direct | false | string | direct | prev/next;default is prev |
Note:
- Value range description of start_time and end_time:
- start_time: value range is [(current time - 90 days),current time] ;default value is clamp(end_time - 10 days,current time -90 days,current time -10 days)which means the furthest time is the current time minus 90 days and the most recent time is current time minus 10 days.
- end_time: value range is [(current day - 90 days),above++),if the end_time is greater than the current time, use current time; if start_time is filled,the end_time shall be greater than start_time. The system will use current time by default.
- if from_id is not filled and the query direction is prev, query from back to front from the end time; if from_id is not filled and the query direction is next, query from front to back from the start time. Query financial records with creation time greater than or equal to the start time but less than or equal to the end time.
- Regardless the query direction is prev or next, the data returned is reverse sorted by query_id.
- If the value of start_time or end_time filled in is not within the value range, the system will report that the parameter is invalid.
- Only data within 90 days are available to query.
Query cases are as below (special cases are not included):
start_time | end_time | from_id | size | direct | Query Result |
---|---|---|---|---|---|
Default 10 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | prev | Query data between 60 days ago and 50 days ago; query 20 data from back to front from 50 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 5 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | prev | Query data between 20 days ago and 10 days ago; query 20 data from back to front from 10 days ago.The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | Default | 20 | next | Query the data within the last 10 days; query 20 data from front to back from 10 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | next | Query data between 60 days ago and 50 days ago, query 20 data from front to back from 60 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | next | Query the data within the last 5 days; query 20 data from 5 days ago. query 20 data from front to back from 5 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | next | Query data between 20 days ago and 10 days ago; query 20 data from front to back from 20 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | 1000 | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the data with transaction id 1000 and the data with transaction id 1000 is in the first line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | 1000 | 20 | next | Query data between 20 days ago and 10 days ago, query 20 data from front to back from the data with transaction id 1000 and the data with transaction id 1000 is in the last line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Response:
{
"status": "ok",
"data": {
"trades": [
{
"query_id": 138798248,
"match_id": 13752484857,
"order_id": 807038270541733888,
"symbol": "BTC",
"contract_code": "BTC-USDT",
"direction": "buy",
"offset": "close",
"trade_volume": 9,
"trade_price": 36580,
"trade_turnover": 329.22,
"trade_fee": -0.131688,
"offset_profitloss": 0.3636,
"create_date": 1612454517757,
"role": "Taker",
"order_source": "android",
"order_id_str": "807038270541733888",
"id": "13752484857-807038270541733888-1",
"fee_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"real_profit": 0.2394,
"reduce_only": 0
}
],
"remain_size": 0,
"next_id": null
},
"ts": 1612503560490
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | |
<data> | true | object | ||
<trades> | true | object array | ||
id | true | string | unique id of the trade, and match_id is not unique id. The specific method of use is to use match_id and id as the joint primary key to form a unique transaction ID. | |
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
match_id | true | long | matching result id, not unique, may be repeated | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_mode | true | string | margin mode | isolated: isolated |
margin_account | true | string | margin account | such as:BTC-USDT” |
direction | true | string | direction向 | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
trade_volume | true | decimal | trade volume | |
trade_price | true | decimal | trade price | |
trade_turnover | true | decimal | trade turnover | |
create_date | true | long | create date | |
offset_profitloss | true | decimal | profit or loss when close position | |
real_profit | true | decimal | real profit | |
trade_fee | true | decimal | trade fee | |
role | true | string | taker or maker | |
fee_asset | true | string | fee asset | ("USDT"...) |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</trades> | ||||
remain_size | true | int | remain size(In the time range, the size that was not queried due to size restrictions) | |
next_id | true | long | query_id for next data(It only has a value when the query result exceeds the size limit) | |
</data> | ||||
ts | true | long | timestamp |
Note:
- if the query result exceeds the data limit, next_id is the id of next data. ( when the query direction is prev, next_id presents the first data on the next page; when the query direction is next, next_id presents the last data on the next page.)
[Isolated] Acquire History Match Results
- POST
/linear-swap-api/v1/swap_matchresults
Remarks
- This interface only supports isolated margin mode.
Request Parameter
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". | |
trade_type | true | int | trasanction types | 0:All; 1: Open long; 2: Open short; 3: Close short; 4: Close long; 5: Liquidate long positions; 6: Liquidate short positions, 17:buy(one-way mode), 18:sell(one-way mode) | |
create_date | true | int | date | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. | |
page_index | false | int | page; if not enter, it will be the default value of the 1st page. | 1 | |
page_size | false | int | if not enter, it will be the default value of 20; the number should ≤50 | 20 |
Response:
{
"status": "ok",
"data": {
"trades": [
{
"match_id": 131560927,
"order_id": 770334322963152896,
"symbol": "BTC",
"contract_code": "BTC-USDT",
"direction": "sell",
"offset": "open",
"trade_volume": 1.000000000000000000,
"trade_price": 13059.800000000000000000,
"trade_turnover": 13.059800000000000000,
"trade_fee": -0.005223920000000000,
"offset_profitloss": 0,
"create_date": 1603703614715,
"role": "Taker",
"order_source": "api",
"order_id_str": "770334322963152896",
"id": "131560927-770334322963152896-1",
"fee_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"real_profit": 0,
"reduce_only": 0
}
],
"total_page": 2,
"current_page": 1,
"total_size": 2
},
"ts": 1603704407235
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | request handling result | |
<data> | ||||
<trades> | ||||
id | true | string | the global unique ID of the trade. | |
match_id | true | long | match_id is the same with trade_id of the websocket subscriptions: orders.$contract_code match_id is the result of sets of order execution and trade confirmation. NOTE: match_id is not unique, which includes all trade records of a taker order and N maker orders. If the taker order matches with N maker orders, it will create N trades with same match_id. | |
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
symbol | true | string | contract type code | |
order_source | true | string | Order Source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
contract_code | true | string | contract code | "BTC-USDT" ... |
direction | true | string | "buy": to bid/ go long; "sell": to ask/ go short. | |
offset | true | string | "open": open positions; "close": close positions , "both" | |
trade_volume | true | int | the number of traded contract with unit of lot | |
trade_price | true | decimal | the price at which orders get filled | |
trade_turnover | true | int | the number of total traded amout with number of USDT | |
create_date | true | long | the time when orders get filled | |
offset_profitloss | true | decimal | profits and losses generated from closing positions(calculated with the average price of position, exclude profit in history settlement.) | |
trade_fee | true | decimal | fees charged by platform | |
role | true | string | taker or maker | |
fee_asset | true | string | the corresponding cryptocurrency to the given fee | "USDT"... |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history settlement.) | |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</trades> | ||||
total_page | true | int | total pages | |
current_page | true | int | current page | |
total_size | true | int | total size of the list | |
</data> | ||||
ts | true | long | timestamp |
Notice
- If users don’t upload/fill the page_index or page_size, it will automatically be set as the default value of the top 20 data on the first page, for more details, please follow the parameters illustration.
- 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.
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- The real profit (real_profit) parameter that orders created after December 10, 2020 has a value. And before that time it is 0.
[Cross] Get History Orders
- POST
/linear-swap-api/v1/swap_cross_hisorders
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 and contract_code must be filled in(if both 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 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 |
trade_type | true | int | trade type | 0:all,1: buy long,2: sell short,3: buy short,4: sell long,5: sell liquidation,6: buy liquidation,7:Delivery long,8: Delivery short,11:reduce positions to close long,12:reduce positions to close short, 17:buy(one-way mode), 18:sell(one-way mode) |
type | true | int | type | 1:All Orders,2:Order in Finished Status |
status | true | string | order status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; |
create_date | true | int | date | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. |
page_index | false | int | page index, default 1st page | |
page_size | false | int | page size, default 20 no more than 50 | |
sort_by | false | string | sort fields(Default: “create_date” descending order) | "create_date":descending order by order create date , "update_time": descending order by order update time |
Note:
- All via API interface submited price limit orders that had been cancelled will only be kept for 2 hours.
Response
{
"status": "ok",
"data": {
"orders": [
{
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"order_id": 918800256249405440,
"contract_code": "BTC-USDT-211210",
"symbol": "BTC",
"lever_rate": 5,
"direction": "buy",
"offset": "open",
"volume": 100.000000000000000000,
"price": 48555.600000000000000000,
"create_date": 1639100651569,
"order_source": "api",
"order_price_type": 3,
"order_type": 1,
"margin_frozen": 0E-18,
"profit": 0E-18,
"trade_volume": 100.000000000000000000,
"trade_turnover": 4855.560000000000000000,
"fee": -2.427780000000000000,
"trade_avg_price": 48555.6000,
"status": 6,
"order_id_str": "918800256249405440",
"fee_asset": "USDT",
"liquidation_type": "0",
"margin_asset": "USDT",
"margin_mode": "cross",
"margin_account": "USDT",
"update_time": 1639100651000,
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
}
],
"total_page": 1,
"current_page": 1,
"total_size": 4
},
"ts": 1639101888331
}
Returning Parameter
Parameter Name | Required | Type | Desc | Data Value |
---|---|---|---|---|
status | true | string | Request Processing Result | |
<data> | true | object | ||
<orders> | true | object array | ||
order_id | true | long | order ID | |
order_id_str | true | string | order ID | |
symbol | true | string | symbol | |
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"... |
lever_rate | true | int | leverage | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | "open", "close" | "open","close","both" |
volume | true | decimal | place volume | |
price | true | decimal | place price | |
create_date | true | long | created time | |
update_time | true | long | order update time,millesecond timestamp | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | int | type of order price | 1:limit,2:market,3:opponent,4:lightning,5:trigger,6:post_only ,7:optimal_5 ,8:optimal_10 ,9:optimal_20,10:FOK ,11:IOC ,12:opponent_ioc,13:lightning_ioc,14:optimal_5_ioc,15:optimal_10_ioc,16:optimal_20_ioc,17:opponent_fok,18:lightning_fok,19:optimal_5_fok,40:optimal_10_fok,41:optimal_20_fok |
margin_asset | true | string | margin asset | |
margin_frozen | true | decimal | frozen margin | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
trade_volume | true | decimal | trade quantity | |
trade_turnover | true | decimal | trade amount | |
fee | true | decimal | service fee | |
trade_avg_price | true | decimal | trade average price | |
status | true | int | order status | |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history 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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
current_page | true | int | current page | |
total_page | true | int | total page | |
total_size | true | int | total size | |
</data> | ||||
ts | true | long | timestamp |
Note:
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And in the other orders created before that times, it is 0.
[Cross]Get History Orders via Multiple Fields
- POST
/linear-swap-api/v1/swap_cross_hisorders_exact
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 and contract_code filled in, the contract_code is the preferred.
Request Parameter
Parameter Name | Required | Type | Description | Value 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 |
trade_type | true | int | trade type | 0:all,1: buy long,2: sell short,3: buy short,4: sell long,5: sell liquidation,6: buy liquidation,7:Delivery long,8: Delivery short,11:reduce positions to close long,12:reduce positions to close short, 17:buy(one-way mode), 18:sell(one-way mode) |
type | true | int | Type | 1:All Orders,2:Order in Finished Status |
status | true | string | status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; |
order_price_type | false | string | order price type | order price type, "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 |
start_time | false | long | start time(timestamp in millisecond) | more detail sees the follow note |
end_time | false | long | end time(timestamp in millisecond) | more detail sees the follow note |
from_id | false | long | from id(value from the query_id in return data) | |
size | false | int | size | default is 20, 50 at most |
direct | false | string | direct | prev/next;default is prev |
Note:
- can't get information of cancelled order which operated via api and before 2 hours
- Value range description of start_time and end_time:
- start_time: value range is [(current time - 90 days),current time] ;default value is clamp(end_time - 10 days,current time -90 days,current time -10 days)which means the furthest time is the current time minus 90 days and the most recent time is current time minus 10 days.
- end_time: value range is [(current day - 90 days),above++),if the end_time is greater than the current time, use current time; if start_time is filled,the end_time shall be greater than start_time. The system will use current time by default.
- if from_id is not filled and the query direction is prev, query from back to front from the end time; if from_id is not filled and the query direction is next, query from front to back from the start time. Query financial records with creation time greater than or equal to the start time but less than or equal to the end time.
- Regardless the query direction is prev or next, the data returned is reverse sorted by query_id.
- If the value of start_time or end_time filled in is not within the value range, the system will report that the parameter is invalid.
- Only data within 90 days are available to query.
Query cases are as below (special cases are not included):
start_time | end_time | from_id | size | direct | Query Result |
---|---|---|---|---|---|
Default 10 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | prev | Query data between 60 days ago and 50 days ago; query 20 data from back to front from 50 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 5 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | prev | Query data between 20 days ago and 10 days ago; query 20 data from back to front from 10 days ago.The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | Default | 20 | next | Query the data within the last 10 days; query 20 data from front to back from 10 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | next | Query data between 60 days ago and 50 days ago, query 20 data from front to back from 60 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | next | Query the data within the last 5 days; query 20 data from 5 days ago. query 20 data from front to back from 5 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | next | Query data between 20 days ago and 10 days ago; query 20 data from front to back from 20 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | 1000 | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the data with transaction id 1000 and the data with transaction id 1000 is in the first line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | 1000 | 20 | next | Query data between 20 days ago and 10 days ago, query 20 data from front to back from the data with transaction id 1000 and the data with transaction id 1000 is in the last line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"query_id": 452057,
"contract_type": "this_week",
"pair": "BTC-USDT",
"business_type": "futures",
"order_id": 918800256249405440,
"contract_code": "BTC-USDT-211210",
"symbol": "BTC",
"lever_rate": 5,
"direction": "buy",
"offset": "open",
"volume": 100.000000000000000000,
"price": 48555.600000000000000000,
"create_date": 1639100651569,
"order_source": "api",
"order_price_type": "opponent",
"order_type": 1,
"margin_frozen": 0E-18,
"profit": 0E-18,
"trade_volume": 100.000000000000000000,
"trade_turnover": 4855.560000000000000000,
"fee": -2.427780000000000000,
"trade_avg_price": 48555.6000,
"status": 6,
"order_id_str": "918800256249405440",
"fee_asset": "USDT",
"liquidation_type": "0",
"is_tpsl": 0,
"real_profit": 0,
"margin_mode": "cross",
"margin_account": "USDT",
"reduce_only": 0
}
],
"remain_size": 0,
"next_id": null
},
"ts": 1639102028275
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | |
<data> | true | object | ||
<orders> | true | object array | ||
query_id | true | long | Query id, which can be used as the from_id field for the next query request. | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
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” |
lever_rate | true | int | lever rate | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
volume | true | decimal | volume | |
price | true | decimal | price | |
create_date | true | long | create date | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | order price type, "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 |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit | |
real_profit | true | decimal | real profit | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 10.Orders failed. 11. Orders cancelling. |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
is_tpsl | true | int | is tpsl | 1: yes; 0:no |
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 |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
remain_size | true | int | remain size(In the time range, the size that was not queried due to size restrictions) | |
next_id | true | long | query_id for next data(It only has a value when the query result exceeds the size limit) | |
</data> | ||||
ts | true | long | timestamp |
Note:
- if the query result exceeds the data limit, next_id is the id of next data. ( when the query direction is prev, next_id presents the first data on the next page; when the query direction is next, next_id presents the last data on the next page.)
[Isolated]Get History Orders via Multiple Fields
- POST
/linear-swap-api/v1/swap_hisorders_exact
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" ... |
trade_type | true | int | trade type | 0:all,1: buy long,2: sell short,3: buy short,4: sell long,5: sell liquidation,6: buy liquidation,7:Delivery long,8: Delivery short,11:reduce positions to close long,12:reduce positions to close short, 17:buy(one-way mode), 18:sell(one-way mode) |
type | true | int | Type | 1:All Orders,2:Order in Finished Status |
status | true | string | status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; |
order_price_type | false | string | order price type | order price type, "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 |
start_time | false | long | start time(timestamp in millisecond) | more detail sees the follow note |
end_time | false | long | end time(timestamp in millisecond) | more detail sees the follow note |
from_id | false | long | from id(value from the query_id in return data) | |
size | false | int | size | default is 20, 50 at most |
direct | false | string | direct | prev/next;default is prev |
Note:
- can't get information of cancelled order which operated via api and before 2 hours
- Value range description of start_time and end_time:
- start_time: value range is [(current time - 90 days),current time] ;default value is clamp(end_time - 10 days,current time -90 days,current time -10 days)which means the furthest time is the current time minus 90 days and the most recent time is current time minus 10 days.
- end_time: value range is [(current day - 90 days),above++),if the end_time is greater than the current time, use current time; if start_time is filled,the end_time shall be greater than start_time. The system will use current time by default.
- if from_id is not filled and the query direction is prev, query from back to front from the end time; if from_id is not filled and the query direction is next, query from front to back from the start time. Query financial records with creation time greater than or equal to the start time but less than or equal to the end time.
- Regardless the query direction is prev or next, the data returned is reverse sorted by query_id.
- If the value of start_time or end_time filled in is not within the value range, the system will report that the parameter is invalid.
- Only data within 90 days are available to query.
Query cases are as below (special cases are not included):
start_time | end_time | from_id | size | direct | Query Result |
---|---|---|---|---|---|
Default 10 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | prev | Query data between 60 days ago and 50 days ago; query 20 data from back to front from 50 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | prev | Query the data within the last 5 days; query 20 data from back to front from the current time. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | prev | Query data between 20 days ago and 10 days ago; query 20 data from back to front from 10 days ago.The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | Default | 20 | next | Query the data within the last 10 days; query 20 data from front to back from 10 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 60 days before the current time | 50 days before the current time | Default | 20 | next | Query data between 60 days ago and 50 days ago, query 20 data from front to back from 60 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
5 days before the current time | Default current time | Default | 20 | next | Query the data within the last 5 days; query 20 data from 5 days ago. query 20 data from front to back from 5 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | Default | 20 | next | Query data between 20 days ago and 10 days ago; query 20 data from front to back from 20 days ago. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Default 10 days before the current time | Default current time | 1000 | 20 | prev | Query the data within the last 10 days; query 20 data from back to front from the data with transaction id 1000 and the data with transaction id 1000 is in the first line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
20 days before the current time | 10 days before the current time | 1000 | 20 | next | Query data between 20 days ago and 10 days ago, query 20 data from front to back from the data with transaction id 1000 and the data with transaction id 1000 is in the last line. The data returned is in reverse order based on creation time. The newer the data, the closer to the front. |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"query_id": 13580806498,
"order_id": 807038270541733888,
"contract_code": "BTC-USDT",
"symbol": "BTC",
"lever_rate": 10,
"direction": "buy",
"offset": "close",
"volume": 9,
"price": 36580,
"create_date": 1612454517740,
"order_source": "android",
"order_price_type": "opponent",
"order_type": 1,
"margin_frozen": 0,
"profit": 0.3636,
"trade_volume": 9,
"trade_turnover": 329.22,
"fee": -0.131688,
"trade_avg_price": 36580,
"status": 6,
"order_id_str": "807038270541733888",
"fee_asset": "BTC-USDT",
"liquidation_type": "0",
"is_tpsl": 0,
"real_profit": 0.2394,
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"reduce_only": 0
}
],
"remain_size": 0,
"next_id": null
},
"ts": 1612503332073
}
Returning Parameter
Parameter Name | Required | Type | Description | Value Range |
---|---|---|---|---|
status | true | string | result of server handled request | |
<data> | true | object | ||
<orders> | true | object array | ||
query_id | true | long | query id, can use as next request's from_id | |
order_id | true | long | order id | |
order_id_str | true | string | order id in string | |
symbol | true | string | symbol | |
contract_code | true | string | contract code | "BTC-USDT" ... |
margin_mode | true | string | margin mode | isolated: isolated |
margin_account | true | string | margin account | such as:BTC-USDT” |
lever_rate | true | int | lever rate | |
direction | true | string | direction | "buy"/"sell" |
offset | true | string | offset | "open","close","both" |
volume | true | decimal | volume | |
price | true | decimal | price | |
create_date | true | long | create date | |
order_source | true | string | order source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | string | order price type | order price type, "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 |
margin_frozen | true | decimal | margin frozen | |
profit | true | decimal | profit | |
real_profit | true | decimal | real profit | |
trade_volume | true | decimal | trade volume | |
trade_turnover | true | decimal | trade turnover | |
fee | true | decimal | fee | |
trade_avg_price | true | decimal | trade avg price | |
status | true | int | status | 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 10.Orders failed. 11. Orders cancelling. |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
fee_asset | true | string | fee asset | ("USDT"...) |
liquidation_type | true | string | liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
is_tpsl | true | int | is tpsl | 1: yes; 0:no |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
remain_size | true | int | remain size(In the time range, the size that was not queried due to size restrictions) | |
next_id | true | long | query_id for next data(It only has a value when the query result exceeds the size limit) | |
</data> | ||||
ts | true | long | timestamp |
Note:
- if the query result exceeds the data limit, next_id is the id of next data. ( when the query direction is prev, next_id presents the first data on the next page; when the query direction is next, next_id presents the last data on the next page.)
[Isolated] Get History Orders
- POST
/linear-swap-api/v1/swap_hisorders
Remarks
- This interface only supports isolated margin mode.
Request Parameter
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". | |
trade_type | true | int | Transaction type | 0:all,1: buy long,2: sell short,3: buy short,4: sell long,5: sell liquidation,6: buy liquidation,7:Delivery long,8: Delivery short,11:reduce positions to close long,12:reduce positions to close short, 17:buy(one-way mode), 18:sell(one-way mode) | |
type | true | int | Type | 1:All Orders,2:Order in Finished Status | |
status | true | string | Order Status | support multiple query seperated by ',',such as '3,4,5', 0: all. 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; | |
create_date | true | int | Date | any positive integer available. Requesting data beyond 90 will not be supported, otherwise, system will return trigger history data within the last 90 days by default. | |
page_index | false | int | Page, default 1st page | 1 | |
page_size | false | int | Default 20,no more than 50 | 20 | |
sort_by | false | string | sort fields(descending) | create_date | "create_date":descending order by order create date , "update_time": descending order by order update time |
Note:
- All via API interface submited price limit orders that had been cancelled will only be kept for 2 hours.
Response:
{
"status": "ok",
"data": {
"orders": [
{
"order_id": 770336866451992576,
"contract_code": "BTC-USDT",
"symbol": "BTC",
"lever_rate": 10,
"direction": "sell",
"offset": "close",
"volume": 1.000000000000000000,
"price": 13100.000000000000000000,
"create_date": 1603704221118,
"update_time": 1603704221118,
"order_source": "web",
"order_price_type": 6,
"order_type": 1,
"margin_frozen": 0,
"profit": 0,
"trade_volume": 0,
"trade_turnover": 0,
"fee": 0,
"trade_avg_price": 0,
"status": 3,
"order_id_str": "770336866451992576",
"fee_asset": "USDT",
"liquidation_type": "0",
"margin_asset": "USDT",
"margin_mode": "isolated",
"margin_account": "BTC-USDT",
"is_tpsl": 0,
"real_profit": 0,
"reduce_only": 0
}
],
"total_page": 10,
"current_page": 1,
"total_size": 10
},
"ts": 1603704312847
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | |
<data> | object | |||
<orders> | array | |||
order_id | true | long | Order ID | |
order_id_str | true | string | Order ID | |
symbol | true | string | Variety code | |
contract_code | true | string | Contract Code | "BTC-USDT" ... |
lever_rate | true | int | Leverage Rate | 1\5\10\20 |
direction | true | string | Transaction direction | |
offset | true | string | "open": "close" | "open", "close", "both" |
volume | true | int | Number of Order | |
price | true | decimal | Price committed | |
create_date | true | long | Creation time | |
update_time | true | long | order update time,millesecond timestamp | |
order_source | true | string | Order Source | system、web、api、m、risk、settlement、ios、android、windows、mac、trigger、tpsl |
order_price_type | true | int | 1:limit,2:market,3:opponent,4:lightning,5:trigger,6:post_only ,7:optimal_5 ,8:optimal_10 ,9:optimal_20,10:FOK ,11:IOC ,12:opponent_ioc,13:lightning_ioc,14:optimal_5_ioc,15:optimal_10_ioc,16:optimal_20_ioc,17:opponent_fok,18:lightning_fok,19:optimal_5_fok,40:optimal_10_fok,41:optimal_20_fok . | |
margin_frozen | true | decimal | Frozen margin | |
margin_asset | true | string | margin asset | |
profit | true | decimal | profit when close position (calculated with the average price of position, exclude profit in history settlement.) | |
trade_volume | true | decimal | Transaction quantity | |
trade_turnover | true | int | Transaction aggregate amount | |
fee | true | decimal | Service fee | |
trade_avg_price | true | decimal | Transaction average price | |
status | true | int | status: 1. Ready to submit the orders; 2. Ready to submit the orders; 3. Have sumbmitted the orders; 4. Orders partially matched; 5. Orders cancelled with partially matched; 6. Orders fully matched; 7. Orders cancelled; 11. Orders cancelling. | |
fee_asset | true | string | the corresponding cryptocurrency to the given fee | "USDT"... |
order_type | true | int | order type | 1. Quotation; 2. Cancelled order; 3. Forced liquidation; 4. Delivery Order |
liquidation_type | true | string | Liquidation type | 0: Non-liquidated,1: Long and short netting,2: Partial liquidated,3: Full liquidated |
margin_mode | true | string | margin mode | isolated : "isolated" |
margin_account | true | string | margin account | "BTC-USDT"... |
is_tpsl | true | int | whether to set take-profit and stop-loss order | 1:yes;0:no |
real_profit | true | decimal | real profit (calculated with the opening average price, include profit in history settlement.) | |
reduce_only | true | int | reduce only | 0: no, 1: yes |
</orders> | ||||
total_page | true | int | Total Pages | |
current_page | true | int | Current Page | |
total_size | true | int | Total Size | |
</data> | ||||
ts | true | long | Timestamp |
Note
- The return order_id is 18 bits, it will make mistake when nodejs and JavaScript analysed 18 bits. Because the Json.parse in nodejs and JavaScript is int by default. so the number over 18 bits need be parsed by json-bigint package.
- The real_profit is calculated with the average price in open position and the transaction average price in close position (the real profit is the sum of each profit of order matched).
- Only of the order information that orders created after 0:00 on January 30, 2021, the real profit (real_profit) parameter has a value. And in the other orders created before that times, it is 0.
[General] Query Liquidation Orders
- GET
/linear-swap-api/v1/swap_liquidation_orders
curl "https://api.hbdm.com/linear-swap-api/v1/swap_liquidation_orders?contract_code=BTC-USDT&trade_type=0&create_date=7"
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 Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
contract_code | false(more see remarks) | string | contract code | Case-Insenstive.e.g. swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
pair | false(more see remarks) | string | pair | BTC-USDT |
trade_type | true | int | trading types | when “0”, request fully filled liquidated orders; when “5’, request liquidated close orders; when “6”, request liquidated open orders |
create_date | true | int | date | 7,90( 7 days or 90 days) |
page_index | false | int | page, system sets page 1 by default without further instruction | |
page_size | false | int | system sets page 20 by default without further instruction. Max page size is 50. |
Response:
{
"status": "ok",
"data": {
"orders": [
{
"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"
},
{
"contract_code": "BTC-USDT-211231",
"symbol": "USDT",
"direction": "sell",
"offset": "close",
"volume": 3999.000000000000000000,
"price": 53457.900000000000000000,
"created_at": 1638564308927,
"amount": 3.999000000000000000,
"trade_turnover": 213778.142100000000000000,
"business_type": "futures",
"pair": "BTC-USDT"
}
],
"total_page": 1,
"current_page": 1,
"total_size": 8
},
"ts": 1638756566302
}
Returning Parameter
Parameter Name | Required | Type | Desc | Value Range |
---|---|---|---|---|
status | true | string | Request Processing Result | |
<data> | ||||
<orders> | ||||
symbol | true | string | symbol | |
contract_code | true | string | contract code | e.g. swap: "BTC-USDT"... , future: "BTC-USDT-210625" ... |
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) | |
trade_turnover | true | decimal | liquidation amount (quotation token) | |
price | true | decimal | bankruptcy price | |
created_at | true | long | liquidation time | |
pair | true | string | pair | such as: “BTC-USDT” |
business_type | true | string | business type | futures, swap |
</orders> | ||||
total_page | true | int | total page | |
current_page | true | int | current page | |
total_size | true | int | total size | |
</data> | ||||
ts | true | long | timestamp |