> ## 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：行情数据。

## 获取服务器时间

`GET` `/v4/public/time`

```java Java theme={null}
public String getServerInfo(){


}
```

```python Python theme={null}
```

```json Response theme={null}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": {
    "serverTime": 1662435658062  //服务器时间
  }
}
```

## 获取客户端IP

`GET` `/v4/public/client`

```java Java theme={null}
public String getClient(){


}
```

```python Python theme={null}
```

```json Response theme={null}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": {
    "ip": 192.168.1.1  
  }
}
```

## 获取交易对信息

`GET` `/v4/public/symbol`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | false | | 交易对  eg:btc\_usdt | |
| symbols | string | false | | 交易对集合，优先级高于symbol。 eg: btc\_usdt,eth\_usdt | |
| version | string | false | | 版本号,当请求版本号与响应内容版本一致时，不返回清单，减少IO eg: 2e14d2cd5czcb2c2af2c1db65078d075 | |

### 限流规则

1.获取单个交易对：10/s/ip

2.获取多个交易对：10/s/ip

### 过滤器

过滤器，即Filter，定义了一系列交易规则。针对不同的领域或者实体有不同的过滤器，这里主要介绍针对symbol这个实体的过滤器。 对于symbol来说，有两种过滤器，一种是全局过滤器，一种是针对某个交易对定制的过滤器。

**价格过滤器 PRICE FILTER**

价格过滤器 用于检测订单中 price 参数的合法性。包含以下三个部分:

1.min 定义了订单中price允许的最小值

2.max 定义了订单中price允许的最大值

3.tickSize 定义了订单中price的步进间隔，即price必须等于minPrice+(tickSize的整数倍)

以上每一项均可为null，为null时代表这一项不再做限制

逻辑伪代码如下:

* price >= min
* price \<= max
* (price-minPrice) % tickSize == 0

**数量过滤器  QUANTITY FILTER**

其逻辑和**PRICE FILTER** 类似，不过针对的是订单数量。

其内部包含三个部分

1.min 允许的最小值

2.max 允许的最大值

3.tickSize  步进间隔，即quantity必须等于minQuantity+(tickSize的整数倍)

以上每一项均可为null，为null时代表这一项不再做限制

逻辑伪代码如下:

* quantity>= min
* quantity\<= max
* (quantity-minQuantity)% tickSize == 0

**金额过滤器 QUOTE\_QTY FILTER**

对于订单的金额做限制

其内部定义了min允许的最小值

当min为null时，订单不做限制

否则限制规则如下：

1.对于限价LIMIT类型的订单，需满足 price\*quantity>=min

2.对于市价MARKET类型并且是购买类型(orderSide=BUY)订单，需满足quoteQty>=min,(quoteQty,市价按金额下单时必填的金额)

**开盘保护过滤器 PROTECTION\_ONLINE FILTER**

对处于开盘之后指定的时间范围内，对于限价类型的订单的价格进行限制

该过滤器内部定义了最大价格倍数(maxPriceMultiple)，持续时间(durationSeconds)。

限制逻辑:当处于交易对开盘后durationSeconds时间范围内，订单类型为限价类（LIMIT）的订单

须满足订单价格price\<=openPrice\*maxPriceMultiple,才会通过（openPrice为开盘价）。

其他类型的订单或者不在开盘时间范围内的订单不做限制。

对于maxPriceMultiple,durationSeconds均可为null,为null时，不做开盘保护限制。

**限价保护过滤器 PROTECTION\_LIMIT FILTER**

对于订单类型(orderType)为LIMIT(限价) 类型的订单具有价格保护限制，包含以下四个部分

1.buyMaxDeviation: 买单最大偏离度，根据该值和最新成交价确定买单价格最小值

2.buyPriceLimitCoefficient: 买单限制系数，根据该值和最新成交价确定买单价格最大值

3.sellMaxDeviation: 卖单最大偏离度，根据该值和最新成交价确定卖单价格最大值

