### GET /v1/klines/batch Source: https://docs.quantdash.net/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96k%E7%BA%BF%E6%95%B0%E6%8D%AE 批量获取多个标的的K线数据,响应以标的代码为 key。 ```APIDOC ## GET /v1/klines/batch ### Description 一次请求获取多个标的的K线数据,响应以标的代码为 key。 ### Method GET ### Endpoint /v1/klines/batch ### Parameters #### Query Parameters - **symbols** (string) - Required - 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) - **period** (string) - Optional - K线周期。分钟级(1m/5m/15m/30m/60m)需要分钟K线权限,日/周/月/季/年需要日K线权限。 - **count** (integer) - Optional - 最大返回条数(默认 100,最大 10000) - **start_time** (integer) - Optional - 起始时间戳(毫秒,含) - **end_time** (integer) - Optional - 结束时间戳(毫秒,含) - **adjust** (string) - Optional - 复权类型:`none`(不复权)、`forward`(前复权)、`backward`(后复权)、`forward_additive`(前复权-差值)、`backward_additive`(后复权-差值) ### Response #### Success Response (200) - **data** (object) - 以标的代码为 key 的K线数据字典,包含列式OHLCV数据(timestamp, open, high, low, close, volume, amount) ``` -------------------------------- ### 获取除权因子 OpenAPI 定义 Source: https://docs.quantdash.net/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E8%8E%B7%E5%8F%96%E9%99%A4%E6%9D%83%E5%9B%A0%E5%AD%90 定义了获取除权因子的 GET 请求路径、参数及响应结构。 ```yaml openapi: 3.1.0 info: contact: email: support@quantdash.net description: 提供中国A股、ETF、美股、港股的实时和历史行情数据接口 title: QuantDash version: 1.0.0 servers: - url: https://api.quantdash.net security: - ApiKeyHeader: [] - ApiKeyQuery: [] tags: - description: 历史K线(OHLCV)数据 name: K线数据 - description: 实时报价和市场深度 name: 实时行情 - description: 日内分钟级别数据 name: 日内分时 - description: 标的元数据 name: 基础信息 paths: /v1/klines/ex-factors: get: tags: - K线数据 summary: 获取除权因子 description: 获取标的的历史除权除息调整因子,可用于计算复权价格。 operationId: getExFactors parameters: - description: 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) example: 600000.SH,000001.SZ in: query name: symbols required: true schema: type: string - description: 起始时间戳(毫秒,含) in: query name: start_time schema: format: int64 type: integer - description: 结束时间戳(毫秒,含) in: query name: end_time schema: format: int64 type: integer responses: '200': content: application/json: schema: $ref: '#/components/schemas/ExFactorsResponse' description: 除权因子数据 '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' components: schemas: ExFactorsResponse: description: 以标的代码为 key 的除权因子历史字典 properties: data: additionalProperties: items: $ref: '#/components/schemas/ExFactorEntry' type: array type: object required: - data type: object ExFactorEntry: properties: ex_factor: description: 除权因子 type: number timestamp: description: 除权日时间戳(毫秒) format: int64 type: integer required: - timestamp - ex_factor type: object ErrorResponse: description: 错误响应 properties: code: description: HTTP 状态码 type: integer message: description: 错误描述 type: string required: - code - message type: object RateLimitResponse: description: 限流响应 properties: code: example: 429 type: integer message: description: 限流说明 type: string retry_after_ms: description: 建议等待时间(毫秒) type: integer required: - code - message - retry_after_ms type: object responses: Unauthorized: content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' description: API Key 无效或缺失 Forbidden: content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' description: 当前套餐无此功能/市场权限 RateLimited: content: application/json: schema: $ref: '#/components/schemas/RateLimitResponse' description: 请求频率超限 securitySchemes: ApiKeyHeader: description: 在请求头 X-API-Key 中传递 API Key in: header name: X-API-Key type: apiKey ApiKeyQuery: description: 在 URL 查询参数 api_key 中传递 API Key in: query name: api_key type: apiKey ``` -------------------------------- ### GET /v1/depth/batch Source: https://docs.quantdash.net/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%EF%BC%88%E4%BA%94%E6%A1%A3%E8%A1%8C%E6%83%85%EF%BC%89 批量获取多个标的的五档盘口数据,包括买入和卖出的价格及数量。 ```APIDOC ## GET /v1/depth/batch ### Description 一次请求获取多个标的盘口数据(5档买卖价格和数量)。 ### Method GET ### Endpoint /v1/depth/batch ### Parameters #### Query Parameters - **symbols** (string) - Required - 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) ### Response #### Success Response (200) - **data** (object) - 以标的代码为 key 的市场深度数据字典,包含 ask_prices, ask_volumes, bid_prices, bid_volumes, region, symbol, timestamp 等字段。 ``` -------------------------------- ### GET /v1/depth Source: https://docs.quantdash.net/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E8%8E%B7%E5%8F%96%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%EF%BC%88%E4%BA%94%E6%A1%A3%E8%A1%8C%E6%83%85%EF%BC%89 获取单个标的盘口数据(5档买卖价格和数量)。 ```APIDOC ## GET /v1/depth ### Description 获取单个标的盘口数据(5档买卖价格和数量)。 ### Method GET ### Endpoint /v1/depth ### Parameters #### Query Parameters - **symbol** (string) - Required - 标的代码(如 `600000.SH`、`AAPL.US`、`00700.HK`) ### Response #### Success Response (200) - **data** (object) - 市场深度数据 - **symbol** (string) - 标的代码 - **region** (string) - 市场地区 (CN, US, HK) - **timestamp** (integer) - 时间戳(毫秒) - **bid_prices** (array) - 买入价(买1到买5,降序) - **bid_volumes** (array) - 买入量 - **ask_prices** (array) - 卖出价(卖1到卖5,升序) - **ask_volumes** (array) - 卖出量 ``` -------------------------------- ### GET /v1/quotes Source: https://docs.quantdash.net/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E8%8E%B7%E5%8F%96%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85 获取最新实时报价。支持按标的代码查询或按标的池查询。两种方式二选一。 ```APIDOC ## GET /v1/quotes ### Description 获取最新实时报价。支持按标的代码查询或按标的池查询。两种方式二选一。 ### Method GET ### Endpoint /v1/quotes ### Parameters #### Query Parameters - **symbols** (string) - Optional - 标的代码,逗号分隔(如 600000.SH,000001.SZ,AAPL.US) - **universes** (string) - Optional - 标的池ID,逗号分隔。可选值:CN_Stock(A股)、US_Stock(美股)、HK_Stock(港股)、CN_ETF(ETF) ### Response #### Success Response (200) - **data** (array) - 行情数据列表 #### Response Example { "data": [ { "symbol": "600519.SH", "region": "CN", "last_price": 1800.0, "prev_close": 1790.0, "open": 1795.0, "high": 1810.0, "low": 1790.0, "volume": 10000, "amount": 18000000.0, "timestamp": 1672531200000 } ] } ``` -------------------------------- ### GET /v1/instruments Source: https://docs.quantdash.net/zh-hans/api-reference/%E5%9F%BA%E7%A1%80%E4%BF%A1%E6%81%AF/%E8%8E%B7%E5%8F%96%E6%A0%87%E7%9A%84%E5%85%83%E6%95%B0%E6%8D%AE 根据标的代码获取元数据(名称、交易所、类型、上市日期等)。支持逗号分隔传入多个标的。 ```APIDOC ## GET /v1/instruments ### Description 根据标的代码获取元数据(名称、交易所、类型、上市日期等)。支持逗号分隔传入多个标的。 ### Method GET ### Endpoint /v1/instruments ### Parameters #### Query Parameters - **symbols** (string) - Required - 标的代码,逗号分隔(如 600000.SH,000001.SZ,AAPL.US) ### Response #### Success Response (200) - **data** (array) - 标的数据列表 - **symbol** (string) - 标的代码 - **exchange** (string) - 交易所代码(SH/SZ/HK/US等) - **code** (string) - 标的纯数字/字母代码 - **name** (string) - 标的名称 - **region** (string) - 市场地区 (CN, US, HK) - **type** (string) - 标的类型 (stock, etf, index, bond, fund, futures, options, other) - **ext** (object) - 标的扩展信息(包含 listing_date, total_shares, float_shares, tick_size, limit_up, limit_down 等) ``` -------------------------------- ### GET /v1/klines/intraday/batch Source: https://docs.quantdash.net/zh-hans/api-reference/%E6%97%A5%E5%86%85%E5%88%86%E6%97%B6/%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E6%97%A5%E5%86%85%E5%88%86%E6%97%B6%E6%95%B0%E6%8D%AE 一次请求获取多个标的的日内分钟级K线数据。 ```APIDOC ## GET /v1/klines/intraday/batch ### Description 一次请求获取多个标的的日内分钟级K线数据。 ### Method GET ### Endpoint /v1/klines/intraday/batch ### Parameters #### Query Parameters - **symbols** (string) - Required - 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) - **period** (string) - Optional - 分时周期,可选值: 1m, 5m, 10m, 15m, 30m, 60m。默认: 1m - **count** (integer) - Optional - 最大返回条数,最大值: 10000。默认: 100 ### Response #### Success Response (200) - **data** (object) - 以标的代码为 key 的K线数据字典,包含 timestamp, open, high, low, close, volume, amount 等数组数据。 #### Response Example { "data": { "600000.SH": { "timestamp": [1672531200000], "open": [10.5], "high": [10.6], "low": [10.4], "close": [10.55], "volume": [10000], "amount": [105000.0] } } } ``` -------------------------------- ### 批量获取市场深度 OpenAPI 定义 Source: https://docs.quantdash.net/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96%E5%B8%82%E5%9C%BA%E6%B7%B1%E5%BA%A6%EF%BC%88%E4%BA%94%E6%A1%A3%E8%A1%8C%E6%83%85%EF%BC%89 定义了 /v1/depth/batch GET 请求的参数、响应结构以及相关的错误处理模式。 ```yaml openapi: 3.1.0 info: contact: email: support@quantdash.net description: 提供中国A股、ETF、美股、港股的实时和历史行情数据接口 title: QuantDash version: 1.0.0 servers: - url: https://api.quantdash.net security: - ApiKeyHeader: [] - ApiKeyQuery: [] tags: - description: 历史K线(OHLCV)数据 name: K线数据 - description: 实时报价和市场深度 name: 实时行情 - description: 日内分钟级别数据 name: 日内分时 - description: 标的元数据 name: 基础信息 paths: /v1/depth/batch: get: tags: - 实时行情 summary: 批量获取市场深度(五档行情) description: 一次请求获取多个标的盘口数据(5档买卖价格和数量)。 operationId: getDepthBatch parameters: - description: 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) example: 600000.SH,000001.SZ in: query name: symbols required: true schema: type: string responses: '200': content: application/json: schema: $ref: '#/components/schemas/DepthBatchResponse' description: 批量市场深度数据 '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' components: schemas: DepthBatchResponse: description: 以标的代码为 key 的市场深度数据字典 properties: data: additionalProperties: $ref: '#/components/schemas/MarketDepth' type: object required: - data type: object MarketDepth: description: 五档盘口数据 properties: ask_prices: description: 卖出价(卖1到卖5,升序) items: type: number type: array ask_volumes: description: 卖出量 items: type: integer type: array bid_prices: description: 买入价(买1到买5,降序) items: type: number type: array bid_volumes: description: 买入量 items: type: integer type: array region: description: 市场地区 enum: - CN - US - HK type: string symbol: description: 标的代码 type: string timestamp: description: 时间戳(毫秒) format: int64 type: integer required: - symbol - region - timestamp - bid_prices - bid_volumes - ask_prices - ask_volumes type: object ErrorResponse: description: 错误响应 properties: code: description: HTTP 状态码 type: integer message: description: 错误描述 type: string required: - code - message type: object RateLimitResponse: description: 限流响应 properties: code: example: 429 type: integer message: description: 限流说明 type: string retry_after_ms: description: 建议等待时间(毫秒) type: integer required: - code - message - retry_after_ms type: object responses: Unauthorized: content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' description: API Key 无效或缺失 Forbidden: content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' description: 当前套餐无此功能/市场权限 RateLimited: content: application/json: schema: $ref: '#/components/schemas/RateLimitResponse' description: 请求频率超限 securitySchemes: ApiKeyHeader: description: 在请求头 X-API-Key 中传递 API Key in: header name: X-API-Key type: apiKey ApiKeyQuery: description: 在 URL 查询参数 api_key 中传递 API Key in: query name: api_key type: apiKey ``` -------------------------------- ### GET /v1/klines/ex-factors Source: https://docs.quantdash.net/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E8%8E%B7%E5%8F%96%E9%99%A4%E6%9D%83%E5%9B%A0%E5%AD%90 获取标的的历史除权除息调整因子,可用于计算复权价格。 ```APIDOC ## GET /v1/klines/ex-factors ### Description 获取标的的历史除权除息调整因子,可用于计算复权价格。 ### Method GET ### Endpoint /v1/klines/ex-factors ### Parameters #### Query Parameters - **symbols** (string) - Required - 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) - **start_time** (integer) - Optional - 起始时间戳(毫秒,含) - **end_time** (integer) - Optional - 结束时间戳(毫秒,含) ### Response #### Success Response (200) - **data** (object) - 以标的代码为 key 的除权因子历史字典 #### Response Example { "data": { "600000.SH": [ { "timestamp": 1609459200000, "ex_factor": 1.05 } ] } } ``` -------------------------------- ### GET /v1/klines/intraday Source: https://docs.quantdash.net/zh-hans/api-reference/%E6%97%A5%E5%86%85%E5%88%86%E6%97%B6/%E8%8E%B7%E5%8F%96%E6%97%A5%E5%86%85%E5%88%86%E6%97%B6%E6%95%B0%E6%8D%AE 获取单个标的当日分钟级K线数据。支持 1m/5m/15m/30m/60m 周期。 ```APIDOC ## GET /v1/klines/intraday ### Description 获取单个标的当日分钟级K线数据。支持 1m/5m/15m/30m/60m 周期。 ### Method GET ### Endpoint /v1/klines/intraday ### Parameters #### Query Parameters - **symbol** (string) - Required - 标的代码(如 `600000.SH`、`AAPL.US`、`00700.HK`) - **period** (string) - Optional - 分时周期(可选值: 1m, 5m, 10m, 15m, 30m, 60m,默认: 1m) - **count** (integer) - Optional - 最大返回条数(最大: 10000,默认: 100) ### Response #### Success Response (200) - **data** (object) - 日内K线数据对象,包含 timestamp, open, high, low, close, volume, amount 等数组字段。 #### Response Example { "data": { "timestamp": [1672531200000], "open": [10.5], "high": [10.6], "low": [10.4], "close": [10.55], "volume": [10000], "amount": [105000] } } ``` -------------------------------- ### 设置环境变量 Source: https://docs.quantdash.net/zh-Hans/sdk/python-quickstart 通过 shell 环境变量配置 API Key。 ```bash export QUANTDASH_API_KEY="your-api-key" ``` -------------------------------- ### 获取K线数据 OpenAPI 定义 Source: https://docs.quantdash.net/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E8%8E%B7%E5%8F%96k%E7%BA%BF%E6%95%B0%E6%8D%AE 定义了获取K线数据的接口路径、参数及响应结构,包括支持的周期和复权类型。 ```yaml openapi: 3.1.0 info: contact: email: support@quantdash.net description: 提供中国A股、ETF、美股、港股的实时和历史行情数据接口 title: QuantDash version: 1.0.0 servers: - url: https://api.quantdash.net security: - ApiKeyHeader: [] - ApiKeyQuery: [] tags: - description: 历史K线(OHLCV)数据 name: K线数据 - description: 实时报价和市场深度 name: 实时行情 - description: 日内分钟级别数据 name: 日内分时 - description: 标的元数据 name: 基础信息 paths: /v1/klines: get: tags: - K线数据 summary: 获取K线数据 description: 获取单个标的的OHLCV K线数据。支持日线、周线、月线和分钟级别。数据以列式格式返回,传输效率高。 operationId: getKlines parameters: - description: 标的代码(如 `600000.SH`、`AAPL.US`、`00700.HK`) example: 600000.SH in: query name: symbol required: true schema: type: string - description: K线周期。分钟级(1m/5m/15m/30m/60m)需要分钟K线权限,日/周/月/季/年需要日K线权限。 in: query name: period schema: $ref: '#/components/schemas/Period' - description: 最大返回条数 in: query name: count schema: default: 100 maximum: 10000 type: integer - description: 起始时间戳(毫秒,含) in: query name: start_time schema: format: int64 type: integer - description: 结束时间戳(毫秒,含) in: query name: end_time schema: format: int64 type: integer - description: >- 复权类型:`none`(不复权)、`forward`(前复权)、`backward`(后复权)、`forward_additive`(前复权-差值)、`backward_additive`(后复权-差值) in: query name: adjust schema: $ref: '#/components/schemas/AdjustType' responses: '200': content: application/json: schema: $ref: '#/components/schemas/KlineResponse' description: K线数据 '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' components: schemas: Period: default: 1d description: K线周期 enum: - 1m - 5m - 15m - 30m - 60m - 1d - 1w - 1M - 1Q - 1Y type: string AdjustType: default: forward description: 复权类型 enum: - none - forward - backward - forward_additive - backward_additive type: string KlineResponse: properties: data: $ref: '#/components/schemas/CompactKlineData' required: - data type: object CompactKlineData: description: 列式OHLCV数据,传输效率高。每个数组长度相同,相同下标对应同一根K线。 properties: amount: description: 成交额 items: type: number type: array close: description: 收盘价 items: type: number type: array high: description: 最高价 items: type: number type: array low: description: 最低价 items: type: number type: array open: description: 开盘价 items: type: number type: array prev_close: description: 前收盘价(部分接口返回) items: type: number type: array timestamp: description: 时间戳(毫秒) items: format: int64 type: integer type: array volume: description: 成交量 items: format: int64 type: integer type: array required: - timestamp - open - high - low - close - volume - amount type: object ErrorResponse: description: 错误响应 properties: code: description: HTTP 状态码 type: integer message: description: 错误描述 type: string required: - code - message type: object RateLimitResponse: description: 限流响应 properties: code: example: 429 type: integer message: description: 限流说明 type: string retry_after_ms: description: 建议等待时间(毫秒) type: integer required: - code - message - retry_after_ms type: object responses: Unauthorized: content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' ``` -------------------------------- ### 批量获取K线数据 OpenAPI 定义 Source: https://docs.quantdash.net/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E6%89%B9%E9%87%8F%E8%8E%B7%E5%8F%96k%E7%BA%BF%E6%95%B0%E6%8D%AE 定义了 /v1/klines/batch 接口的请求参数、响应结构及相关数据模型。 ```yaml openapi: 3.1.0 info: contact: email: support@quantdash.net description: 提供中国A股、ETF、美股、港股的实时和历史行情数据接口 title: QuantDash version: 1.0.0 servers: - url: https://api.quantdash.net security: - ApiKeyHeader: [] - ApiKeyQuery: [] tags: - description: 历史K线(OHLCV)数据 name: K线数据 - description: 实时报价和市场深度 name: 实时行情 - description: 日内分钟级别数据 name: 日内分时 - description: 标的元数据 name: 基础信息 paths: /v1/klines/batch: get: tags: - K线数据 summary: 批量获取K线数据 description: 一次请求获取多个标的的K线数据,响应以标的代码为 key。 operationId: getKlinesBatch parameters: - description: 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) example: 600000.SH,000001.SZ in: query name: symbols required: true schema: type: string - description: K线周期。分钟级(1m/5m/15m/30m/60m)需要分钟K线权限,日/周/月/季/年需要日K线权限。 in: query name: period schema: $ref: '#/components/schemas/Period' - description: 最大返回条数 in: query name: count schema: default: 100 maximum: 10000 type: integer - description: 起始时间戳(毫秒,含) in: query name: start_time schema: format: int64 type: integer - description: 结束时间戳(毫秒,含) in: query name: end_time schema: format: int64 type: integer - description: >- 复权类型:`none`(不复权)、`forward`(前复权)、`backward`(后复权)、`forward_additive`(前复权-差值)、`backward_additive`(后复权-差值) in: query name: adjust schema: $ref: '#/components/schemas/AdjustType' responses: '200': content: application/json: schema: $ref: '#/components/schemas/KlineBatchResponse' description: 批量K线数据 '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' components: schemas: Period: default: 1d description: K线周期 enum: - 1m - 5m - 15m - 30m - 60m - 1d - 1w - 1M - 1Q - 1Y type: string AdjustType: default: forward description: 复权类型 enum: - none - forward - backward - forward_additive - backward_additive type: string KlineBatchResponse: description: 以标的代码为 key 的K线数据字典 properties: data: additionalProperties: $ref: '#/components/schemas/CompactKlineData' type: object required: - data type: object CompactKlineData: description: 列式OHLCV数据,传输效率高。每个数组长度相同,相同下标对应同一根K线。 properties: amount: description: 成交额 items: type: number type: array close: description: 收盘价 items: type: number type: array high: description: 最高价 items: type: number type: array low: description: 最低价 items: type: number type: array open: description: 开盘价 items: type: number type: array prev_close: description: 前收盘价(部分接口返回) items: type: number type: array timestamp: description: 时间戳(毫秒) items: format: int64 type: integer type: array volume: description: 成交量 items: format: int64 type: integer type: array required: - timestamp - open - high - low - close - volume - amount type: object ErrorResponse: description: 错误响应 properties: code: description: HTTP 状态码 type: integer message: description: 错误描述 type: string required: - code - message type: object RateLimitResponse: description: 限流响应 properties: code: example: 429 type: integer message: description: 限流说明 type: string retry_after_ms: description: 建议等待时间(毫秒) type: integer required: - code - message - retry_after_ms type: object responses: Unauthorized: content: ``` -------------------------------- ### 按时间区间批量获取K线数据 Source: https://docs.quantdash.net/zh-Hans/sdk/python-quickstart 通过 start_time 和 end_time 参数获取特定时间范围内的K线数据,时间戳需转换为毫秒级整数。 ```python import datetime from quantdash import QuantDash qd = QuantDash(api_key="your-api-key") start = int(datetime.datetime(2026, 5, 26).timestamp() * 1000) end = int(datetime.datetime(2026, 6, 1).timestamp() * 1000) dfs = qd.klines.batch(["600519.SH", "000858.SZ"], period="1d", start_time=start, end_time=end, to_dataframe=True) for sym, df in dfs.items(): print(f"--- {sym} ({df['name'].iloc[0]}) ---") print(df[["trade_date", "open", "close", "volume"]].to_string(index=False)) ``` -------------------------------- ### GET /v1/klines Source: https://docs.quantdash.net/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E8%8E%B7%E5%8F%96k%E7%BA%BF%E6%95%B0%E6%8D%AE 获取单个标的的OHLCV K线数据。支持日线、周线、月线和分钟级别。数据以列式格式返回,传输效率高。 ```APIDOC ## GET /v1/klines ### Description 获取单个标的的OHLCV K线数据。支持日线、周线、月线和分钟级别。数据以列式格式返回,传输效率高。 ### Method GET ### Endpoint /v1/klines ### Parameters #### Query Parameters - **symbol** (string) - Required - 标的代码(如 `600000.SH`、`AAPL.US`、`00700.HK`) - **period** (string) - Optional - K线周期。分钟级(1m/5m/15m/30m/60m)需要分钟K线权限,日/周/月/季/年需要日K线权限。枚举值: 1m, 5m, 15m, 30m, 60m, 1d, 1w, 1M, 1Q, 1Y - **count** (integer) - Optional - 最大返回条数,默认100,最大10000 - **start_time** (integer) - Optional - 起始时间戳(毫秒,含) - **end_time** (integer) - Optional - 结束时间戳(毫秒,含) - **adjust** (string) - Optional - 复权类型:`none`(不复权)、`forward`(前复权)、`backward`(后复权)、`forward_additive`(前复权-差值)、`backward_additive`(后复权-差值) ### Response #### Success Response (200) - **data** (object) - 包含列式OHLCV数据的对象,包含 timestamp, open, high, low, close, volume, amount 数组。 ``` -------------------------------- ### 使用 Python SDK 获取行情数据 Source: https://docs.quantdash.net/zh-Hans/quickstart 通过 QuantDash Python SDK 初始化客户端并获取日 K 线及实时行情数据。 ```python from quantdash import QuantDash qd = QuantDash(api_key="your-api-key") # 获取贵州茅台日K线 df = qd.klines.get("600519.SH", period="1d", count=10, to_dataframe=True) print(df[["trade_date", "close", "volume"]]) # 获取全部 A 股实时行情 df = qd.quotes.get(universes=["CN_Stock"], to_dataframe=True) print(f"共 {len(df)} 只标的") ``` -------------------------------- ### 获取实时行情 OpenAPI 定义 Source: https://docs.quantdash.net/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E8%8E%B7%E5%8F%96%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85 定义了获取实时行情数据的 OpenAPI 规范,包括请求参数、响应结构及错误处理机制。 ```yaml openapi: 3.1.0 info: contact: email: support@quantdash.net description: 提供中国A股、ETF、美股、港股的实时和历史行情数据接口 title: QuantDash version: 1.0.0 servers: - url: https://api.quantdash.net security: - ApiKeyHeader: [] - ApiKeyQuery: [] tags: - description: 历史K线(OHLCV)数据 name: K线数据 - description: 实时报价和市场深度 name: 实时行情 - description: 日内分钟级别数据 name: 日内分时 - description: 标的元数据 name: 基础信息 paths: /v1/quotes: get: tags: - 实时行情 summary: 获取实时行情 description: 获取最新实时报价。支持按标的代码查询或按标的池查询。两种方式二选一。 operationId: getQuotes parameters: - description: 标的代码,逗号分隔(如 `600000.SH,000001.SZ,AAPL.US`) example: 600000.SH,000001.SZ in: query name: symbols schema: type: string - description: >- 标的池ID,逗号分隔。可选值:`CN_Stock`(A股)、`US_Stock`(美股)、`HK_Stock`(港股)、`CN_ETF`(ETF) in: query name: universes schema: enum: - CN_Stock - US_Stock - HK_Stock - CN_ETF type: string responses: '200': content: application/json: schema: $ref: '#/components/schemas/QuotesResponse' description: 行情数据 '401': $ref: '#/components/responses/Unauthorized' '403': $ref: '#/components/responses/Forbidden' '429': $ref: '#/components/responses/RateLimited' components: schemas: QuotesResponse: properties: data: items: $ref: '#/components/schemas/Quote' type: array required: - data type: object Quote: description: 单个标的的实时行情快照 properties: amount: description: 成交额 type: number ext: $ref: '#/components/schemas/QuoteExt' high: description: 最高价 type: number last_price: description: 最新价 type: number low: description: 最低价 type: number open: description: 开盘价 type: number prev_close: description: 昨收价 type: number region: description: 市场地区 enum: - CN - US - HK type: string symbol: description: 标的代码 example: 600519.SH type: string timestamp: description: 行情时间戳(毫秒) format: int64 type: integer volume: description: 成交量 format: int64 type: integer required: - symbol - region - last_price - prev_close - open - high - low - volume - amount - timestamp type: object ErrorResponse: description: 错误响应 properties: code: description: HTTP 状态码 type: integer message: description: 错误描述 type: string required: - code - message type: object RateLimitResponse: description: 限流响应 properties: code: example: 429 type: integer message: description: 限流说明 type: string retry_after_ms: description: 建议等待时间(毫秒) type: integer required: - code - message - retry_after_ms type: object QuoteExt: description: 行情扩展字段(因市场而异) properties: amplitude: description: 振幅(小数) type: number change_amount: description: 涨跌额 type: number change_pct: description: 涨跌幅(小数,如 0.01 表示 1%) type: number name: description: 标的名称 type: string turnover_rate: description: 换手率(小数) type: number type: description: 标的具体类型(如 cn_equity) type: string type: object responses: Unauthorized: content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' description: API Key 无效或缺失 Forbidden: content: application/json: schema: $ref: '#/components/schemas/ErrorResponse' description: 当前套餐无此功能/市场权限 RateLimited: content: application/json: schema: $ref: '#/components/schemas/RateLimitResponse' description: 请求频率超限 securitySchemes: ApiKeyHeader: description: 在请求头 X-API-Key 中传递 API Key in: header name: X-API-Key type: apiKey ApiKeyQuery: description: 在 URL 查询参数 api_key 中传递 API Key in: query name: api_key type: apiKey ``` -------------------------------- ### API 认证请求示例 Source: https://docs.quantdash.net/zh-Hans/api-reference/introduction 通过 Header 或 URL 参数进行 API 认证的示例。 ```bash curl https://api.quantdash.net/v1/quotes \ -H "X-API-Key: your-api-key" \ -G -d "symbols=600519.SH" ``` ```text https://api.quantdash.net/v1/quotes?symbols=600519.SH&api_key=your-api-key ```