> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reportify.cn/llms.txt
> Use this file to discover all available pages before exploring further.

# 批量日线行情

> 批量获取多只股票的日线行情数据

批量获取多只股票的 OHLCV（开高低收量）日线数据。

<CodeGroup>
  ```bash cURL theme={null}
  curl -X POST https://api.reportify.cn/v1/quant/quotes/ohlcv/batch \
    -H "Authorization: Bearer <token>" \
    -H "Content-Type: application/json" \
    -d '{
      "market": "cn",
      "symbols": ["000001", "000002", "600519"],
      "start_date": "2026-01-01",
      "end_date": "2026-01-10"
    }'
  ```

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

  response = requests.post(
      "https://api.reportify.cn/v1/quant/quotes/ohlcv/batch",
      headers={"Authorization": "Bearer <token>"},
      json={
          "market": "cn",
          "symbols": ["000001", "000002", "600519"],
          "start_date": "2026-01-01",
          "end_date": "2026-01-10"
      }
  )
  print(response.json())
  ```

  ```typescript TypeScript theme={null}
  const response = await fetch('https://api.reportify.cn/v1/quant/quotes/ohlcv/batch', {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer <token>',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      market: 'cn',
      symbols: ['000001', '000002', '600519'],
      start_date: '2026-01-01',
      end_date: '2026-01-10'
    })
  });
  const data = await response.json();
  ```
</CodeGroup>

## 请求参数

<ParamField body="market" type="string" default="cn">
  股票市场：`cn`（A股）, `hk`（港股）, `us`（美股）, `global`（其他全球市场）。获取指数行情（`stock_type=index`）时，除 A 股（`cn`）、港股（`hk`）、美股（`us`）外，其余指数统一通过 `global` 查询。
</ParamField>

<ParamField body="symbols" type="string[]" required>
  股票代码列表（至少 1 个）
</ParamField>

<ParamField body="start_date" type="string">
  开始日期，格式：`YYYY-MM-DD`（默认：1 个月前）
</ParamField>

<ParamField body="end_date" type="string">
  结束日期，格式：`YYYY-MM-DD`（默认：今天）
</ParamField>

## 响应参数

<ResponseField name="datas" type="array">
  OHLCV 数据列表，按日期（降序）和股票代码排序

  <Expandable title="数据字段">
    <ResponseField name="date" type="string">
      日期
    </ResponseField>

    <ResponseField name="symbol" type="string">
      股票代码
    </ResponseField>

    <ResponseField name="open" type="number">
      开盘价
    </ResponseField>

    <ResponseField name="high" type="number">
      最高价
    </ResponseField>

    <ResponseField name="low" type="number">
      最低价
    </ResponseField>

    <ResponseField name="close" type="number">
      收盘价
    </ResponseField>

    <ResponseField name="volume" type="integer">
      成交量
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="metadata" type="object">
  查询元数据
</ResponseField>

## 响应示例

```json theme={null}
{
  "datas": [
    {
      "date": "2026-01-10",
      "symbol": "000001",
      "open": 12.15,
      "high": 12.48,
      "low": 12.10,
      "close": 12.35,
      "volume": 98765432
    },
    {
      "date": "2026-01-10",
      "symbol": "000002",
      "open": 15.80,
      "high": 16.20,
      "low": 15.65,
      "close": 16.05,
      "volume": 76543210
    },
    {
      "date": "2026-01-10",
      "symbol": "600519",
      "open": 1680.00,
      "high": 1705.00,
      "low": 1675.00,
      "close": 1698.50,
      "volume": 3456789
    },
    {
      "date": "2026-01-09",
      "symbol": "000001",
      "open": 12.00,
      "high": 12.25,
      "low": 11.95,
      "close": 12.15,
      "volume": 87654321
    },
    {
      "date": "2026-01-09",
      "symbol": "000002",
      "open": 15.50,
      "high": 15.95,
      "low": 15.40,
      "close": 15.80,
      "volume": 65432109
    },
    {
      "date": "2026-01-09",
      "symbol": "600519",
      "open": 1665.00,
      "high": 1688.00,
      "low": 1660.00,
      "close": 1680.00,
      "volume": 2987654
    }
  ],
  "metadata": {
    "market": "cn",
    "symbols": ["000001", "000002", "600519"],
    "start_date": "2026-01-01",
    "end_date": "2026-01-10",
    "count": 6
  }
}
```

## 使用示例

### 计算涨跌幅

```python theme={null}
import requests
from collections import defaultdict