4.sellPriceLimitCoefficient: 卖单限制系数，根据该值和最新成交价确定卖单价格最小值

若没有最新成交价则不做限制，或者以上参数为null,则对应方向类型订单不做限制

为了通过限价保护，订单price必须满足以下条件(latestPrice为最新成交价)

买单: price >= latestPrice-latestPrice*buyMaxDeviation   &&  price \<= latestPrice+latestPrice*buyPriceLimitCoefficient

卖单: price \<= latestPrice+latestPrice*sellMaxDeviation   &&  price >= latestPrice-latestPrice*sellPriceLimitCoefficient

**市价保护过滤器 PROTECTION\_MARKET FILTER**

对于订单类型为MARKET的订单具有价格限制保护机制，其内部规定了maxDeviation最大偏差率。

对于市价类型订单，市场价格须满足以下条件，订单才会通过(sellBestPrice  卖一价格，buyBestPrice 买一价格，latestPrice 最新成交价,这些数据均通过历史成交数据获得)

买单: latestPrice + latestPrice\* maxDeviation >= sellBestPrice

卖单: latestPrice - latestPrice\* maxDeviation \<= buyBestPrice

对于以上情况maxDeviation，latestPrice，sellBestPrice ，buyBestPrice

均有可能为空或者没有最新成交价，买一价格，卖一价格，则不做限制

```json Response theme={null}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": {
    "time": 1662444177871,                          //时间
    "version": "7cd2cfab0dc979339f1de904bd90c9cb",  //内容版本
    "symbols": [                                    //交易对清单
      {
        "id": 614,                                  //ID
        "symbol": "btc_usdt",                       //交易对
        "state": "ONLINE",                          //交易对状态[ONLINE=上线的;OFFLINE=下线的,DELISTED=退市]
        "tradingEnabled": true,                     //启用交易
        "openapiEnabled": true,                     //启用OPENAPI
        "nextStateTime": null,                      //下一个状态时间
        "nextState": null,                          //下一个状态
        "depthMergePrecision": 5,                   //深度合并精度
        "baseCurrency": "btc",                      //标的资产
        "baseCurrencyPrecision": 5,                 //标的资产精度
        "baseCurrencyId": 2,                        //标的资产ID
        "quoteCurrency": "usdt",                    //报价资产
        "quoteCurrencyPrecision": 6,                //报价资产精度
        "quoteCurrencyId": 11,                      //报价资产ID
        "pricePrecision": 4,                        //交易价格精度
        "quantityPrecision": 6,                     //交易数量精度
        "takerFeeRate": 0.001,                      //吃单手续费率
        "makerFeeRate": 0.002,                      //挂单手续费率
        "orderTypes": [                             //订单类型[LIMIT=限价单;MARKET=市价单]
          "LIMIT",
          "MARKET"
        ],
        "timeInForces": [                           //有效方式[GTC=成交为止,一直有效; IOC=无法立即成交(吃单)的部分就撤销; FOK=无法全部立即成交就撤销; GTX=无法成为挂单方就撤销]
          "GTC",
          "FOK",
          "IOC",
          "GTX"
        ],
        "displayWeight": 1,                         //展示权重，越大越靠前
        "displayLevel": "FULL",                     //展示级别,[FULL=完全展示,SEARCH=搜索展示,DIRECT=直达展示,NONE=不展示]
        "plates": [],                               //所属板块  eg:22,23,24
        "filters": [                                //过滤器
          {
            "filter": "PROTECTION_LIMIT",
            "buyMaxDeviation": "0.8"
            "sellMaxDeviation": "0.8"
          },
          {
            "filter": "PROTECTION_MARKET",
            "maxDeviation": "0.1"
          },
          {
            "filter": "PROTECTION_ONLINE",
            "durationSeconds": "300",
            "maxPriceMultiple": "5"
          },
          {
            "filter": "PRICE",
            "min": null,
            "max": null,
            "tickSize": null
          },
          {
            "filter": "QUANTITY",
            "min": null,
            "max": null,
            "tickSize": null
          },
          {
            "filter": "QUOTE_QTY",
            "min": null
          },
       ]
      }
    ]
  }
}            
```

