> ## Documentation Index
> Fetch the complete documentation index at: https://docs.monochrome.exchange/llms.txt
> Use this file to discover all available pages before exploring further.

# 订单

> 合约 API：订单。

## 下单

`POST` `/future/trade/v1/order/create`

Content-Type = application/x-www-form-urlencoded && application/json

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| clientOrderId | string | false | N/A | 自定义订单id | |
| symbol | string | true | | 交易对 | |
| orderSide | string | true | N/A | 买卖方向：BUY;SELL | BUY;SELL |
| orderType | string | true | N/A | 订单类型：LIMIT；MARKET | LIMIT；MARKET |
| origQty | number | true | N/A | 数量（张） | |
| price | number | false | N/A | 价格 | |
| timeInForce | string | false | GTC | 有效方式：GTC;IOC;FOK;GTX | GTC;IOC;FOK;GTX |
| triggerProfitPrice | number | false | N/A | 止盈价 | |
| triggerStopPrice | number | false | N/A | 止损价 | |
| positionSide | string | true | N/A | 仓位方向：LONG;SHORT | LONG;SHORT |

### OrigQty 计算公式

**公式**

origQty = Truncate ((Balance \* Percent \* Leverage ) / (Mark\_price \* Contract\_size))

**解释**

```text theme={null}
Truncate : 取整数部分 

Balance : (walletBalance - openOrderMarginFrozen) , api: /future/user/v1/compat/balance/list  

Percent : 用户输入 , 例如: 0.2 

Leverage : 杠杆倍数 , 例如: 20 

Mark_price : 市场标记价格 , 例如: 88888 (btc_usdt) 

Contract_size : 合约面值 , api: /future/market/v1/public/symbol/detail , Contract multiplier(face value)  
```

**举例**

truncate(10000 \* 0.2 \* 20 / 88888 / 0.0001) = 4500

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": {},
  "returnCode": 0
}
```

## 查询历史订单

`GET` `/future/trade/v1/order/list-history`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | false | N/A | 交易对 | |
| direction | string | false | NEXT | 方向（PREV:上一页；NEXT:下一页） | PREV;NEXT |
| id | integer | false | N/A | id | |
| limit | integer | false | 10 | 条数 | |
| startTime | integer | false | N/A | 起始时间 | |
| endTime | integer | false | N/A | 结束时间 | |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": {
    "hasNext": false, //是否有下一页
    "hasPrev": false, //是否有上一页
    "items": [ //数据列表
      {
        "clientOrderId": "", //自定义订单id
        "avgPrice": 0, //成交均价
        "closePosition": false, //是否条件全平仓
        "closeProfit": 0, //平仓盈亏
        "createdTime": 0, //创建时间
        "executedQty": 0, //已成交数量（张）
        "forceClose": false, //是否是强平订单
        "marginFrozen": 0, //占用保证金
        "orderId": 0, //订单id
        "orderSide": "", //买卖方向
        "orderType": "", //订单类型
        "origQty": 0, //数量（张）
        "positionSide": "", //持仓方向
        "price": 0, //委托价格
        "sourceId": 0, //条件触发id
        "state": "", //订单状态 NEW：新建订单（未成交）；PARTIALLY_FILLED：部分成交；PARTIALLY_CANCELED：部分撤销；FILLED：全部成交；CANCELED：已撤销；REJECTED：下单失败；EXPIRED：已过期
        "symbol": "", //交易对
        "timeInForce": "", //有效类型
        "triggerProfitPrice": 0, //止盈触发价
        "triggerStopPrice": 0 //止损触发价
      }
    ]
  },
  "returnCode": 0
}
```

## 查询成交明细

`GET` `/future/trade/v1/order/trade-list`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| orderId | integer | false | N/A | 订单id | |
| symbol | string | false | N/A | 交易对 | |
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 单页数 | |
| startTime | integer | false | N/A | 起始时间 | |
| endTime | integer | false | N/A | 结束时间 | |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": {
    "items": [
      {
        "fee": 0,               //手续费
        "feeCoin": "",          //手续费币种
        "orderId": 0,           //订单id
        "execId": 0,            //成交id
        "price": 0,             //成交价格
        "quantity": 0,          //成交数量
        "symbol": "",           //交易对
        "timestamp": 0,         //时间
        "takerMaker": "TAKER"   
      }
    ],
    "page": 0,
    "ps": 0,
    "total": 0
  },
  "returnCode": 0
}
```

## 改单

`POST` `/future/trade/v1/order/update`

Content-Type = application/x-www-form-urlencoded && application/json

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| orderId | number | true | | 订单id | |
| price | number | true | | 目标价格 | |
| origQty | number | true | | 目标数量（张） | |
| triggerProfitPrice | number | false | N/A | 止盈价格 | |
| triggerStopPrice | number | false | N/A | 止损价格 | |
| triggerPriceType | string | false | LATEST\_PRICE | 触发价格类型 | INDEX\_PRICE(指数价格)；MARK\_PRICE(标记价格)；LATEST\_PRICE(最新价) |
| profitDelegateOrderType | string | false | N/A | 止盈委托订单类型 | LIMIT(限价)；MARKET(市价) |
| profitDelegateTimeInForce | string | false | N/A | 止盈委托有效方式 | GTC;IOC;FOK;GTX |
| profitDelegatePrice | number | false | N/A | 止盈委托委托价格 | |
| stopDelegateOrderType | string | false | N/A | 止损委托订单类型 | LIMIT(限价)；MARKET(市价) |
| stopDelegateTimeInForce | string | false | N/A | 止损委托有效方式 | GTC;IOC;FOK;GTX |
| stopDelegatePrice | number | false | N/A | 止损委托价格 | |
| followUpOrder | boolean | false | N/A | | 如果为 true，则表示为追单订单 |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": {},
  "returnCode": 0
}
```

