# 合约交易

公共

### 安全类型: None

公共下方的接口不需要API-key或者签名就能自由访问

***

## &#x20;测试连接

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/ping`

测试REST API的连通性

{% tabs %}
{% tab title="200  连接正常" %}

```
{}
```

{% endtab %}
{% endtabs %}

***

## 获取服务器时间

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/time`

{% tabs %}
{% tab title="200 " %}

```json
{
    "timezone": "China Standard Time",
    "serverTime": 1704962055664
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="153">名称</th><th width="121">类型</th><th width="193">例子</th><th>描述</th></tr></thead><tbody><tr><td>timezone</td><td>string</td><td>China Standard Time</td><td>服务器时区</td></tr><tr><td>serverTime</td><td>long</td><td>1607702400000</td><td>服务器时间戳</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## 合约列表

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/contracts`

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "symbol": "E-ETC-USDT",
        "pricePrecision": 3,
        "side": 1,
        "maxMarketVolume": 200000,
        "multiplier": 1.0000000000000000,
        "minOrderVolume": 1,
        "maxMarketMoney": 500000.0000000000000000,
        "type": "E",
        "maxLimitVolume": 300000,
        "maxValidOrder": 10,
        "multiplierCoin": "ETC",
        "minOrderMoney": 1.0000000000000000,
        "maxLimitMoney": 500000.0000000000000000,
        "status": 1
    },
    {
        "symbol": "E-ATOM-USDT",
        "pricePrecision": 3,
        "side": 1,
        "maxMarketVolume": 100000,
        "multiplier": 1.0000000000000000,
        "minOrderVolume": 1,
        "maxMarketMoney": 200000.0000000000000000,
        "type": "E",
        "maxLimitVolume": 200000,
        "maxValidOrder": 10,
        "multiplierCoin": "ATOM",
        "minOrderMoney": 20.0000000000000000,
        "maxLimitMoney": 2000000.0000000000000000,
        "status": 1
    }
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th>名称</th><th width="136">类型</th><th width="168">例子</th><th>描述</th></tr></thead><tbody><tr><td>symbol</td><td>string</td><td><code>E-BTC-USDT</code></td><td>大写合约名称</td></tr><tr><td>pricePrecision</td><td>number</td><td>4</td><td>价格精度</td></tr><tr><td>status</td><td>number</td><td><code>1</code></td><td>合约状态（0：不可交易，1：可交易</td></tr><tr><td>type</td><td>string</td><td><code>S</code></td><td>合约类型 (E:永续合约，S:模拟合约，其他为混合合约)</td></tr><tr><td>side</td><td>number</td><td><code>1</code></td><td>合约方向 (0: 反向，1：正向)</td></tr><tr><td>multiplier</td><td>number</td><td><code>0.50</code></td><td>合约面值</td></tr><tr><td>minOrderVolume</td><td>number</td><td><code>10</code></td><td>最小下单量</td></tr><tr><td>minOrderMoney</td><td>number</td><td><code>10</code></td><td>最小下单金额</td></tr><tr><td>maxMarketVolume</td><td>number</td><td><code>100000</code></td><td>市价单最大下单数量</td></tr><tr><td>maxMarketMoney</td><td>number</td><td><code>100000.00</code></td><td>市价最大下单金额</td></tr><tr><td>maxLimitVolume</td><td>number</td><td><code>100000</code></td><td>限价单最大下单数量</td></tr><tr><td>maxLimitMoney</td><td>number</td><td><code>100000.00</code></td><td>限价最大下单金额</td></tr><tr><td>maxValidOrder</td><td>number</td><td><code>100000</code></td><td>最大有效委托的订单数量</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## 行情相关

### 安全类型: None

行情下方的接口不需要API-Key或者签名就能自由访问