## 获取深度数据

`GET` `/v4/public/depth`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | true | | 交易对  eg:btc\_usdt | |
| limit | number | false | 100 | 数量，最小查询100条 | 1\~500 |

### 限流规则

10/s/ip

```java Java theme={null}
public String depth(){


}
```

```python Python theme={null}
```

```json Response theme={null}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": {
    "timestamp": 1662445330524,          //时间戳
    "lastUpdateId": 137333589606963580,  //最后更新记录
    "bids": [                            //买盘([?][0]=价位;[?][1]=挂单量)
      [
        "200.0000",                      //价位
        "0.996000"                       //挂单量
      ],
      [
        "100.0000",
        "0.001000"
      ],
      [
        "20.0000",
        "10.000000"
      ]
    ],
    "asks": []                          //卖盘([?][0]=价位;[?][1]=挂单量)
  }
}
```

## 获取k线数据

`GET` `/v4/public/kline`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | true | | 交易对  eg:btc\_usdt | |
| interval | string | true | | K线类型 ,1m;3m;5m;15m;30m;1h;2h;4h;6h;8h;12h;1d;3d;1w;1M eg:1m | \[1m;3m;5m;15m;30m;1h;2h;4h;6h;8h;12h;1d;3d;1w;1M] |
| startTime | number | false | | 起始时间戳 | |
| endTime | number | false | | 结束时间戳 | |
| limit | number | false | 100 | 限制数量 | 1\~1000 |

### 限流规则

10/s/ip

```json Response theme={null}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
      "t": 1662601014832,   //开盘时间(time)
      "o": "30000",         //开盘价(open)
      "c": "32000",         //收盘价(close)
      "h": "35000",         //最高价(high)
      "l": "25000",         //最低价(low)
      "q": "512",           //成交量(quantity)
      "v": "15360000"       //成交额(volume)
    }
  ]
}
```

## 查询近期成交列表

`GET` `/v4/public/trade/recent`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | true | | 交易对 | |
| limit | number | false | 200 | 数量 | 1，1000 |

### 限流规则

10/s/ip

```java Java theme={null}
public String tradeRecent(){


}
```

```python Python theme={null}
```

```json Response theme={null}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
      "i": 0,           //ID
      "t": 0,           //成交时间(time)
      "p": "string",    //成交价(price)
      "q": "string",    //成交量(quantity)
      "v": "string",    //成交额(volume)
      "b": true         //方向(buyerMaker)
    }
  ]
}
```

## 查询历史成交列表

`GET` `/v4/public/trade/history`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | true | | 交易对 | |
| limit | number | false | 200 | 数量 | 1，1000 |
| direction | string | true | | 查询方向 | PREV-上一页,NEXT-下一页 |
| fromId | number | false | | 起始ID，eg: 6216559590087220004 | |

### 限流规则

10/s/ip

```java Java theme={null}
public String tradeHistory(){


}
```

```python Python theme={null}
```

```json Response theme={null}
{
  "rc": 0,
  "mc": "string",
  "ma": [
    {}
  ],
  "result": [
    {
      "i": 0,           //ID
      "t": 0,           //成交时间(time)
      "p": "string",    //成交价(price)
      "q": "string",    //成交量(quantity)
      "v": "string",    //成交额(volume)
      "b": true         //方向(buyerMaker)
    }
  ]
}
```

## 完整ticker

`GET` `/v4/public/ticker`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | false | | 交易对  eg:btc\_usdt | |
| symbols | array | false | | 交易对集合，优先级高于symbol。 eg: btc\_usdt,eth\_usdt | |
| tags | string | false | | 标签集合,逗号分割，当前仅支持 spot | |

