Order
Order
Attribute Name | Type | Description | Example |
---|---|---|---|
id | number | id of order | |
asset_pair_name | string | name of asset pair | |
price | string | order price | |
amount | string | order amount | |
filled_amount | string | already filled amount | |
avg_deal_price | string | average price of the deal | |
side | string | order side, one of ASK/BID | |
state | string | order status, one of FILLED/PENDING/CANCELLED/FIRED/REJECTED | |
created_at | string | created time | |
updated_at | string | updated time | |
type | string | order type, one of LIMIT/MARKET/STOP_LIMIT/STOP_MARKET | |
stop_price | string | order stop_price, only for stop order | |
operator | string | operator, one of GTE/LTE | |
immediate_or_cancel | bool | only use in limit type | |
post_only | bool | only use in limit type | |
client_order_id | string | client order id, assigned by the customer himself to identify the order. must match ^[a-zA-Z0-9-_]{1,36}$ this regex. |
Get user orders in a asset pair
GET /viewer/orders
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_pair_name | string | true | asset pair Name | BTC-USDT |
page_token | string | false | request page after this page token | |
side | string | false | order side, one of "ASK"/"BID" | |
state | string | false | order state, one of PENDING/OPENING/CLOSED/NONE_FILLED/ALL, default is PENDING. CLOSED = FILLED + CANCELLED; OPENING = PENDING = FIRED + PENDING; NONE_FILLED is used for querying the orders which state is closed and filled amount is zero;ALL return customer all orders | |
limit | string | false | default 20; max 200. |
Response is Order array.
{
"data": [{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"type": "LIMIT",
"stop_price": "9.8",
"operator": "LTE",
"immediate_or_cancel": true,
"post_only": false,
"client_order_id": "",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}],
"page_token":"dxzef"
}
Get one order
1. Get order by id in path:
GET /viewer/orders/{id}
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
id | string | true | order id | 10 |
2. Get order by id or client_order_id in query:
GET /viewer/order
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
order_id | string | false | order id | 10 |
client_order_id | string | false | client order id |
Response is Order object.
{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"type": "LIMIT",
"stop_price": "9.8",
"operator": "LTE",
"immediate_or_cancel": true,
"post_only": false,
"client_order_id": "",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}
Create Order
POST /viewer/orders
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_pair_name | string | true | asset pair name | BTC-USDT |
side | string | true | order side, one of "ASK"/"BID" | |
price | string | true | order price | |
amount | string | true | must larger than 0 | |
type | string | true | order type, one of LIMIT/MARKET/STOP_LIMIT/STOP_MARKET | |
stop_price | string | false | must larger than 0, only for stop order. in BID side, price cannot be higher than 110% of the stop_price; in ASK side, price cannot be lower than 90% of the stop_price | |
operator | string | false | operator, one of GTE/LTE, only for stop order, gte – greater than and equal (>=), lte – less than and equal (<=) | |
immediate_or_cancel | bool | false | only use in limit type , must be false when post_only is true | |
post_only | bool | false | only use in limit type, must be false when immediate_or_cancel is true | |
client_order_id | string | false | must match ^[a-zA-Z0-9-_]{1,36}$ this regex. client_order_id is unique in 24 hours, If created 24 hours later and the order closed, it will be released and can be reused |
Price's scale should less than AssetPair's quote scale Amount's scale should less than AssetPair's base scale
Price * Amount should larger than AssetPair's min_quote_value
Request body should be a json string.
The header of Content-Type
should be application/json
.
Http request example (raw data)
POST /api/v3/viewer/orders HTTP/1.1
Content-Type: application/json
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MTAwMiwiaWRlbnRpdHkiOm51bGwsInR5cGUiOiJCYXNpYyIsImV4cCI6MTU1MDc0MDM1NCwiaWF0IjoxNTUwNDgxMTU0LCJpc3MiOiJCcm9rZXIiLCJuYmYiOjE1NTA0ODExNTMsInN1YiI6MTAwMn0.4cZZ7hFOyfbROr8EZ6-lu20W--T-P35iSOLMOQuqWp8
Host: b1.run
Connection: close
{"asset_pair_name":"BTC-USDT","side":"ASK","price":"10001","amount":"0.1", "type":"STOP_LIMIT", "stop_price":"10000", "operator":"GTE"}
Response is Order object.
{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"type": "STOP_LIMIT",
"stop_price": "9.8",
"operator": "LTE",
"immediate_or_cancel": false,
"post_only": true,
"client_order_id": "",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}
Multiple Create Orders
POST /viewer/orders/multi
Only Limit or Market order is allowed to multiple create, Stop order is not allowed. The quantity limit of multiple create orders: 10
Notice: If an error occurs in it, all order creations fail.
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_pair_name | string | true | asset pair name | BTC-USDT |
side | string | true | order side, one of "ASK"/"BID" | |
price | string | true | order price | |
amount | string | true | must larger than 0 | |
type | string | true | order type, one of LIMIT/MARKET | |
immediate_or_cancel | bool | false | only use in limit type , must be false when post_only is true | |
post_only | bool | false | only use in limit type, must be false when immediate_or_cancel is true | |
client_order_id | string | false | must match ^[a-zA-Z0-9-_]{1,36}$ this regex. client_order_id is unique in 24 hours, If created 24 hours later and the order closed, it will be released and can be reused |
Request body
[{
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"side": "ASK",
"amount": "1",
"type": "STOP_LIMIT",
"stop_price": "9.8",
"operator": "LTE",
"immediate_or_cancel": false,
"post_only": true,
}]
Response is Order array.
[{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "FILLED",
"type": "STOP_LIMIT",
"stop_price": "9.8",
"operator": "LTE",
"immediate_or_cancel": false,
"post_only": true,
"client_order_id": "",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}]
Cancel Order
Notice: When canceling an order, if not found in opening orders, will return a NotFound error, Code: 10013
1. Cancel order by id in path:
POST /viewer/orders/{id}/cancel
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
id | number | true | order id |
2. Cancel order by id or client_order_id in query:
POST /viewer/order/cancel
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
order_id | string | false | order id | 10 |
client_order_id | string | false | client order id |
Response is Order object.
{
"id": 10,
"asset_pair_name": "EOS-BTC",
"price": "10.00",
"amount": "10.00",
"filled_amount": "9.0",
"avg_deal_price": "12.0",
"side": "ASK",
"state": "CANCELLED",
"type": "STOP_LIMIT",
"stop_price": "9.8",
"operator": "LTE",
"immediate_or_cancel": false,
"post_only": true,
"client_order_id": "",
"created_at":"2019-01-29T06:05:56Z",
"updated_at":"2019-01-29T06:05:56Z"
}
Cancel All Orders
POST /viewer/orders/cancel
Parameters
Name | Type | Require | Description | Example |
---|---|---|---|---|
asset_pair_name | string | true | asset pair name | BTC-USDT |
Response example.
{
"code":0,
"data": {
"cancelled":[
58272370,
58272377
],
"failed":[]
}
}