## &#x20;订单薄

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/depth`

市场订单薄深度信息

#### Query Parameters

| Name         | Type    | Description         |
| ------------ | ------- | ------------------- |
| limit        | integer | 默认100; 最大100        |
| contractName | string  | 大写合约名称 如 E-BTC-USDT |

{% tabs %}
{% tab title="200  成功获取深度信息" %}

```java
{
  "asks": [
    [
      "4.00000200",  // 价格
      "12.00000000"  // 数量
    ],
    [
      "5.10000000",
      "28.00000000"
    ]
  ],
  "bids": [
    [
      "3.90000000",   // 价格
      "431.00000000"  // 数量
    ],
    [
      "4.00000000",
      "431.00000000"
    ]
  ],
  "time":1704962463000
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="89">名称</th><th width="71">类型</th><th width="183">例子</th><th>描述</th></tr></thead><tbody><tr><td>time</td><td>long</td><td><code>1595563624731</code></td><td>当前时间(Unix Timestamp, 毫秒ms)</td></tr><tr><td>bids</td><td>list</td><td>[[2100,13],[1990,3]]</td><td>订单薄买盘信息，数组第一位为价格，类型为float；第二位为当前价格对应的数量，类型为float</td></tr><tr><td>asks</td><td>list</td><td>[[2100,13],[1990,3]]</td><td>订单薄卖盘信息，数组第一位为价格，类型为float；第二位为当前价格对应的数量，类型为float</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

{% hint style="info" %}
bids和asks所对应的信息代表了订单薄的所有价格以及价格对应的数量的信息, 由最优价格从上到下排列
{% endhint %}

***

## &#x20;行情ticker

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/ticker`

24小时价格变化数据

#### Query Parameters

| Name                                           | Type   | Description         |
| ---------------------------------------------- | ------ | ------------------- |
| contractName<mark style="color:red;">\*</mark> | string | 大写合约名称 如 E-BTC-USDT |

{% tabs %}
{% tab title="200  成功获取ticker信息" %}

```json
{
    "high": "2500",
    "vol": "0",
    "last": "2500",
    "low": "2500",
    "buy": 2100,
    "sell": 0,
    "rose": "0",
    "time": 1704966225000
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="118">名称</th><th width="112">类型</th><th width="207">例子</th><th>描述</th></tr></thead><tbody><tr><td>time</td><td>long</td><td><code>1595563624731</code></td><td>时间戳</td></tr><tr><td>high</td><td>float</td><td><code>9900</code></td><td>最高价</td></tr><tr><td>low</td><td>float</td><td><code>8800.34</code></td><td>最低价</td></tr><tr><td>last</td><td>float</td><td><code>8900.23</code></td><td>最新价</td></tr><tr><td>vol</td><td>float</td><td><code>4999</code></td><td>交易量</td></tr><tr><td>rose</td><td>string</td><td>+0.05</td><td>涨跌幅，+为涨，-为跌，+0.05为涨5%</td></tr><tr><td>buy</td><td>float</td><td>2100.01</td><td>买一价格</td></tr><tr><td>sell</td><td>float</td><td>2050.01</td><td>卖一价格</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## &#x20;获取指数/标记价格

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/index`

#### Query Parameters

| Name                                           | Type   | Description         |
| ---------------------------------------------- | ------ | ------------------- |
| contractName<mark style="color:red;">\*</mark> | string | 合约名称大写 如 E-BTC-USDT |
| limit                                          | string | 默认100; 最大1000       |

{% tabs %}
{% tab title="200 " %}

```java
{
    "currentFundRate": -0.0037500000000000,
    "indexPrice": 27905.9800000000000000,
    "tagPrice": 27824.4422146875000000,
    "nextFundRate": -0.0037500000000000
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="191">名称</th><th width="108">类型</th><th width="114">例子</th><th>描述</th></tr></thead><tbody><tr><td>indexPrice</td><td>float</td><td><code>0.055</code></td><td>指数价格</td></tr><tr><td>tagPrice</td><td>float</td><td><code>0.0578</code></td><td>标记价格</td></tr><tr><td>nextFundRate</td><td>float</td><td><code>0.343</code></td><td>资金费率价格</td></tr><tr><td>currentFundRate</td><td>float</td><td><code>0.123</code></td><td>上期资金费率(用于本期结算)</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## K线/蜡烛图数据

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/klines`

#### Query Parameters

| Name                                           | Type    | Description                                                                                                    |
| ---------------------------------------------- | ------- | -------------------------------------------------------------------------------------------------------------- |
| contractName<mark style="color:red;">\*</mark> | string  | 合约名称大写 如 E-BTC-USDT                                                                                            |
| interval<mark style="color:red;">\*</mark>     | string  | k线图区间, 可识别的参数值为： `1min`,`5min`,`15min`,`30min`,`1h`,`1day`,`1week`,`1month`（min=分钟，h=小时,day=天，week=星期，month=月） |
| limit                                          | integer | 默认100; 最大300                                                                                                   |
| startTime                                      | long    | <p>时间戳，毫秒（ms）</p><p>1708617600000</p>                                                                          |
| endTime                                        | long    | <p>时间戳，毫秒（ms）</p><p>1708704000000</p>                                                                          |

{% tabs %}
{% tab title="200 " %}

```java
[
    {
        "high": "6228.77",
        "vol": "111",
        "low": "6228.77",
        "idx": 1594640340,
        "close": "6228.77",
        "open": "6228.77"
    },
    {
        "high": "6228.77",
        "vol": "222",
        "low": "6228.77",
        "idx": 1587632160,
        "close": "6228.77",
        "open": "6228.77"
    },
    {
        "high": "6228.77",
        "vol": "333",
        "low": "6228.77",
        "idx": 1587632100,
        "close": "6228.77",
        "open": "6228.77"
    }
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="161">名称</th><th width="114">类型</th><th width="175">例子</th><th>描述</th></tr></thead><tbody><tr><td><code>idx</code></td><td>long</td><td><code>1538728740000</code></td><td>开始时间戳，毫秒（ms）</td></tr><tr><td><code>open</code></td><td>float</td><td><code>36.00000</code></td><td>开盘价</td></tr><tr><td><code>close</code></td><td>float</td><td><code>33.00000</code></td><td>收盘价</td></tr><tr><td><code>high</code></td><td>float</td><td><code>36.00000</code></td><td>最高价</td></tr><tr><td><code>low</code></td><td>float</td><td><code>30.00000</code></td><td>最低价</td></tr><tr><td><code>vol</code></td><td>float</td><td><code>2456.00000</code></td><td>成交量</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## 交易相关

### 安全类型: TRADE

交易下方的接口都需要签名和API-key验证

## 创建订单

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/order`

创建单个新订单

#### Headers

| Name                                          | Type   | Description |
| --------------------------------------------- | ------ | ----------- |
| X-CH-TS<mark style="color:red;">\*</mark>     | string | 时间戳         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string | 您的API-KEY   |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string | 签名          |

#### Request Body

| Name                                           | Type   | Description                                                       |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------- |
| volume<mark style="color:red;">\*</mark>       | number | 下单张数，有精度限制，精度由管理员设置, <mark style="color:red;">市价开仓时这里单位是价值</mark> |
| price                                          | number | 下单价格,限价单时该字段为必传,有精度限制，精度由管理员设置                                    |
| contractName<mark style="color:red;">\*</mark> | string | 大写合约名称 如 `E-BTC-USDT`                                             |
| type<mark style="color:red;">\*</mark>         | string | 订单类型, `LIMIT/MARKET`                                              |
| side<mark style="color:red;">\*</mark>         | string | 买卖方向, `BUY/SELL`                                                  |
| open<mark style="color:red;">\*</mark>         | string | 开平仓方向, `OPEN/CLOSE`                                               |
| positionType                                   | number | 持仓类型, `1:全仓/2:逐仓`                                                 |
| clientOrderId                                  | string | 客户端下单标识, 长度小于32位的字符串                                              |
| timeInForce                                    | string | `IOC, FOK, POST_ONLY`                                             |

{% tabs %}
{% tab title="200 " %}

```java
{
    "orderId": 256609229205684228
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th>名称</th><th width="117">类型</th><th width="221">例子</th><th>描述</th></tr></thead><tbody><tr><td>orderId</td><td>string</td><td><code>256609229205684228</code></td><td>订单ID</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## 创建条件单

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/conditionOrder/`

#### Headers

| Name                                          | Type   | Description |
| --------------------------------------------- | ------ | ----------- |
| X-CH-TS<mark style="color:red;">\*</mark>     | string | 时间戳         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string | 您的API-KEY   |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string | 签名          |

#### Request Body

| Name          | Type   | Description                      |
| ------------- | ------ | -------------------------------- |
| triggerType   | string | 条件的类型，1:止损/2:止盈/3:追涨/4:杀跌        |
| triggerPrice  | string | 触发价                              |
| clientOrderId | string | 客户端下单标识，长度小于32位的字符串              |
| positionType  | number | 持仓类型，1：全仓/2.逐仓                   |
| open          | string | 开平仓方向，OPEN/CLOSE                 |
| side          | string | 买卖方向，BUY/SELL                    |
| type          | string | 订单类型, LIMIT/MARKET               |
| contractName  | string | 大写合约名称 如 E-BTC-USDT              |
| price         | number | 下单价格，有精度限制，精度由管理员设置              |
| volume        | number | 下单数量,市价开仓时这里单位是价值,有精度限制,精度由管理员设置 |

{% tabs %}
{% tab title="200: OK " %}

```json
{
    "code": "0",
    "msg": "Success",
    "data": {
        "triggerIds": [
            "1322738336974712847"
        ],
        "ids": [],
        "cancelIds": []
    },
    "succ": true
}

```

{% endtab %}
{% endtabs %}

{% hint style="warning" %} <mark style="color:orange;">如果该接口返回与期望不符，请联系技术团队，我们会为您提供相关帮助</mark>
{% endhint %}

***

## &#x20;取消订单

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/cancel`

**限速规则: 20次/2s**

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |

#### Request Body

| Name                                           | Type   | Description           |
| ---------------------------------------------- | ------ | --------------------- |
| contractName<mark style="color:red;">\*</mark> | string | 大写合约名称 如 `E-BTC-USDT` |
| orderId<mark style="color:red;">\*</mark>      | string | 订单ID                  |

{% tabs %}
{% tab title="200 " %}

```java
{
    "orderId": 256609229205684228
}
```

{% endtab %}
{% endtabs %}

***

## 订单详情

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/order`

#### Query Parameters

| Name                                            | Type   | Description        |
| ----------------------------------------------- | ------ | ------------------ |
| contractName<mark style="color:red;">\*</mark>  | string | 大写合约名称 如E-BTC-USDT |
| orderId<mark style="color:red;">\*</mark>       | string | 订单ID               |
| clientOrderId<mark style="color:red;">\*</mark> | string | 客户端唯一标识，默认为0       |

{% tabs %}
{% tab title="200 " %}

```json
{
    "side": "BUY",
    "executedQty": 0,
    "orderId": 2006628907041292645,
    "price": 2000.0000000000000000,
    "origQty": 2.0000000000000000,
    "avgPrice": 0E-8,
    "transactTime": 1704967622000,
    "action": "OPEN",
    "contractName": "E-BTC-USDT",
    "type": "LIMIT",
    "timeInForce": "",
    "status": "NEW"
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="177">名称</th><th width="84">类型</th><th width="216">例子</th><th>描述</th></tr></thead><tbody><tr><td><code>orderId</code></td><td>long</td><td><code>150695552109032492</code></td><td>订单ID（系统生成</td></tr><tr><td><code>contractName</code></td><td>string</td><td><code>E-BTC-USDT</code></td><td>大写合约名称</td></tr><tr><td><code>price</code></td><td>float</td><td><code>10.50</code></td><td>委托价格</td></tr><tr><td><code>origQty</code></td><td>float</td><td><code>10.50</code></td><td>委托数量</td></tr><tr><td><code>executedQty</code></td><td>float</td><td><code>10.10</code></td><td>成交数量</td></tr><tr><td><code>avgPrice</code></td><td>float</td><td><code>10.50</code></td><td>成交均价</td></tr><tr><td><code>status</code></td><td>string</td><td><code>NEW</code></td><td>订单状态。可能出现的值为：<code>NEW</code>(新订单，无成交)、<code>PARTIALLY_FILLED</code>（部分成交）、<code>FILLED</code>（全部成交）、<code>CANCELED</code>（已取消）和<code>REJECTED</code>（订单被拒绝）</td></tr><tr><td><code>side</code></td><td>string</td><td><code>NEW</code></td><td>订单方向。可能出现的值只能为：BUY（买入做多） 和 SELL（卖出做空）</td></tr><tr><td><code>action</code></td><td>string</td><td><code>OPEN</code></td><td><code>OPEN/CLOSE</code></td></tr><tr><td><code>transactTime</code></td><td>long</td><td><code>1607702400000</code></td><td>订单创建时间</td></tr><tr><td>type</td><td>string</td><td>LIMIT</td><td>订单类型LIMIT/MARKET</td></tr><tr><td>timeInForce</td><td>integer</td><td>2</td><td>条件单有效方式1 limit， 2 market，3 IOC，4 FOK，5 POST_ONLY</td></tr><tr><td>fills</td><td>[ ]</td><td></td><td>成交记录</td></tr></tbody></table>
{% endtab %}

{% tab title="Fills field:" %}

| 名称             | 类型      | 例子      | 描述     |
| -------------- | ------- | ------- | ------ |
| tradeId        | long    | 3599217 | 成交记录id |
| price          | float   | 45500   | 价格     |
| qty            | integer | 36      | 数量     |
| commission     | float   | 0.01638 | 手续费    |
| commissionCoin | string  | USDT    | 手续费币种  |
| {% endtab %}   |         |         |        |
| {% endtabs %}  |         |         |        |

***

## &#x20;当前订单

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/openOrders`

**限速规则:**\
**获取当前合约, 该用户的当前委托**

#### Query Parameters

| Name         | Type   | Description           |
| ------------ | ------ | --------------------- |
| contractName | string | 需大写合约名称 如`E-BTC-USDT` |

#### Headers

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| X-CH-SIGN   | string | 签名          |
| X-CH-APIKEY | string | 您的API-key   |
| X-CH-TS     | string | 时间戳         |

{% tabs %}
{% tab title="200 " %}

```java
[
    {
       "side": "BUY",
       "executedQty": 0,
       "orderId": 259396989397942275,
       "price": 10000.0000000000000000,
       "origQty": 1.0000000000000000,
       "avgPrice": 0E-8,
       "transactTime": "1607702400000",
       "action": "OPEN",
       "contractName": "E-BTC-USDT",
       "type": "LIMIT",
       "status": "INIT"
    }
]

```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="179">名称</th><th width="92">类型</th><th width="222">例子</th><th>描述</th></tr></thead><tbody><tr><td><code>orderId</code></td><td>long</td><td><code>150695552109032492</code></td><td>订单ID（系统生成）</td></tr><tr><td><code>contractName</code></td><td>string</td><td><code>E-BTC-USDT</code></td><td>大写合约名称</td></tr><tr><td><code>price</code></td><td>float</td><td><code>4765.29</code></td><td>订单价格</td></tr><tr><td><code>origQty</code></td><td>float</td><td><code>1.01</code></td><td>订单数量</td></tr><tr><td><code>executedQty</code></td><td>float</td><td><code>1.01</code></td><td>已经成交订单数量</td></tr><tr><td><code>avgPrice</code></td><td>float</td><td><code>4754.24</code></td><td>订单已经成交的平均价格</td></tr><tr><td><code>type</code></td><td>string</td><td><code>LIMIT</code></td><td>订单类型。可能出现的值只能为:<code>LIMIT</code>(限价)和<code>MARKET</code>（市价）</td></tr><tr><td><code>side</code></td><td>string</td><td><code>BUY</code></td><td>订单方向。可能出现的值只能为：<code>BUY</code>（买入做多） 和 <code>SELL</code>（卖出做空）</td></tr><tr><td><code>status</code></td><td>string</td><td><code>NEW</code></td><td>订单状态。可能出现的值为：<code>NEW</code>(新订单，无成交)、<code>PARTIALLY_FILLED</code>（部分成交）、<code>FILLED</code>（全部成交）、<code>CANCELED</code>（已取消）和<code>REJECTED</code>（订单被拒绝）.</td></tr><tr><td><code>action</code></td><td>string</td><td><code>OPEN</code></td><td><code>OPEN/CLOSE</code></td></tr><tr><td><code>transactTime</code></td><td>long</td><td><code>1607702400000</code></td><td>订单创建时间</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## 历史委托

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/orderHistorical`

#### Headers

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| X-CH-SIGN   | string | 签名          |
| X-CH-APIKEY | string | 您的API-key   |
| X-CH-TS     | string | 时间戳         |

#### Request Body

| Name         | Type   | Description         |
| ------------ | ------ | ------------------- |
| contractName | string | 大写合约名称 `E-BTC-USDT` |
| limit        | string | 分页条数, 默认100; 最大1000 |
| fromId       | long   | 从这条记录开始检索           |

{% tabs %}
{% tab title="200: OK " %}

```javascript
[
    {
        "side":"BUY",
        "clientId":"0",
        "ctimeMs":1632903411000,
        "positionType":2,
        "orderId":777293886968070157,
        "avgPrice":41000,
        "openOrClose":"OPEN",
        "leverageLevel":26,
        "type":4,
        "closeTakerFeeRate":0.00065,
        "volume":2,
        "openMakerFeeRate":0.00025,
        "dealVolume":1,
        "price":41000,
        "closeMakerFeeRate":0.00025,
        "contractId":1,
        "ctime":"2021-09-29T16:16:51",
        "contractName":"E-BTC-USDT",
        "openTakerFeeRate":0.00065,
        "dealMoney":4.1,
        "status":4
    }
]
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %} <mark style="color:orange;">如果该接口返回与期望不符，请联系技术团队，我们会为您提供相关帮助</mark>
{% endhint %}

***

## &#x20;盈亏记录

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/profitHistorical`

<mark style="color:orange;">如果该接口返回报错，请联系技术团队，我们会为您提供相关帮助</mark>

#### Headers

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| X-CH-SIGN   | string | 签名          |
| X-CH-APIKEY | string | 您的API-key   |
| X-CH-TS     | string | 时间戳         |

#### Request Body

| Name         | Type   | Description          |
| ------------ | ------ | -------------------- |
| contractName | string | 大写合约名称 如`E-BTC-USDT` |
| limit        | string | 分页条数, 默认100; 最大1000  |
| fromId       | long   | 从这条记录开始检索            |

{% tabs %}
{% tab title="200: OK " %}

```javascript
[
    {
        "side":"SELL",
        "positionType":2,
        "tradeFee":-5.23575,
        "realizedAmount":0,
        "leverageLevel":26,
        "openPrice":44500,
        "settleProfit":0,
        "mtime":1632882739000,
        "shareAmount":0,
        "openEndPrice":44500,
        "closeProfit":-45,
        "volume":900,
        "contractId":1,
        "historyRealizedAmount":-50.23575,
        "ctime":1632882691000,
        "id":8764,
        "capitalFee":0
    }
]
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %} <mark style="color:orange;">如果该接口返回与期望不符，请联系技术团队，我们会为您提供相关帮助</mark>
{% endhint %}

***

## &#x20;交易记录

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/myTrades`

**限速规则: 20次/2s**

#### Query Parameters

| Name                                           | Type   | Description         |
| ---------------------------------------------- | ------ | ------------------- |
| contractName<mark style="color:red;">\*</mark> | string | 大写合约名称 如 E-BTC-USDT |
| limit                                          | string | 分页条数, 默认100; 最大1000 |
| fromId                                         | long   | 从这个tradeId开始检索      |

#### Headers

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| X-CH-SIGN   | string  | 签名          |
| X-CH-APIKEY | string  | 您的API-key   |
| X-CH-TS     | integer | 时间戳         |

{% tabs %}
{% tab title="200 " %}

```json
[
    {
        "amount": 0.30000000000000000000000000000000,
        "side": "BUY",
        "fee": "0.000075",
        "isMaker": true,
        "isBuyer": true,
        "bidId": 1874564572563538130,
        "bidUserId": 10034,
        "price": 10.0000000000000000,
        "qty": 3,
        "askId": 1954072405852309104,
        "contractName": "E-ETH-USDT",
        "time": 1701419186000,
        "tradeId": 1528,
        "askUserId": 10378
    },
    {
        "amount": 1.00000000000000000000000000000000,
        "side": "BUY",
        "fee": "0.00025",
        "isMaker": true,
        "isBuyer": true,
        "bidId": 1874564572563538059,
        "bidUserId": 10034,
        "price": 10.0000000000000000,
        "qty": 10,
        "askId": 1954072405852309104,
        "contractName": "E-ETH-USDT",
        "time": 1701419186000,
        "tradeId": 1527,
        "askUserId": 10378
    }
]
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

<table><thead><tr><th width="175">名称</th><th width="130">类型</th><th width="212">例子</th><th>描述</th></tr></thead><tbody><tr><td>tradeId</td><td>number</td><td>28457</td><td>交易ID</td></tr><tr><td>bidId</td><td>long</td><td>150695552109032492</td><td>买方订单ID</td></tr><tr><td>askId</td><td>long</td><td>150695552109032493</td><td>卖方订单ID</td></tr><tr><td>bidUserId</td><td>integer</td><td>10024</td><td>买方用户ID</td></tr><tr><td>askUserId</td><td>integer</td><td>10025</td><td>卖方用户ID</td></tr><tr><td>price</td><td>float</td><td>4.01</td><td>成交价格</td></tr><tr><td>qty</td><td>float</td><td>12</td><td>交易数量</td></tr><tr><td>amount</td><td>float</td><td>5.38</td><td>成交金额</td></tr><tr><td>time</td><td>number</td><td>1499865549590</td><td>交易时间戳</td></tr><tr><td>fee</td><td>number</td><td>0.001</td><td>交易手续费</td></tr><tr><td>side</td><td>string</td><td>buy</td><td>当前订单方向 BUY 买入, SELL 卖出</td></tr><tr><td>contractName</td><td>string</td><td>E-BTC-USDT</td><td>大写合约名称</td></tr><tr><td>isMaker</td><td>boolean</td><td>true</td><td>是否是maker</td></tr><tr><td>isBuyer</td><td>boolean</td><td>true</td><td>是否买方</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## 更改持仓模式

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/edit_user_position_model`

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |

#### Request Body

| Name                                            | Type    | Description                |
| ----------------------------------------------- | ------- | -------------------------- |
| contractName<mark style="color:red;">\*</mark>  | string  | 大写合约名称 如 E-BTC-USDT        |
| positionModel<mark style="color:red;">\*</mark> | integer | 持仓模式  （1.净持仓 2.双向持仓）传入1或者2 |

{% tabs %}
{% tab title="200: OK 成功code为 0  ，code小于0为错误，msg为错误原因" %}

```json
{ 
    "code": "0", 
    "msg": "成功", 
    "data": null 
}
```

{% endtab %}
{% endtabs %}

***

## 更改保证金模式

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/edit_user_margin_model`

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |

#### Request Body

| Name                                           | Type    | Description             |
| ---------------------------------------------- | ------- | ----------------------- |
| contractName<mark style="color:red;">\*</mark> | string  | 大写合约名称 如 E-BTC-USDT     |
| marginModel<mark style="color:red;">\*</mark>  | integer | 保证金模式 （1.全仓 2.逐仓）传入1或者2 |

{% tabs %}
{% tab title="200: OK 成功code为 0  ，code小于0为错误，msg为错误原因" %}

```json
{ 
    "code": "0", 
    "msg": "成功", 
    "data": null 
}
```

{% endtab %}
{% endtabs %}

***

## 更改杠杆倍数

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/edit_lever`

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |

#### Request Body

| Name                                           | Type    | Description         |
| ---------------------------------------------- | ------- | ------------------- |
| contractName<mark style="color:red;">\*</mark> | string  | 大写合约名称 如 E-BTC-USDT |
| nowLevel<mark style="color:red;">\*</mark>     | integer | 需要修改的杠杆倍数 如50       |

{% tabs %}
{% tab title="200: OK 成功code为 0  ，code小于0为错误，msg为错误原因" %}

```json
{ 
    "code": "0", 
    "msg": "成功", 
    "data": null 
}
```

{% endtab %}
{% endtabs %}

***

## 获取当前条件单

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/fapi/v1/trigger_order_list`

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |

#### Request Body

| Name                                           | Type    | Description         |
| ---------------------------------------------- | ------- | ------------------- |
| contractName<mark style="color:red;">\*</mark> | string  | 大写合约名称 如 E-BTC-USDT |
| page                                           | integer | 当前页数，默认为1           |
| limit                                          | integer | 分页条数,默认1000条        |

{% tabs %}
{% tab title="200: OK 成功code为 0  ，code小于0为错误，msg为错误原因" %}

```json
{
    "code":"0",
    "msg":"成功",
    "data":{
        "count":2,
        "trigOrderList":[
            {
                "mtime":1706513208000,
                "price":0,
                "ctime":1706513208000,
                "contractName":"BTCUSDT",
                "id":"895",
                "triggerOrderId":"1322738336974712829",
                "pricePrecision":3,
                "side":"BUY",
                "triggerPrice":11111,
                "multiplier":0.0001,
                "marginCoin":"USDT",
                "volume":100,
                "expireTime":1707722808000,
                "contractId":127,
                "triggerType":4,
                "open":"OPEN",
                "status":0
            },
            {
                "mtime":1705978532000,
                "price":0,
                "ctime":1705978532000,
                "contractName":"BTCUSDT",
                "id":"782",
                "triggerOrderId":"1322738336974712828",
                "pricePrecision":3,
                "side":"SELL",
                "triggerPrice":10000,
                "multiplier":0.0001,
                "marginCoin":"USDT",
                "volume":10,
                "expireTime":1707188132000,
                "contractId":127,
                "triggerType":1,
                "open":"CLOSE",
                "status":0
            }
        ]
    }
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response" %}

<table><thead><tr><th width="161">名称</th><th width="109">类型</th><th width="205">例子</th><th>描述</th></tr></thead><tbody><tr><td>id</td><td>long</td><td>782</td><td>条件单归集表id</td></tr><tr><td>triggerOrderId</td><td>long</td><td>1322738336974712828</td><td>条件单id</td></tr><tr><td>contractId</td><td>long</td><td>127</td><td>合约id</td></tr><tr><td>contractName</td><td>string</td><td>BTCUSDT</td><td>合约名</td></tr><tr><td>marginCoin</td><td>string</td><td>USDT</td><td>保证金币种</td></tr><tr><td>multiplier</td><td>float</td><td>0.0001</td><td>合约面值</td></tr><tr><td>triggerPrice</td><td>float</td><td>10000</td><td>触发价格</td></tr><tr><td>price</td><td>float</td><td>0</td><td>下单价格</td></tr><tr><td>pricePrecision</td><td>integer</td><td>3</td><td>价格精度</td></tr><tr><td>volume</td><td>float</td><td>100</td><td>下单数量</td></tr><tr><td>open</td><td>string</td><td>OPEN</td><td>开平仓方向(open 开仓，close 平仓)</td></tr><tr><td>side</td><td>string</td><td>BUY</td><td>买卖方向（buy 买入，sell 卖出）</td></tr><tr><td>status</td><td>integer</td><td>0</td><td>有效状态 0有效</td></tr><tr><td>expireTime</td><td>long</td><td>1707722808000</td><td>订单过期时间</td></tr><tr><td>ctime</td><td>long</td><td>1705978532000</td><td>创建时间</td></tr><tr><td>mtime</td><td>long</td><td>1705978532000</td><td>修改时间</td></tr><tr><td>triggerType</td><td>integer</td><td>1</td><td>条件单类型1 stop loss，2 take profit，3 stop loss limit，4 take profit limit</td></tr></tbody></table>
{% endtab %}
{% endtabs %}

***

## 取消条件单

<mark style="color:green;">`POST`</mark> `https://futuresopenapi.xxx.com/v1/inner/trigger_order_cancel`

#### Headers

| Name                                          | Type    | Description |
| --------------------------------------------- | ------- | ----------- |
| X-CH-TS<mark style="color:red;">\*</mark>     | integer | 时间戳         |
| X-CH-APIKEY<mark style="color:red;">\*</mark> | string  | 您的API-key   |
| X-CH-SIGN<mark style="color:red;">\*</mark>   | string  | 签名          |

#### Request Body

| Name                                           | Type   | Description         |
| ---------------------------------------------- | ------ | ------------------- |
| contractName<mark style="color:red;">\*</mark> | string | 大写合约名称 如 E-BTC-USDT |
| orderId<mark style="color:red;">\*</mark>      | long   | 1322738336974712828 |

{% tabs %}
{% tab title="200: OK 成功code为 0  ，code小于0为错误，msg为错误原因" %}

```json
{ 
    "code": "0", 
    "msg": "成功", 
    "data": null 
}
```

{% endtab %}
{% endtabs %}

***

## 账户

### 安全类型: USER\_DATA

账户下方的接口都需要签名和API-key验证

## &#x20;账户信息

<mark style="color:blue;">`GET`</mark> `https://futuresopenapi.xxx.com/fapi/v1/account`

**限速规则: 20次/2s**

#### Headers

| Name        | Type    | Description |
| ----------- | ------- | ----------- |
| X-CH-SIGN   | string  | 签名          |
| X-CH-APIKEY | string  | 您的API-key   |
| X-CH-TS     | integer | 时间戳         |

{% tabs %}
{% tab title="200  获取账户信息成功" %}

```json
{
    "account": [
        {
            "marginCoin": "USDT",
            "accountNormal": 999.5606,
            "accountLock": 23799.5017,
            "partPositionNormal": 9110.7294,
            "totalPositionNormal": 0,
            "achievedAmount": 4156.5072,
            "unrealizedAmount": 650.6385,
            "totalMarginRate": 0,
            "totalEquity": 99964804.560,
            "partEquity": 13917.8753,
            "totalCost": 0,
            "sumMarginRate": 873.4608,
            "positionVos": [
                {
                    "contractId": 1,
                    "contractName": "E-BTC-USDT",
                    "contractOtherName": "BTC-USDT",
                    "contractSymbol": "BTC-USDT",
                    "positions": [
                        {
                            "id": 13603,
                            "uid": 10023,
                            "contractId": 1,
                            "positionType": 2,
                            "side": "BUY",
                            "volume": 69642.0,
                            "openPrice": 11840.2394,
                            "avgPrice": 11840.3095,
                            "closePrice": 12155.3005,
                            "leverageLevel": 24,
                            "openAmount": 0.0600000000000000,
                            "holdAmount": 7014.2111,
                            "closeVolume": 40502.0,
                            "pendingCloseVolume": 0,
                            "realizedAmount": 8115.9125,
                            "historyRealizedAmount": 1865.3985,
                            "tradeFee": -432.0072,
                            "capitalFee": 2891.2281,
                            "closeProfit": 8117.6903,
                            "shareAmount": 0.1112,
                            "freezeLock": 0,
                            "status": 1,
                            "ctime": "2020-12-11T17:42:10",
                            "mtime": "2020-12-18T20:35:43",
                            "brokerId": 21,
                            "lockTime": "2023-12-05T13:53:04",
                            "marginRate": 0.2097,
                            "reducePrice": 9740.8083,
                            "returnRate": 0.3086,
                            "unRealizedAmount": 2164.5289,
                            "openRealizedAmount": 2165.0173,
                            "positionBalance": 82458.2839,
                            "settleProfit": 0.4883,
                            "totalMargin": 0.8351780179968750,
                            "indexPrice": 12151.1175,
                            "keepRate": 0.005,
                            "maxFeeRate": 0.0025
                        }
                    ]
                }
            ]
        }
    ]
}
```

{% endtab %}
{% endtabs %}

{% tabs %}
{% tab title="Response:" %}

| 名称           | 类型   | 描述   |
| ------------ | ---- | ---- |
| `account`    | `[]` | 余额集合 |
| {% endtab %} |      |      |

{% tab title="Account field:" %}

<table><thead><tr><th>名称</th><th width="134">类型</th><th>例子</th><th>描述</th></tr></thead><tbody><tr><td>marginCoin</td><td>string</td><td>USDT</td><td>保证金币种</td></tr><tr><td>accountNormal</td><td>float</td><td>10.05</td><td>余额帐户</td></tr><tr><td>accountLock</td><td>float</td><td>10.07</td><td>保证金冻结帐户</td></tr><tr><td>partPositionNormal</td><td>float</td><td>10.07</td><td>逐仓保证金余额</td></tr><tr><td>totalPositionNormal</td><td>float</td><td>10.07</td><td>全仓占用的初始保证金</td></tr><tr><td>achievedAmount</td><td>float</td><td>10.07</td><td>已实现盈亏</td></tr><tr><td>unrealizedAmount</td><td>float</td><td>10.05</td><td>未实现盈亏</td></tr><tr><td>totalMarginRate</td><td>float</td><td>10.05</td><td>全仓保证金率</td></tr><tr><td>totalEquity</td><td>float</td><td>10.07</td><td>全仓权益</td></tr><tr><td>partEquity</td><td>float</td><td>10.07</td><td>逐仓权益</td></tr><tr><td>totalCost</td><td>float</td><td>10.07</td><td>全仓占用的成本</td></tr><tr><td>sumMarginRate</td><td>float</td><td>10.07</td><td>全账户的保证金率</td></tr><tr><td>positionVos</td><td>[ ]</td><td></td><td>仓位合约记录</td></tr></tbody></table>
{% endtab %}

{% tab title="PositionVos field:" %}

<table><thead><tr><th>名称</th><th width="114">类型</th><th width="186">例子</th><th>描述</th></tr></thead><tbody><tr><td>contractId</td><td>integer</td><td>2</td><td>合约id</td></tr><tr><td>contractName</td><td>string</td><td>E-BTC-USDT</td><td>大写合约名称</td></tr><tr><td>contractOtherName</td><td>string</td><td>BTC-USDT</td><td>币种别名</td></tr><tr><td>contractSymbol</td><td>string</td><td>BTC-USDT</td><td>合约币对</td></tr><tr><td>positions</td><td>[ ]</td><td></td><td>仓位明细</td></tr></tbody></table>
{% endtab %}

{% tab title="Positions field:" %}

<table><thead><tr><th>名称</th><th width="134">类型</th><th width="139">例子</th><th>描述</th></tr></thead><tbody><tr><td>id</td><td>integer</td><td>2</td><td>仓位id</td></tr><tr><td>uid</td><td>integer</td><td>10023</td><td>用户ID</td></tr><tr><td>contractId</td><td>integer</td><td>1</td><td>合约ID</td></tr><tr><td>positionType</td><td>integer</td><td>1</td><td>持仓类型(1: 全仓，2: 逐仓)</td></tr><tr><td>side</td><td>string</td><td>SELL</td><td>持仓方向( BUY: 多仓, SELL: 空仓</td></tr><tr><td>volume</td><td>float</td><td>1.05</td><td>持仓数量</td></tr><tr><td>openPrice</td><td>float</td><td>1.05</td><td>开仓价格</td></tr><tr><td>avgPrice</td><td>float</td><td>1.05</td><td>持仓均价</td></tr><tr><td>closePrice</td><td>float</td><td>1.05</td><td>平仓均价</td></tr><tr><td>leverageLevel</td><td>float</td><td>1.05</td><td>杠杆倍数</td></tr><tr><td>openAmount</td><td>float</td><td>1.05</td><td>开仓保证金</td></tr><tr><td>holdAmount</td><td>float</td><td>1.05</td><td>持仓保证金</td></tr><tr><td>closeVolume</td><td>float</td><td>1.05</td><td>已平仓数量</td></tr><tr><td>pendingCloseVolume</td><td>float</td><td>1.05</td><td>已挂出平仓单的数量</td></tr><tr><td>realizedAmount</td><td>float</td><td>1.05</td><td>已实现盈亏</td></tr><tr><td>historyRealizedAmount</td><td>float</td><td>1.05</td><td>历史累计已实现盈亏</td></tr><tr><td>tradeFee</td><td>float</td><td>1.05</td><td>交易手续费</td></tr><tr><td>capitalFee</td><td>float</td><td>1.05</td><td>资金费用</td></tr><tr><td>closeProfit</td><td>float</td><td>1.05</td><td>平仓盈亏</td></tr><tr><td>shareAmount</td><td>float</td><td>1.05</td><td>分摊金额</td></tr><tr><td>freezeLock</td><td>integer</td><td>0</td><td>持仓冻结状态 (0: 正常，1: 爆仓冻结，2: 交割冻结)</td></tr><tr><td>status</td><td>integer</td><td>0</td><td>仓位有效性(0: 无效 ，1：有效)</td></tr><tr><td>ctime</td><td>time</td><td>2023-12-05T13:53:04</td><td>创建时间</td></tr><tr><td>mtime</td><td>time</td><td>2023-12-05T13:53:04</td><td>更新时间</td></tr><tr><td>brokerId</td><td>integer</td><td>1023</td><td>商户id</td></tr><tr><td>lockTime</td><td>time</td><td></td><td>爆仓锁仓时间</td></tr><tr><td>marginRate</td><td>float</td><td>1.05</td><td>保证金率</td></tr><tr><td>reducePrice</td><td>float</td><td>1.05</td><td>强减价格</td></tr><tr><td>returnRate</td><td>float</td><td>1.05</td><td>回报率(收益率)</td></tr><tr><td>unRealizedAmount</td><td>float</td><td>1.05</td><td>未实现盈亏</td></tr><tr><td>openRealizedAmount</td><td>float</td><td>1.05</td><td>开仓未实现盈亏</td></tr><tr><td>positionBalance</td><td>float</td><td>1.05</td><td>仓位价值</td></tr><tr><td>settleProfit</td><td>float</td><td>1.05</td><td>持仓结算</td></tr><tr><td>indexPrice</td><td>float</td><td>1.05</td><td>最新标记价格</td></tr><tr><td>keepRate</td><td>float</td><td>1.05</td><td>阶梯最低维持保证金率</td></tr><tr><td>maxFeeRate</td><td>float</td><td>1.05</td><td>平仓最大手续费率</td></tr></tbody></table>
{% endtab %}
{% endtabs %}
