Trading
This is a page about trading.
Place order
REQUEST
POST /v1/trading/orders
Request Headers:
name value required desc Content-Type application/json YES Authorization your access_token YES Request body Schema: application/json
Request body parameters:
name type required description account_id string Y account id symbol string Y stock symbol,eg: us-BABA or us-AAPL order_type string Y eg: MARKET or LIMIT,see: Order Type Definations qty string Y trade quantity price string Y trade price action string Y eg: OPEN / CLOSE, see: Trade Action Definations client_order_id string Y client 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:
name value required desc Content-Type application/json YES Authorization your access_token YES Request body Schema: application/json
Request body parameters:
name type required description account_id string Y account id symbol string Y stock symbol,eg: us-BABA or us-AAPL order_id string Y pending 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:
name value required desc Content-Type application/json YES Authorization your access_token YES Request url parameters:
name type required description account_id string Y account 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:
name value required desc Content-Type application/json YES Authorization your access_token YES Request url parameters:
name type required description account_id string Y account id order_id string Y order 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:
name value required desc Content-Type application/json YES Authorization your access_token YES Request url parameters:
name type required description account_id string Y account id start_time string N query start time, eg: 2023-01-01 00:00:00 end_time string N quey end time, eg: 2023-03-23 00:00:00 page integer N page index, default: 1 page_size integer N page 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:
name value required desc Content-Type application/json YES Authorization your access_token YES Request path parameters:
name type required description account_id string Y account 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:
name value required desc Content-Type application/json YES Authorization your access_token YES Request path parameters:
name type required description account_id string Y account 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
| code | message |
|---|---|
| 0 | Ok |
| 4001 | Internal Server Error |
| 4002 | Invalid Request |
| 4003 | Account Not Found |
| 4004 | Unsupported |
Order Type
| value | description |
|---|---|
| MARKET | Market order |
| LIMIT | Limit order |
Trade Action
| value | description |
|---|---|
| OPEN | Buy/Open position |
| CLOSE | Sell/Close position |
Order Status
| value | description |
|---|---|
| WAITING_SUBMIT | Waiting to submit |
| MATCHED | Executed |
| CANCELLED | Successfully cancelled |
| INVALID | Invalid |
| PART_MATCHED | Partially executed |
| SUBMITTED | Submitted |
| SUBMITTING | Submitting |
| WAITING_CANCEL | Waiting to cancel |
| SUBMITTING_CANCEL | Cancelling |
| SUBMITTED_CANCEL | Cancel request submitted |
| PART_CANCELLED | Partially executed, remainder cancelled successfully |
| PART_CANCEL_SUBMITTING | Partially executed, remainder cancelling |
| PART_CANCEL_SUBMITTED | Partially executed, remainder cancellation request submitted |
| PART_INVALID | Partially executed, remainder invalidated |