HTX is going to allow sub user to trade in margin mode

Dear API users,

HTX is currently allowing sub user to trade in spot market, but not in margin mode. Since the effective day of this notification, authorized sub users are allowed to trade in margin mode, through related existing REST API endpoints.

Effective Date: September 16, 2019 (GMT+8)
All the changes will be updated on 【API Docs】

HTX
September 12, 2019

The following are change details:
1) POST /v1/dw/transfer-in/margin
Transfer asset from sub user’s spot account to margin account.
2) POST /v1/dw/transfer-out/margin
Transfer asset from sub user’s margin account to spot account.
3) POST /v1/margin/orders
Apply a margin loan by sub user.
4) POST /v1/margin/orders/{order-id}/repay
Repay margin loan by sub user.
5) GET /v1/margin/loan-orders
Query margin loan orders by sub user.
6) GET /v1/margin/accounts/balance
Query margin account balance by sub user.











Asset transfer between parent user’s spot account and sub user’s spot account is still going through existing endpoint “POST /v1/subuser/transfer”. Asset transfer between parent user’s margin account and sub user’s margin account will not be supported.

Currently parent user is able to query aggregated spot account balance from all sub users through existing endpoint “GET /v1/subuser/aggregate-balance”. Since the effective day of this notification, this endpoint will be supporting aggregated margin account balance from all sub users as well. A new enumerated value “margin” will be added into existing field “type” in response message, in order to differentiate the aggregated balance which is coming from spot account or margin account. (margin account balance = user’s equity – unpaid principal – unpaid interest)

Currently parent user is able to query individual’s spot account balance from specific sub user through existing endpoint “GET /v1/account/accounts/{sub-uid}”. Since the effective day of this notification, this endpoint will be supporting individual’s margin account balance as well. A new field “symbol” will be added into response message, in order to differentiate margin accounts of the sub user.

Currently both parent user and sub user are able to query their own loan orders through existing endpoint “GET /v1/margin/loan-orders”. Since the effective day of this notification, by adding a new optional field “sub-uid” in the request, parent user will be allowed to query loan orders of a specific sub user. If “sub-uid” is not specified, this endpoint will still return loan orders from current logged-in user.

Currently both parent user and sub user are able to query their own margin account balance through existing endpoint “GET /v1/margin/ accounts/balance”. Since the effective day of this notification, by adding a new optional field “sub-uid” in the request, parent user will be allowed to query margin account balance of a specific sub user. If “sub-uid” is not specified, this endpoint will still return margin account balance from current logged-in user.

Parent user is only able to authorize a sub user for margin trading from HTX official web. An authorized sub user will be able to trade all eligible symbols in margin mode, and share the credit quota with parent user.

1、REST API version 1 – Parent User to Query All Sub Users’ Aggregated Account Balance
GET /v1/subuser/aggregate-balance (API Key Permission: Read)
Request parameter(s):N/A

Response:

Parameter Required Data Type Description Value Range
status true   Status "OK" or "Error"
data true list    
{ currency true string Currency  
type true string Account type spot, margin
balance } true string Accumulated balance from all sub users  

2、REST API version 1 – Parent User to Query Specific Sub User’s Account Balance
GET /v1/account/accounts/{sub-uid} (API Key Permission: Read)
Request parameter(s):N/A

Response:

Parameter Required Data Type Description Value Range
status true   Status "OK" or "Error"
data true list    
{ id true string Sub user account ID  
type true string Account type spot, margin
symbol true string Trading symbol  
state true string Account status working, lock
list true object    
{ currency true string Currency  
type true string Type of balance trade, frozen, loan, interest
Balance }} true decimal Balance  

3、REST API version 1 – Query Loan Orders
GET /v1/margin/loan-orders (API Key Permission: Read)

Request parameter(s):

Parameter Required Data Type Description Default Value Value Range
symbol true string Trading symbol NA  
start-date false string Start date of the query in format yyyy-mm-dd -61d  
end-date false string End date of the query in format yyyy-mm-dd Today  
states false string Order status all created,accrual,cleared,invalid
from false string Start ID of the query NA  
direct false string Direction of the searchin next prev - in ascending order from the start IDnext - in descending order from the start ID
size false string Number of items in each response 100 [1,100]
sub-uid false int Sub user ID (mandatory field while parent user querying sub user’s orders) If not entered, by default it returns margin orders of current user  

Response:

Parameter Required Data Type Description Value Range
status true   Status "OK" or "Error"
data true list    
{ id true long Order ID  
user-id true long User ID  
account-id true long Account ID  
symbol true string Trading symbol  
currency true string Currency  
loan-amount true string Debt amount  
loan-balance true string Unpaid debt  
interest-rate true string Interest rate  
 interest-amount true string Interest amount  
interest-balance true string Unpaid interest  
created-at true long Order creation time  
accrued-at true long Last counting time of interest  
state } true string Order status created,accrual,cleared,invalid

4、REST API version 1 – Query Margin Account Balance
GET /v1/margin/accounts/balance (API Key Permission: Read)
Request parameter(s):

Parameter Required Data Type Description Default Value Value Range
symbol false string Trading symbol all  
sub-uid false int Sub user ID (mandatory field while parent user querying sub user’s margin account details) If not entered, by default it returns margin account details of current user  

Response:

Parameter Required Data Type Description Value Range
status true   Status "OK" or "Error"
data true list    
{ id true string Account ID  
symbol true string Trading symbol  
state true string Account status working,fl-sys,fl-mgt,fl-end
risk-rate true string Risk rate  
fl-price true string Liquidation price  
list true object    
{ currency true string Currency  
type true string Type of balance trade, frozen, loan, interest
Balance }} true decimal Balance