# 市场行情快照

- 接口：stock_market
- 路径：`/api/v1/market/data/daec/market/snapshot`
- 方法：GET
- 描述：查询全市场或单个交易所的行情快照，返回市场状态、涨跌幅、成交量、成交额，以及按涨跌幅区间统计的涨跌分布（9 档）。
- 数据范围：最新实时快照
- 单次限量：单次返回一个快照对象，无分页
- 提示：
  - `scope` 可选，默认 `ChinaStock`（全市场）；可指定 `Xshg`（沪市）/ `Xshe`（深市）/ `Bjse`（北交所）。
  - 市场状态依据北京时间交易时段判断，非交易时段 `status` 为 `closed`。

## 输入参数

| 名称 | 类型 | 必选 | 描述 |
|------|------|------|------|
| scope | string | N | 市场范围：`ChinaStock`（默认）/ `Xshg` / `Xshe` / `Bjse` |


## 输出参数
成功响应外层固定为 `code`、`message`、`data`：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| code | integer | Y | HTTP 状态码；成功固定为 200 |
| message | string | Y | 成功固定为 `success`；失败时为中文错误信息 |
| data | object / null | Y | 成功时为业务数据对象；失败时为 `null`。其字段如下 |


data 对象：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|---------|------|
| status | string | Y | 市场状态（如 `closed` / 交易中） |
| change_rate | number | Y | 涨跌幅 |
| volume | integer | Y | 成交量，单位股 |
| turnover | string | Y | 成交额，单位元 |
| prev_turnover | string | N | 前成交额，单位元 |
| distribution | object | Y | 涨跌分布（9 档，见下） |

distribution 对象：

| 名称 | 类型 | 默认显示 | 描述 |
|------|------|------|------|
| up_limited | integer | Y | 涨停 |
| up_5pct_to_limited | integer | Y | 涨 5% ~ 涨停 |
| up_1pct_to_5pct | integer | Y | 涨 1% ~ 5% |
| up_0pct_to_1pct | integer | Y | 涨 0 ~ 1% |
| flat | integer | Y | 平盘 |
| down_0pct_to_1pct | integer | Y | 跌 0 ~ 1% |
| down_1pct_to_5pct | integer | Y | 跌 1% ~ 5% |
| down_5pct_to_limited | integer | Y | 跌 5% ~ 跌停 |
| down_limited | integer | Y | 跌停 |

## 接口示例

```bash
# 全市场快照
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/daec/market/snapshot"

# 沪市快照
curl -sS "https://market.ft.tech/gateway/api/v1/market/data/daec/market/snapshot?scope=Xshg"
```


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

```python
import ftshare as ft

market = ft.market_api()
df = market.stock_market()
print(df)
```

## 数据样例

全市场快照（`scope=ChinaStock`），节选：

| status | change_rate | volume | turnover | 涨停 | 跌停 |
|--------|-------------|--------|----------|------|------|
| closed | 0.0 | 144355319384 | 2896765166908.61 | 166 | 24 |

distribution 完整 9 档：

| up_limited | up_5pct_to_limited | up_1pct_to_5pct | up_0pct_to_1pct | flat |
|------------|--------------------|-----------------|-----------------|------|
| 166 | 341 | 2524 | 745 | 71 |

| down_0pct_to_1pct | down_1pct_to_5pct | down_5pct_to_limited | down_limited |
|-------------------|-------------------|----------------------|--------------|
| 426 | 937 | 297 | 24 |

## 注意事项

- `status` 依据北京时间交易时段判断，非交易时段为 `closed`。
- `distribution` 各档为快照时刻的股票数量统计，9 档合计覆盖全市场标的。