response = requests.post(
    "https://api.reportify.cn/v1/quant/quotes/ohlcv/batch",
    headers={"Authorization": "Bearer <token>"},
    json={
        "market": "cn",
        "symbols": ["000001", "000002", "600519"],
        "start_date": "2026-01-08",
        "end_date": "2026-01-10"
    }
)
data = response.json()

# 按股票分组
by_symbol = defaultdict(list)
for row in data["datas"]:
    by_symbol[row["symbol"]].append(row)

# 计算区间涨跌幅
for symbol, rows in by_symbol.items():
    rows.sort(key=lambda x: x["date"])
    if len(rows) >= 2:
        change = (rows[-1]["close"] - rows[0]["close"]) / rows[0]["close"] * 100
        print(f"{symbol}: {change:.2f}%")
```

### 批量获取港股数据

```python theme={null}
response = requests.post(
    "https://api.reportify.cn/v1/quant/quotes/ohlcv/batch",
    headers={"Authorization": "Bearer <token>"},
    json={
        "market": "hk",
        "symbols": ["00700", "09988", "09618"],
        "start_date": "2026-01-01"
    }
)
```

### 批量获取美股数据

```python theme={null}
response = requests.post(
    "https://api.reportify.cn/v1/quant/quotes/ohlcv/batch",
    headers={"Authorization": "Bearer <token>"},
    json={
        "market": "us",
        "symbols": ["AAPL", "MSFT", "GOOGL", "NVDA"],
        "start_date": "2026-01-01"
    }
)
```


## OpenAPI

````yaml POST /v1/quant/quotes/ohlcv/batch
openapi: 3.1.0
info:
  title: Reportify API
  version: 1.0.0
  description: API documentation for Reportify's document management and search services.
servers:
  - url: https://api.reportify.cn
    description: Production server
security:
  - BearerAuth: []
paths:
  /v1/quant/quotes/ohlcv/batch:
    post:
      tags:
        - openapi-quant
      summary: Get batch OHLCV data for multiple symbols
      description: >
        Get OHLCV (Open, High, Low, Close, Volume) daily data for multiple
        symbols.


        - **symbols**: List of stock code (required)

        - **market**: Stock market (cn, hk, us, global), default: cn. For index
        quotes (stock_type=index), indices other than A-share (cn), HK (hk) and
        US (us) are queried via global.

        - **start_date**: Start date (optional, default: 1 month ago)

        - **end_date**: End date (optional, default: today)


        Returns data sorted by date (descending), then by symbol.
      operationId: quote_ohlcv_batch
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/BatchOHLCVInput'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BatchOHLCVOutput'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    BatchOHLCVInput:
      type: object
      required:
        - symbols
      properties:
        market:
          $ref: '#/components/schemas/StockMarket'
          description: Stock market
          default: cn
        symbols:
          type: array
          title: Symbols
          description: >-
            List of stock codes, e.g., ["600519", "000001"] for CN market
            (required)
          minItems: 1
          items:
            type: string
        start_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Start Date
          description: 'Start date (default: 1 month ago)'
        end_date:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: End Date
          description: 'End date (default: today)'
      title: BatchOHLCVInput
      description: Batch OHLCV request input.
    BatchOHLCVOutput:
      type: object
      required:
        - datas
        - metadata
      properties:
        datas:
          type: array
          title: Datas
          description: OHLCV data list sorted by date desc, then symbol
          items:
            type: object
            additionalProperties: true
        metadata:
          type: object
          title: Metadata
          description: Query metadata
          additionalProperties: true
      title: BatchOHLCVOutput
      description: Batch OHLCV data response.
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    StockMarket:
      type: string
      enum:
        - cn
        - hk
        - us
        - global
      title: StockMarket
      description: Stock market identifier
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Enter your Bearer token

````