Trading

This is a page about trading.

Place order

REQUEST

  • POST /v1/trading/orders

  • Request Headers:

    namevaluerequireddesc
    Content-Typeapplication/jsonYES
    Authorizationyour access_tokenYES
  • Request body Schema: application/json

  • Request body parameters:

    nametyperequireddescription
    account_idstringYaccount id
    symbolstringYstock symbol,eg: us-BABA or us-AAPL
    order_typestringYeg: MARKET or LIMIT,see: Order Type Definations
    qtystringYtrade quantity
    pricestringYtrade price
    actionstringYeg: OPEN / CLOSE, see: Trade Action Definations
    client_order_idstringYclient uniq id

RESPONSE

  • Response body schema: application/json

  • Response body sample:

    {
    	"code": 0,
    	"msg": "Ok",
    	"data": {
    		"order_id": "EB480BB859F0428598BE2C323C849058"
    	}
    }
    

Cancel order

REQUEST

  • POST /v1/trading/orders/cancel

  • Request Headers:

    namevaluerequireddesc
    Content-Typeapplication/jsonYES
    Authorizationyour access_tokenYES
  • Request body Schema: application/json

  • Request body parameters:

    nametyperequireddescription
    account_idstringYaccount id
    symbolstringYstock symbol,eg: us-BABA or us-AAPL
    order_idstringYpending order id

RESPONSE

  • Response body schema: application/json

  • Response body sample:

    {
    	"code": 0,
    	"msg": "Ok"
    }
    

Order list query

REQUEST

  • GET /v1/trading/orders/pending

  • Request Headers:

    namevaluerequireddesc
    Content-Typeapplication/jsonYES
    Authorizationyour access_tokenYES
  • Request url parameters:

    nametyperequireddescription
    account_idstringYaccount id

