> For the complete documentation index, see [llms.txt](https://docs.bbx.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.bbx.com/zhs/bbx-dex-public-api/coingecko-ji-cheng/he-yue-yu-he-yue-gui-ge.md).

# 合约与合约规格

返回 BBX DEX 为 CoinGecko 衍生品交易所集成提供的当前有效加密货币永续合约市场。

该端点将 CoinGecko 对 `Contracts` 和 `Contract Specs` 的要求合并至同一个响应中。

已下架、已禁用、现货及非加密资产市场不会包含在返回数据中。

### 端点

```http
GET /fapi/market/v1/public/coingecko/contracts
```

### 完整 URL

```
https://dex.bbx.com/fapi/market/v1/public/coingecko/contracts
```

### 身份验证

无需身份验证。

该端点可公开访问，并且无需：

* API 密钥
* 请求签名
* 登录凭证
* 身份验证令牌
* 自定义请求头

### 查询参数

该端点无需提供查询参数。

### 市场范围

该端点返回 BBX 为 CoinGecko 集成提供的当前有效加密货币永续合约市场。

以下交易标的不会包含在返回数据中：

* 已下架或已禁用的合约
* 现货市场
* 代币化股票和股票合约
* ETF 和指数
* 商品
* 其他非加密资产交易标的

### 请求示例

```bash
curl -s \
  'https://dex.bbx.com/fapi/market/v1/public/coingecko/contracts'
```

### 响应示例

```json
[
  {
    "ticker_id": "BTC-USDT",
    "base_currency": "BTC",
    "target_currency": "USDT",
    "last_price": "67250.5",
    "base_volume": "1523.447",
    "target_volume": "102450321.88",
    "bid": "67249.8",
    "ask": "67251.2",
    "high": "68100.0",
    "low": "66300.0",
    "product_type": "Perpetual",
    "open_interest": "8452.331",
    "open_interest_usd": "568432100.55",
    "index_price": "67248.9",
    "index_name": "BTC-USDT",
    "index_currency": "USDT",
    "funding_rate": "0.0001",
    "next_funding_rate": "0.0001",
    "next_funding_rate_timestamp": 1721548800,
    "contract_type": "Vanilla",
    "contract_price": "0.0001",
    "contract_price_currency": "USDT"
  }
]
```

> 以上数值仅用于示例。实际响应将返回 BBX 当前的市场数据。

### 响应字段

#### 市场数据

| 字段                | 类型       | 要求 | 说明                                      |
| ----------------- | -------- | -- | --------------------------------------- |
| `ticker_id`       | `string` | 必填 | 合约标识符，采用 `BASE-TARGET` 格式，例如 `BTC-USDT` |
| `base_currency`   | `string` | 必填 | 基础资产符号                                  |
| `target_currency` | `string` | 必填 | 目标资产或计价资产符号                             |
| `last_price`      | `string` | 必填 | 最新成交价格                                  |
| `base_volume`     | `string` | 必填 | 以基础资产单位表示的滚动 24 小时交易量                   |
| `target_volume`   | `string` | 必填 | 以目标资产单位表示的滚动 24 小时交易量                   |
| `bid`             | `string` | 推荐 | 当前最高买价；买单侧为空时可能省略                       |
| `ask`             | `string` | 推荐 | 当前最低卖价；卖单侧为空时可能省略                       |
| `high`            | `string` | 推荐 | 滚动 24 小时内的最高成交价格                        |
| `low`             | `string` | 推荐 | 滚动 24 小时内的最低成交价格                        |

#### 产品信息

| 字段                | 类型        | 要求 | 说明                            |
| ----------------- | --------- | -- | ----------------------------- |
| `product_type`    | `string`  | 必填 | 产品类型：`Perpetual` 或 `Futures`  |
| `start_timestamp` | `integer` | 可选 | 产品开始时间，采用 Unix 秒级时间戳；数据不可用时省略 |
| `end_timestamp`   | `integer` | 可选 | 产品到期时间，采用 Unix 秒级时间戳；永续合约省略   |

#### 未平仓量与指数数据

| 字段                  | 类型       | 要求 | 说明                  |
| ------------------- | -------- | -- | ------------------- |
| `open_interest`     | `string` | 必填 | 以基础资产单位表示的双边未平仓量    |
| `open_interest_usd` | `string` | 必填 | 以美元表示的双边未平仓量        |
| `index_price`       | `string` | 必填 | 当前标的指数价格            |
| `index_name`        | `string` | 推荐 | 标的指数名称或标识符；数据不可用时省略 |
| `index_currency`    | `string` | 必填 | 标的指数的计价币种           |

#### 资金费率数据

| 字段                            | 类型        | 要求     | 说明                         |
| ----------------------------- | --------- | ------ | -------------------------- |
| `funding_rate`                | `string`  | 永续合约必填 | 当前资金费率                     |
| `next_funding_rate`           | `string`  | 永续合约必填 | 下一资金费率周期的费率值               |
| `next_funding_rate_timestamp` | `integer` | 永续合约必填 | 下一资金费率周期开始时间，采用 Unix 秒级时间戳 |

#### 合约规格

| 字段                        | 类型       | 要求 | 说明                               |
| ------------------------- | -------- | -- | -------------------------------- |
| `contract_type`           | `string` | 必填 | 线性合约为 `Vanilla`，币本位合约为 `Inverse` |
| `contract_price`          | `string` | 必填 | 单份合约代表的合约规模或价格                   |
| `contract_price_currency` | `string` | 必填 | 合约的计价币种                          |

### 交易对命名规则

合约标识符采用以下格式：

```
BASE-TARGET
```

示例：

```
BTC-USDT
ETH-USDT
SOL-USDT
```

### 数值格式

为避免浮点数精度损失，价格、交易量、未平仓量和资金费率均以字符串形式返回。

示例：

```json
{
  "last_price": "67250.5",
  "open_interest": "8452.331",
  "funding_rate": "0.0001"
}
```

时间戳以 JSON 整数形式返回。

### 时间戳单位

以下字段采用 Unix 秒级时间戳：

```
start_timestamp
end_timestamp
next_funding_rate_timestamp
```

永续合约可能不返回 `start_timestamp` 和 `end_timestamp`。

### 未平仓量计算方式

该端点按照 CoinGecko 的双边统计方式报告未平仓量。

双边未平仓量表示多头与空头未平仓仓位的合计值。

API 提供：

* `open_interest`：以基础资产单位表示
* `open_interest_usd`：以美元表示

### 资金费率格式

资金费率以小数形式返回，且未进行年化处理。

示例：

```
0.0001 = 0.01%
```

`next_funding_rate_timestamp` 字段表示下一资金费率周期的开始时间。

### 数据可用性

当对应的市场数据不可用时，`bid`、`ask`、`high`、`low` 和 `index_name` 等推荐字段可能被省略。

该端点返回的每个有效市场均包含所有必填字段。

成功响应以纯 JSON 格式返回，不包含外层封装结构。
