# 上金所现货品种

- 接口：sge_spot_description_all
- 路径：/api/v1/market/data/sge-spot-description-all
- 方法：GET
- 描述：查询上海黄金交易所（SGE）现货/延期品种主档全量列表，包括品种代码、中文简称、品种分类、上市/下架日期、合约乘数、保证金率、涨跌停板、最小变动价位、报价单位、交收规则与官网交易时间原文。共 19 只品种：竞价交易 17 只活跃品种（现货实盘 9、现货即期 1、现货延期交收 7）+ 2 只已下架品种（白银999、黄金50g）。支持按品种分类与活跃状态过滤，不传参数返回全部 19 只。
- 数据范围：品种主档快照，随官网更新，每天 17:30 更新；
- 单次限量：无分页，一次返回满足过滤条件的全部品种，最多 19 只。
- 提示：
  - 不传参数返回全部 19 只品种（含已下架）。
  - `category` 仅接受 `spot_full` / `spot_forward` / `spot_deferred` 三个取值，其他取值返回 400；空串视同未传。
  - `active_only=true` 仅返回活跃品种（`de_listed_date` 为 `null` 的 17 只）；`false` 与缺省返回全部；空串视同未传；传其他非布尔值返回 400。
  - `category` 与 `active_only` 可组合使用，返回结果仍按 `symbol` 升序。
  - `symbol` 含交易所后缀，如 `AG9999.SGEX`；`official_code` 为官网代码（slug），如 `Au(T+D)`、`Ag9999`，两者格式不同。
  - 活跃品种 `de_listed_date` 为 `null`；已下架品种返回最后交易日期。
  - `trading_hours` 为官网交易时间原文（含集合竞价段）；下架品种无官网原文，返回 `null`。
  - `contract_multiplier` 统一按克计（白银品种官网按千克，已折算为克，如 白银9999 为 15000）；`margin_rate` 为小数，现货实盘类全额交易为 1.0。
  - `limit_pct`、`min_move`、`quote_unit`、`settle_rule` 为官网独有字段，缺失时返回 `null`（下架品种均缺失）。
  - 交易所会在节假日前后动态调整保证金率与涨跌停板，返回值为最近一次更新的口径。
  - `category` 取值：`spot_full` 现货实盘 / `spot_forward` 现货即期 / `spot_deferred` 现货延期交收。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| category | string | N | 品种分类筛选：`spot_full` 现货实盘 / `spot_forward` 现货即期 / `spot_deferred` 现货延期交收；不传返回全部分类 |
| active_only | boolean | N | `true` 仅返回活跃品种（17 只）；不传、`false` 或空串返回全部（含 2 只已下架品种） |

## 输出参数

成功响应外层固定为 `code`、`message`、`data`：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| code | integer | Y | HTTP 状态码；成功固定为 `200` |
| message | string | Y | 成功固定为 `success`；失败时为中文错误信息 |
| data | array / null | Y | 成功时为品种列表；失败时为 `null` |

data 数组：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| symbol | string | Y | 品种代码，含交易所后缀，如 `AG9999.SGEX` |
| exchange | string | Y | 交易所代码 |
| type | string | Y | 品种类型 |
| symbol_cn_name | string | Y | 中文简称，如 白银9999 |
| listed_date | string | Y | 上市日期，格式 YYYY-MM-DD |
| de_listed_date | string / null | Y | 下架日期，格式 YYYY-MM-DD；活跃品种为 `null` |
| market_tplus | integer | Y | T+N 交易日限制 |
| trading_hours | string / null | Y | 官网交易时间原文，含集合竞价段；下架品种为 `null` |
| contract_multiplier | number | Y | 合约乘数，统一按克 |
| margin_rate | number | Y | 保证金率，小数 |
| round_lot | integer | Y | 每手最小交易单位 |
| category | string | Y | 品种分类：`spot_full` 现货实盘 / `spot_forward` 现货即期 / `spot_deferred` 现货延期交收 |
| official_code | string | Y | 官网代码（slug），如 `Au(T+D)` |
| limit_pct | number / null | Y | 涨跌停板百分比，如 30.0；下架品种为 `null` |
| min_move | number / null | Y | 最小变动价位；下架品种为 `null` |
| quote_unit | string / null | Y | 报价单位，如 元（人民币）/克；下架品种为 `null` |
| settle_rule | string / null | Y | 官网交收规则原文，如 `T+0`；NYAuTN06/12 为官网「交割结算日」原文；下架品种为 `null` |

## 接口示例

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/sge-spot-description-all"
```

带过滤参数：

```bash
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/sge-spot-description-all?category=spot_deferred&active_only=true"
```

Python（[`ftshare`](https://github.com/FTShare-Lab/FTShare-python-sdk.git) SDK，方法 `market.sge_spot_description_all`，默认返回 pandas `DataFrame`）：

```python
import ftshare as ft

market = ft.market_api()

# 默认返回 DataFrame（全部 19 只品种），19 行 × 17 列
df = market.sge_spot_description_all()
print(df.shape)
print(df[["symbol", "symbol_cn_name", "category", "contract_multiplier", "margin_rate"]].head())
#         symbol symbol_cn_name      category  contract_multiplier  margin_rate
# 0  AG999.SGEX         白银999  spot_forward              15000.0          0.2
# 1  AG9999.SGEX        白银9999  spot_forward              15000.0          0.2
# ...

# 仅返回活跃的延期交收品种
df = market.sge_spot_description_all(category="spot_deferred", active_only=True)

# 返回原始 JSON 信封（未经 DataFrame 抽取）
payload = market.sge_spot_description_all(raw=True)
```

## 数据样例

全量 19 只品种节选（覆盖现货实盘、现货延期与已下架形态）：

| symbol | exchange | type | symbol_cn_name | listed_date | de_listed_date | market_tplus | trading_hours | contract_multiplier | margin_rate | round_lot | category | official_code | limit_pct | min_move | quote_unit | settle_rule |
|--------|----------|------|----------------|-------------|----------------|--------------|---------------|---------------------|-------------|-----------|----------|---------------|-----------|----------|------------|-------------|
| AG999.SGEX | SGEX | Spot | 白银999 | 2006-10-30 | 2013-07-23 | 0 | null | 15000.0 | 0.2 | 1 | spot_forward | Ag999 | null | null | null | null |
| AG9999.SGEX | SGEX | Spot | 白银9999 | 2010-04-26 | null | 0 | 日间：9:00至15:30，夜间:19:50 至次日 02:30。 | 15000.0 | 0.2 | 1 | spot_forward | Ag9999 | 10.0 | 1.0 | 元（人民币）/千克 | T+2 |
| AU9999.SGEX | SGEX | Spot | 黄金9999 | 2002-10-30 | null | 0 | 日间：9:00至15:30，夜间:20:00 至次日 02:30。 | 10.0 | 1.0 | 1 | spot_full | Au9999 | 30.0 | 0.01 | 元（人民币）/克 | T+0 |
| AUTD.SGEX | SGEX | Spot | 黄金延期 | 2004-08-16 | null | 0 | 日间：9:00至15:30，夜间:19:50 至次日 02:30。 | 1000.0 | 0.15 | 1 | spot_deferred | Au(T+D) | 14.0 | 0.01 | 元（人民币）/克 | 交收申报配对成功的当日 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