RESPONSE

  • Response body schema: application/json

  • Response body sample:

    {
    	"code": 0,
    	"msg": "Ok",
    	"data": {
    		"orders": [{
    			"symbol": "us-BABA",
    			"created_at": "2023-03-23 00:53:26",
    			"expired_at": "2023-03-23 23:50:00",
    			"price": "83.0",
    			"qty": "1",
    			"action": "OPEN",
    			"currency": "USD",
    			"commission": "0.00",
    			"order_type": "LIMIT",
    			"order_id": "EB480BB859F0428598BE2C323C849058",
    			"status": "SUBMITTED"
    		}
    }
    

Order query

REQUEST

  • GET /v1/trading/orders/get

  • Request Headers:

    namevaluerequireddesc
    Content-Typeapplication/jsonYES
    Authorizationyour access_tokenYES
  • Request url parameters:

    nametyperequireddescription
    account_idstringYaccount id
    order_idstringYorder id

RESPONSE

  • Response body schema: application/json

  • Response body sample:

    {
    	"code": 0,
    	"msg": "Ok",
    	"data": {
    		"symbol": "us-BABA",
    		"matched_qty": "0",
    		"created_at": "2023-03-23 00:53:26",
    		"expired_at": "2023-03-23 23:50:00",
    		"matched_at": "",
    		"price": "83.0",
    		"earn": "0.00",
    		"qty": "1",
    		"action": "OPEN",
    		"currency": "USD",
    		"commission": "0.00",
    		"order_type": "LIMIT",
    		"order_id": "EB480BB859F0428598BE2C323C849058",
    		"matched_price": "0.000",
    		"status": "SUBMITTED"
    	}
    }
    

History order inquiry

REQUEST

  • GET /v1/trading/orders/history

  • Request Headers:

    namevaluerequireddesc
    Content-Typeapplication/jsonYES
    Authorizationyour access_tokenYES
  • Request url parameters:

    nametyperequireddescription
    account_idstringYaccount id
    start_timestringNquery start time, eg: 2023-01-01 00:00:00
    end_timestringNquey end time, eg: 2023-03-23 00:00:00
    pageintegerNpage index, default: 1
    page_sizeintegerNpage size, default: 20

RESPONSE

  • Response body schema: application/json

  • Response body sample:

    {
    	"code": 0,
    	"msg": "Ok",
    	"data": {
    		"pages": {
    			"page_index": 1, // Current page number
    			"total": 1, // Total number of orders
    			"pages": 1 // Maximum page number
    		},
    		"orders": [{
    			"symbol": "us-BABA",
    			"matched_qty": "0", // Quantity filled
    			"created_at": "2023-03-23 00:53:26", // Creation time
    			"expired_at": "2023-03-23 23:50:00", // Expiration time
    			"matched_at": "", // Filled time
    			"price": "0.00", // Order price
    			"earn": "0.00", // Profit and loss
    			"qty": "1", // Order quantity
    			"action": "OPEN",
    			"currency": "USD",
    			"commission": "0.00",
    			"order_type": "MARKET",
    			"order_id": "EB480BB859F0428598BE2C323C849058",
    			"matched_price": "0.000", // Price filled
    			"status": "SUBMITTED" // Order status
    		}]
    	}
    }
    

Asset data query

REQUEST

  • GET /v1/trading/accounts/{account_id}

  • Request Headers:

    namevaluerequireddesc
    Content-Typeapplication/jsonYES
    Authorizationyour access_tokenYES
  • Request path parameters:

    nametyperequireddescription
    account_idstringYaccount id

RESPONSE

  • Response body schema: application/json

  • Response body sample:

    {
    	"code": 0,
    	"msg": "Ok",
    	"data": {
    		"account_id": "1638075659031023616",
    		"currency": "USD",
    		"equity": "50000.00", // Net value
    		"balance": "50000.00", // Account balance
    		"frozen": "0.00", // Frozen funds in trading
    		"mkt_value": "0.00", // Total market value of positions
    		"transfers_frozen": "0.00", // Frozen funds in deposits and withdrawals
    		"withdrawable": "50000.00", // Withdrawable amount
    		"earn": "0.00" // Total floating profit and loss of positions
    	}
    }
    

Position inquiry

REQUEST

  • GET /v1/trading/positions/{account_id}

  • Request Headers:

    namevaluerequireddesc
    Content-Typeapplication/jsonYES
    Authorizationyour access_tokenYES
  • Request path parameters:

    nametyperequireddescription
    account_idstringYaccount id

RESPONSE

  • Response body schema: application/json

  • Response body sample:

    {
    	"code": 0,
    	"msg": "Ok",
    	"data": {
    		"positions": [{
    			"symbol": "us-JD",
    			"mkt_value": "38.50", // Market value of position
    			"avail_qty": "1", // Available quantity for selling
    			"earn": "-21.87", // Floating profit and loss
    			"qty": "1", // Total quantity held
    			"cur_price": "38.500", // Current price
    			"earn_rate": "-0.3623", // Floating profit and loss rate
    			"currency": "USD",
    			"cost_price": "60.370" // Purchase cost price
    		}]
    	}
    }
    

Definitions

Response code

codemessage
0Ok
4001Internal Server Error
4002Invalid Request
4003Account Not Found
4004Unsupported

Order Type

valuedescription
MARKETMarket order
LIMITLimit order

Trade Action

valuedescription
OPENBuy/Open position
CLOSESell/Close position

Order Status

valuedescription
WAITING_SUBMITWaiting to submit
MATCHEDExecuted
CANCELLEDSuccessfully cancelled
INVALIDInvalid
PART_MATCHEDPartially executed
SUBMITTEDSubmitted
SUBMITTINGSubmitting
WAITING_CANCELWaiting to cancel
SUBMITTING_CANCELCancelling
SUBMITTED_CANCELCancel request submitted
PART_CANCELLEDPartially executed, remainder cancelled successfully
PART_CANCEL_SUBMITTINGPartially executed, remainder cancelling
PART_CANCEL_SUBMITTEDPartially executed, remainder cancellation request submitted
PART_INVALIDPartially executed, remainder invalidated