### 限流规则

1.单个交易对：10/s/ip

2.多个交易对：10/s/ip

```java Java theme={null}
public String price(){


}
```

```python Python theme={null}
```

```json Response theme={null}
{
    "rc": 0,
    "mc": "SUCCESS",
    "ma": [],
    "result": [
          {
            "s": "btc_usdt",        //交易对(symbol)
            "t": 1662444879425,     //更新时间(time)
            "cv": "0.00",           //价格变动(change value)
            "cr": "0.0000",         //价格变动百分比(change rate)
            "o": "200.00",          //最早一笔(open)
            "l": "200.00",          //最低(low)
            "h": "200.00",          //最高(high)
            "c": "200.00",          //最后一笔(close)
            "q": "0.002",           //成交量(quantity)
            "v": "0.40",            //成交额(volume)
            "ap": null,             //asks price(卖一价)
            "aq": null,             //asks qty(卖一量)
            "bp": null,             //bids price(买一价)
            "bq": null              //bids qty(买一量)
            }
        ]
}
```

## 获取最新价格ticker

`GET` `/v4/public/ticker/price`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | false | | 交易对  eg:btc\_usdt | |
| symbols | array | false | | 交易对集合，优先级高于symbol。 eg: btc\_usdt,eth\_usdt | |
| tags | string | false | | 标签集合,逗号分割，当前仅支持 spot | |

### 限流规则

1.单个交易对：10/s/ip

2.多个交易对：10/s/ip

```java Java theme={null}
public String price(){


}
```

```python Python theme={null}
```

```json Response theme={null}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": [
    {
      "s": "btc_usdt",     //交易对(symbol)
      "t": 1661856036925   //时间(time)
      "p": "9000.0000",    //价格(price)
      }
  ]
}
```

## 获取最优挂单ticker

`GET` `/v4/public/ticker/book`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | false | | 交易对  eg:btc\_usdt | |
| symbols | array | false | | 交易对集合，优先级高于symbol。 eg: btc\_usdt,eth\_usdt | |
| tags | string | false | | 标签集合,逗号分割，当前仅支持 spot | |

### 限流规则

1.单个交易对：10/s/ip

2.多个交易对：10/s/ip

```json Response theme={null}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": [
    {
      "s": "btc_usdt",      //交易对(symbol)
      "t": 1661856036925,   //最后更新时间(last updated time) 
      "ap": null,           //asks price(卖一价)
      "aq": null,           //asks qty(卖一量)
      "bp": null,           //bids price(买一价)
      "bq": null            //bids qty(买一量)
    }
  ]
}
```

## 获取24h统计ticker

`GET` `/v4/public/ticker/24h`

**Parameters**

| 参数 | 数据类型 | 是否必须 | 默认值 | 描述 | 取值范围 |
| - | - | - | - | - | - |
| symbol | string | false | | 交易对  eg:btc\_usdt | |
| symbols | array | false | | 交易对集合，优先级高于symbol。 eg: btc\_usdt,eth\_usdt | |
| tags | string | false | | 标签集合,逗号分割，当前仅支持 spot | |

### 限流规则

1.单个交易对：10/s/ip

2.多个交易对：10/s/ip

```json Response theme={null}
{
  "rc": 0,
  "mc": "SUCCESS",
  "ma": [],
  "result": [
    {
      "s": "btc_usdt",     //交易对(symbol)
      "t": 1661856036925,  //时间(time) 
      "cv": "0.0000",      //价格变动(change value)
      "cr": "0.00",        //价格变动百分比(change rate)
      "o": "9000.0000",    //最早一笔(open)
      "l": "9000.0000",    //最低(low)
      "h": "9000.0000",    //最高(high)
      "c": "9000.0000",    //最后一笔(close)
      "q": "0.0136",       //成交量(quantity)
      "v": "122.9940"      //成交额(volume)
    }
  ]
}
```


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