## 批量下单

`POST` `/future/trade/v2/order/create-batch`

Content-Type = application/x-www-form-urlencoded && application/json

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| list | string | true | N/A | 下单数据的list集合 | |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": true,
  "returnCode": 0
}
```

## 根据id查询订单

`GET` `/future/trade/v1/order/detail`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| orderId | integer | true | N/A | 订单id | |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": {
    "avgPrice": 0, //成交均价
    "closePosition": false, //是否条件全平仓
    "closeProfit": 0, //平仓盈亏
    "createdTime": 0, //创建时间
    "executedQty": 0, //已成交数量（张）
    "forceClose": false, //是否是强平订单
    "marginFrozen": 0, //占用保证金
    "orderId": 0, //订单id
    "orderSide": "", //买卖方向
    "orderType": "", //订单类型
    "origQty": 0, //数量（张）
    "positionSide": "", //持仓方向
    "price": 0, //委托价格
    "sourceId": 0, //条件触发id
    "state": "", //订单状态 NEW：新建订单（未成交）；PARTIALLY_FILLED：部分成交；PARTIALLY_CANCELED：部分撤销；FILLED：全部成交；CANCELED：已撤销；REJECTED：下单失败；EXPIRED：已过期
    "symbol": "", //交易对
    "timeInForce": "", //有效类型
    "triggerProfitPrice": 0, //止盈触发价
    "triggerStopPrice": 0 //止损触发价
  },
  "returnCode": 0
}
```

## 查询订单

`GET` `/future/trade/v1/order/list`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| clientOrderId | String | false | N/A | 自定义订单id | |
| page | integer | false | 1 | 页码 | |
| size | integer | false | 10 | 单页数 | |
| startTime | integer | false | N/A | 开始时间 | |
| endTime | integer | false | N/A | 结束时间 | |
| state | string | false | NEW | 订单状态 NEW：新建订单（未成交）；PARTIALLY\_FILLED：部分成交；FILLED：全部成交；CANCELED：用户撤销；REJECTED：下单失败；EXPIRED：已过期；UNFINISHED：未完成；HISTORY：（历史） | |
| symbol | string | false | N/A | 交易对 | |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": {
    "items": [
      {
        "clientOrderId": "", //自定义订单id
        "avgPrice": 0, //成交均价
        "closePosition": false, //是否条件全平仓
        "closeProfit": 0, //平仓盈亏
        "createdTime": 0, //创建时间
        "executedQty": 0, //已成交数量（张）
        "forceClose": false, //是否是全平订单
        "marginFrozen": 0, //占用保证金
        "orderId": 0, //订单id
        "orderSide": "", //买卖方向
        "orderType": "", //订单类型
        "origQty": 0, //数量（张）
        "positionSide": "", //持仓方向
        "price": 0, //委托价格
        "sourceId": 0, //条件触发id
        "state": "", //订单状态 NEW：新建订单（未成交）；PARTIALLY_FILLED：部分成交；PARTIALLY_CANCELED：部分撤销；FILLED：全部成交；CANCELED：已撤销；REJECTED：下单失败；EXPIRED：已过期
        "symbol": "", //交易对
        "timeInForce": "", //有效类型
        "triggerProfitPrice": 0, //止盈触发价
        "triggerStopPrice": 0 //止损触发价
      }
    ],
    "page": 0,
    "ps": 0,
    "total": 0
  },
  "returnCode": 0
}
```

## 撤销订单

`POST` `/future/trade/v1/order/cancel`

Content-Type = application/x-www-form-urlencoded && application/json

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| orderId | Integer | true | N/A | 订单id | |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": "", //订单id
  "returnCode": 0
}
```

## 撤销所有订单

`POST` `/future/trade/v1/order/cancel-all`

Content-Type = application/x-www-form-urlencoded && application/json

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | String | true | N/A | 交易对（传空字符串撤销所有交易对订单） | |

### 限流规则

200/s/apikey

```json Response theme={null}
{
  "error": {
    "code": "",
    "msg": ""
  },
  "msgInfo": "",
  "result": true,
  "returnCode": 0
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.