### Install TickFlow SDK Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Use pip to install the TickFlow Python SDK. ```bash pip install "tickflow[all]" --upgrade ``` -------------------------------- ### Install OpenClaw Source: https://docs.tickflow.org/zh-Hans/openclaw Commands to install the OpenClaw platform on different operating systems. ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` ```bash openclaw onboard ``` ```powershell powershell -ExecutionPolicy ByPass -c "irm https://openclaw.ai/install.ps1 | iex" ``` ```powershell openclaw onboard ``` ```bash npm i -g openclaw ``` -------------------------------- ### Install TickFlow Skill Source: https://docs.tickflow.org/zh-Hans/openclaw Methods to install the TickFlow Skill into the OpenClaw workspace. ```bash npx clawhub install tickflow ``` ```bash mkdir -p ~/.openclaw/workspace/skills/tickflow && \ curl -fsSL https://raw.githubusercontent.com/tickflow-org/tickflow-skills/refs/heads/main/tickflow/SKILL.md \ -o ~/.openclaw/workspace/skills/tickflow/SKILL.md && \ echo "✅ 安装成功!" ``` ```powershell powershell -Command "New-Item -ItemType Directory -Force -Path $HOME\.openclaw\workspace\skills\tickflow; curl.exe -fsSL https://raw.githubusercontent.com/tickflow-org/tickflow-skills/refs/heads/main/tickflow/SKILL.md -o $HOME\.openclaw\workspace\skills\tickflow\SKILL.md; Write-Host '✅ 安装完成'" ``` -------------------------------- ### 获取标的池列表 OpenAPI 定义 Source: https://docs.tickflow.org/zh-hans/api-reference/标的池/获取标的池列表 定义了 /v1/universes 接口的 GET 请求规范,包含认证要求及响应数据结构。 ```yaml openapi: 3.1.0 info: title: TickFlow 行情数据 API description: |- 高性能行情数据服务,支持 A股、ETF、美股、港股。 ## 认证方式 所有接口需要通过 `x-api-key` 请求头传递 API Key 进行认证。 ## 速率限制 根据 API Key 配置的权限,可能会有请求频率和配额限制。 ## 批量查询 部分接口同时支持 GET 和 POST 方法: - **GET**: 通过 URL 参数传递,适合少量数据 - **POST**: 通过 JSON Body 传递,适合大批量查询,不受 URL 长度限制 ## K线周期 支持的周期:1m, 5m, 10m, 15m, 30m, 60m, 4h, 1d, 1w, 1M, 1Q, 1Y - 日内周期(5m/15m/30m/60m/4h)从1m数据聚合 - 周线(1w)/月线(1M)/季线(1Q)/年线(1Y)从日线聚合 - intraday 接口当前为 Beta 版本 contact: name: TickFlow Team license: name: '' version: 1.0.0 servers: - url: https://api.tickflow.org security: - api_key: [] paths: /v1/universes: get: tags: - 标的池 summary: 获取标的池列表 operationId: list_universes responses: '200': description: 查询成功 content: application/json: schema: $ref: '#/components/schemas/UniverseListResponse' '401': description: 认证失败 content: application/json: schema: $ref: '#/components/schemas/ApiError' security: - api_key: [] components: schemas: UniverseListResponse: type: object required: - data properties: data: type: array items: $ref: '#/components/schemas/UniverseSummary' ApiError: type: object description: API 错误响应体 required: - code - message properties: code: type: string description: 错误代码 (如 "INVALID_PERIOD", "SYMBOL_NOT_FOUND") example: INVALID_PERIOD details: description: 详细信息 (可选,用于调试) message: type: string description: 错误消息 (人类可读) example: 'Invalid period: 2d' UniverseSummary: type: object description: 标的池摘要(用于列表展示) required: - id - name - region - category - symbol_count properties: category: type: string description: 分类 description: type: - string - 'null' description: 描述 id: type: string description: 唯一标识符 name: type: string description: 显示名称 region: type: string description: 地区代码 symbol_count: type: integer description: 标的数量 minimum: 0 securitySchemes: api_key: type: apiKey in: header name: x-api-key ``` -------------------------------- ### Display Quote Output Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Example output format for multi-market quote queries. ```text symbol region last_price prev_close open ... ext.name ext.change_pct ext.change_amount ext.amplitude ext.turnover_rate 0 000001.SZ CN 10.79 10.76 10.77 ... 平安银行 0.002788 0.03 0.006506 0.003603 1 920662.BJ CN 28.62 27.53 28.26 ... 方盛股份 0.039593 1.09 0.052307 0.023130 2 au2604.SHF CN 1150.16 1140.00 1139.00 ... 沪金2604 0.008912 10.16 0.017316 NaN 3 600000.SH CN 9.98 9.85 9.83 ... 浦发银行 0.013198 0.13 0.019289 0.001633 [4 rows x 18 columns] ``` -------------------------------- ### GET /v1/klines/ex-factors Source: https://docs.tickflow.org/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E6%9F%A5%E8%AF%A2%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 - 逗号分隔的标的代码 - **start_time** (integer) - Optional - 开始时间(毫秒时间戳) - **end_time** (integer) - Optional - 结束时间(毫秒时间戳) ### Response #### Success Response (200) - **data** (object) - 包含标的代码及其对应的除权因子列表 #### Response Example { "data": { "AAPL": [ { "timestamp": 1672531200000, "ex_factor": 1.0 } ] } } ``` -------------------------------- ### GET /v1/quotes Source: https://docs.tickflow.org/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%9F%A5%E8%AF%A2%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85 Retrieves real-time market data for specified symbols or universe IDs. ```APIDOC ## GET /v1/quotes ### Description Retrieves real-time market data for one or more financial instruments. ### Method GET ### Endpoint /v1/quotes ### Parameters #### Query Parameters - **symbols** (string) - Optional - Comma-separated list of ticker symbols. - **universes** (string) - Optional - Comma-separated list of universe IDs. ### Response #### Success Response (200) - **data** (array) - List of quote objects. #### Response Example { "data": [ { "symbol": "AAPL", "region": "US", "last_price": 150.00, "prev_close": 148.50, "open": 149.00, "high": 151.00, "low": 148.00, "volume": 1000000, "amount": 150000000.0, "timestamp": 1672531200000 } ] } ``` -------------------------------- ### Get Real-time Quotes by Universe Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Retrieves real-time market data for all stocks within a specified universe, such as all A-shares. Returns data as a pandas DataFrame. ```python # 获取全部 A 股行情 quotes_df_a = tf.quotes.get(universes=["CN_Equity_A"], as_dataframe=True) print(quotes_df_a) ``` -------------------------------- ### Get Universe Details Source: https://docs.tickflow.org/zh-hans/api-reference/标的池/获取标的池详情 Retrieves detailed information about a specific universe, including its symbols. Authentication is required via an API key. ```APIDOC ## GET /v1/universes/{id} ### Description Retrieves detailed information about a specific universe, including its symbols. Authentication is required via an API key. ### Method GET ### Endpoint /v1/universes/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the universe to retrieve. ### Request Example (No request body for GET method) ### Response #### Success Response (200) - **data** (object) - Contains the universe details. - **id** (string) - Unique identifier of the universe. - **name** (string) - Display name of the universe. - **region** (string) - Region code of the universe. - **category** (string) - Category of the universe. - **description** (string | null) - Description of the universe. - **symbol_count** (integer) - Number of symbols in the universe. - **symbols** (array of strings) - List of symbols in the universe. #### Error Response (401) - **code** (string) - Error code (e.g., "UNAUTHENTICATED"). - **message** (string) - Error message. #### Error Response (404) - **code** (string) - Error code (e.g., "NOT_FOUND"). - **message** (string) - Error message. ``` -------------------------------- ### Get Real-time Quotes for Multiple Stocks Source: https://docs.tickflow.org/zh-Hans/sdk/python-examples Fetches real-time quote data for a list of specified stock symbols. The output is returned as a pandas DataFrame. ```python quotes_df = tf.quotes.get( symbols=["600000.SH", "000001.SZ", "600519.SH"], as_dataframe=True ) print(quotes_df) ``` -------------------------------- ### Batch Get Daily K-lines Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Retrieve daily K-line data for multiple symbols simultaneously. This is optimized for fetching data for a large number of instruments. ```APIDOC ## POST /api/klines/batch ### Description Retrieves daily K-line data for multiple stock symbols in a single request. ### Method POST ### Endpoint /api/klines/batch ### Parameters #### Request Body - **symbols** (array of strings) - Required - A list of stock symbols (e.g., ["600000.SH", "000001.SZ"]) - **period** (string) - Optional - The period for the K-lines. Defaults to "1d". - **count** (integer) - Optional - The number of data points to retrieve for each symbol. Defaults to 1000. - **as_dataframe** (boolean) - Optional - If true, returns data as a pandas DataFrame. Defaults to false. - **show_progress** (boolean) - Optional - If true, displays a progress bar during data fetching. Defaults to false. ### Request Example ```python from tickflow import TickFlow tf = TickFlow(api_key="your-api-key") symbols = ["600000.SH", "000001.SZ", "600519.SH"] dfs = tf.klines.batch(symbols, period="1d", count=10000, as_dataframe=True, show_progress=True) print(list(dfs.keys())) print(dfs["600000.SH"].tail()) ``` ### Response #### Success Response (200) - **data** (dict of DataFrames or JSON) - A dictionary where keys are symbols and values are their respective K-line data. #### Response Example ```json { "600000.SH": [ { "symbol": "600000.SH", "name": "浦发银行", "timestamp": 1772553600000, "trade_date": "2026-03-04", "trade_time": "2026-03-04 00:00:00", "open": 9.69, "high": 9.70, "low": 9.43, "close": 9.60, "volume": 1617556, "amount": 1.544304e+09 } ], "000001.SZ": [ { "symbol": "000001.SZ", "name": "平安银行", "timestamp": 1772553600000, "trade_date": "2026-03-04", "trade_time": "2026-03-04 00:00:00", "open": 10.10, "high": 10.20, "low": 10.00, "close": 10.15, "volume": 2000000, "amount": 2.03e+09 } ] } ``` ``` -------------------------------- ### Get All Shanghai and Shenzhen ETF Quotes Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Retrieves all Shanghai and Shenzhen ETF quotes and prints them as a pandas DataFrame. Ensure the 'tickflow' library is installed. ```python quotes_df_etf = tf.quotes.get(universes=["CN_ETF"], as_dataframe=True) print(quotes_df_etf) ``` -------------------------------- ### Manage Client Lifecycle with Context Managers Source: https://docs.tickflow.org/zh-Hans/sdk/python-best-practices Use the 'with' statement to ensure resources are properly released after use. ```python from tickflow import TickFlow with TickFlow(api_key="your-api-key") as tf: df = tf.klines.get("600000.SH", as_dataframe=True) # 使用完毕后自动关闭连接 ``` ```python from tickflow import AsyncTickFlow async with AsyncTickFlow(api_key="your-api-key") as tf: df = await tf.klines.get("600000.SH", as_dataframe=True) # 使用完毕后自动关闭连接 ``` -------------------------------- ### Configure Production Environment with Environment Variables Source: https://docs.tickflow.org/zh-Hans/sdk/python-best-practices Set up your production environment by defining API keys and base URLs in a `.env` file. The TickFlow client automatically reads these variables. ```bash # .env 文件 TICKFLOW_API_KEY=your-production-api-key TICKFLOW_BASE_URL=https://api.tickflow.org ``` ```python import os from dotenv import load_dotenv from tickflow import TickFlow load_dotenv() tf = TickFlow() # 自动读取环境变量 ``` -------------------------------- ### 查询除权因子 OpenAPI 定义 Source: https://docs.tickflow.org/zh-hans/api-reference/k线数据/查询除权因子 定义了 /v1/klines/ex-factors 接口的请求参数、响应模型及安全认证方式。 ```yaml openapi: 3.1.0 info: title: TickFlow 行情数据 API description: |- 高性能行情数据服务,支持 A股、ETF、美股、港股。 ## 认证方式 所有接口需要通过 `x-api-key` 请求头传递 API Key 进行认证。 ## 速率限制 根据 API Key 配置的权限,可能会有请求频率和配额限制。 ## 批量查询 部分接口同时支持 GET 和 POST 方法: - **GET**: 通过 URL 参数传递,适合少量数据 - **POST**: 通过 JSON Body 传递,适合大批量查询,不受 URL 长度限制 ## K线周期 支持的周期:1m, 5m, 10m, 15m, 30m, 60m, 4h, 1d, 1w, 1M, 1Q, 1Y - 日内周期(5m/15m/30m/60m/4h)从1m数据聚合 - 周线(1w)/月线(1M)/季线(1Q)/年线(1Y)从日线聚合 - intraday 接口当前为 Beta 版本 contact: name: TickFlow Team license: name: '' version: 1.0.0 servers: - url: https://api.tickflow.org security: - api_key: [] paths: /v1/klines/ex-factors: get: tags: - K线数据 summary: 查询除权因子 operationId: get_ex_factors parameters: - name: symbols in: query description: 逗号分隔的标的代码 required: true schema: type: string - name: start_time in: query description: 开始时间(毫秒时间戳) required: false schema: type: - integer - 'null' format: int64 - name: end_time in: query description: 结束时间(毫秒时间戳) required: false schema: type: - integer - 'null' format: int64 responses: '200': description: 查询成功 content: application/json: schema: $ref: '#/components/schemas/ExFactorsResponse' '400': description: 参数错误 content: application/json: schema: $ref: '#/components/schemas/ApiError' '401': description: 认证失败 content: application/json: schema: $ref: '#/components/schemas/ApiError' '403': description: 无权限 content: application/json: schema: $ref: '#/components/schemas/ApiError' security: - api_key: [] components: schemas: ExFactorsResponse: type: object required: - data properties: data: type: object additionalProperties: type: array items: $ref: '#/components/schemas/ExFactorEntry' propertyNames: type: string ApiError: type: object description: API 错误响应体 required: - code - message properties: code: type: string description: 错误代码 (如 "INVALID_PERIOD", "SYMBOL_NOT_FOUND") example: INVALID_PERIOD details: description: 详细信息 (可选,用于调试) message: type: string description: 错误消息 (人类可读) example: 'Invalid period: 2d' ExFactorEntry: type: object description: 单条复权因子 required: - timestamp - ex_factor properties: ex_factor: type: number format: double description: 除权因子 timestamp: type: integer format: int64 description: 除权日时间戳 (毫秒) securitySchemes: api_key: type: apiKey in: header name: x-api-key ``` -------------------------------- ### GET /v1/instruments Source: https://docs.tickflow.org/zh-hans/api-reference/标的/查询标的元数据 Retrieve instrument metadata by providing a comma-separated list of symbols. ```APIDOC ## GET /v1/instruments ### Description Retrieve instrument metadata, including name, exchange, and type, by specifying instrument codes. ### Method GET ### Endpoint /v1/instruments ### Parameters #### Query Parameters - **symbols** (string) - Required - Comma-separated instrument codes, e.g., "600000.SH,000001.SZ,AAPL.US" ### Request Example ```json { "example": "GET /v1/instruments?symbols=600000.SH,AAPL.US" } ``` ### Response #### Success Response (200) - **data** (array) - A list of instrument metadata objects. #### Response Example ```json { "data": [ { "code": "600000", "exchange": "SH", "region": "CN", "symbol": "600000.SH", "name": "ST浦发A", "type": "stock", "ext": { "type": "cn_equity" } }, { "code": "AAPL", "exchange": "US", "region": "US", "symbol": "AAPL.US", "name": "Apple Inc.", "type": "stock", "ext": { "type": "us_equity" } } ] } ``` #### Error Response (400, 401) - **code** (string) - Error code (e.g., "INVALID_PERIOD", "SYMBOL_NOT_FOUND") - **message** (string) - Human-readable error message - **details** (any) - Optional details for debugging ``` -------------------------------- ### Configure API Key Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Methods to authenticate the SDK using an API key. ```python from tickflow import TickFlow tf = TickFlow(api_key="your-api-key") ``` ```powershell $env:TICKFLOW_API_KEY="your-api-key" ``` ```cmd set TICKFLOW_API_KEY=your-api-key ``` ```bash export TICKFLOW_API_KEY="your-api-key" ``` ```python from tickflow import TickFlow # 自动读取 TICKFLOW_API_KEY 环境变量 tf = TickFlow() ``` -------------------------------- ### GET /v1/quotes Source: https://docs.tickflow.org/zh-hans/api-reference/实时行情/查询实时行情 Retrieve real-time market quotes for specified symbols or symbol pools. ```APIDOC ## GET /v1/quotes ### Description Query real-time market data for specific symbols or predefined symbol pools. ### Method GET ### Endpoint /v1/quotes ### Parameters #### Query Parameters - **symbols** (string) - Optional - Comma-separated list of ticker symbols. - **universes** (string) - Optional - Comma-separated list of symbol pool IDs. ### Response #### Success Response (200) - **data** (array) - List of quote objects containing price, volume, and market details. #### Response Example { "data": [ { "symbol": "AAPL", "region": "US", "last_price": 150.00, "prev_close": 148.50, "open": 149.00, "high": 151.00, "low": 148.00, "volume": 1000000, "amount": 150000000.0, "timestamp": 1672531200000 } ] } ``` -------------------------------- ### Asynchronous Data Retrieval with TickFlow Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Demonstrates how to use the asynchronous client for high-concurrency scenarios. Requires an API key and the 'asyncio' library. For large-scale K-line data, consider using the batch interface. ```python import asyncio from tickflow import AsyncTickFlow async def main(): async with AsyncTickFlow(api_key="your-api-key") as tf: # 异步获取数据 df = await tf.klines.get("600000.SH", as_dataframe=True) print(df.tail()) # 并发获取多只股票,仅演示,如需大量获取K线数据,请使用批量接口,tf.klines.batch tasks = [ tf.klines.get(s, as_dataframe=True) for s in ["600000.SH", "000001.SZ"] ] results = await asyncio.gather(*tasks) asyncio.run(main()) ``` -------------------------------- ### Get Real-time Quotes for an Entire Universe Source: https://docs.tickflow.org/zh-Hans/sdk/python-examples Fetches real-time quote data for all stocks within a specified universe, such as 'CN_Equity_A'. It includes calculations for percentage change and identifies top gainers and losers. ```python # 获取全部 A 股行情 df = tf.quotes.get(universes=["CN_Equity_A"], as_dataframe=True) # 计算涨跌幅 df["change_pct"] = (df["last_price"] - df["prev_close"]) / df["prev_close"] * 100 # 涨幅榜 top_gainers = df.nlargest(10, "change_pct')[["symbol", "last_price", "change_pct"]] print("涨幅榜 Top 10:") print(top_gainers) # 跌幅榜 top_losers = df.nsmallest(10, "change_pct')[["symbol", "last_price", "change_pct"]] print("\n跌幅榜 Top 10:") print(top_losers) ``` -------------------------------- ### GET /v1/exchanges Source: https://docs.tickflow.org/zh-hans/api-reference/%E4%BA%A4%E6%98%93%E6%89%80/%E8%8E%B7%E5%8F%96%E4%BA%A4%E6%98%93%E6%89%80%E5%88%97%E8%A1%A8 Retrieves a list of all configured exchanges along with the count of symbols available for each. ```APIDOC ## GET /v1/exchanges ### Description Returns all configured exchanges and their symbol counts. ### Method GET ### Endpoint /v1/exchanges ### Response #### Success Response (200) - **data** (array) - List of exchange information objects #### Response Example { "data": [ { "exchange": "SSE", "region": "China", "count": 1500 } ] } ``` -------------------------------- ### Configure Logging for httpx Requests Source: https://docs.tickflow.org/zh-Hans/sdk/python-best-practices Configure logging to view request details from the `httpx` library. Set the root logger to INFO and `httpx` logger to DEBUG. ```python import logging # 配置 httpx 日志查看请求详情 logging.basicConfig(level=logging.INFO) logging.getLogger("httpx").setLevel(logging.DEBUG) ``` -------------------------------- ### List Universes API Source: https://docs.tickflow.org/zh-hans/api-reference/标的池/获取标的池列表 Retrieves a list of available universes. This endpoint supports GET requests. ```APIDOC ## GET /v1/universes ### Description Fetches a list of available universes. ### Method GET ### Endpoint /v1/universes ### Parameters #### Query Parameters None explicitly defined in the OpenAPI spec for this GET request. ### Request Example No request body for GET method. ### Response #### Success Response (200) - **data** (array) - An array of UniverseSummary objects. - **UniverseSummary** (object) - **id** (string) - Unique identifier. - **name** (string) - Display name. - **region** (string) - Region code. - **category** (string) - Category. - **symbol_count** (integer) - Number of symbols. - **description** (string, null) - Description (optional). #### Response Example ```json { "data": [ { "id": "us_stocks", "name": "US Stocks", "region": "US", "category": "Stocks", "symbol_count": 10000, "description": "All listed US stocks" } ] } ``` #### Error Response (401) - **ApiError** (object) - **code** (string) - Error code (e.g., "INVALID_API_KEY"). - **message** (string) - Human-readable error message. - **details** (any) - Optional details for debugging. ``` -------------------------------- ### GET /metadata Source: https://docs.tickflow.org/zh-hans/api-reference/标的/查询标的元数据 Retrieves metadata for a specific financial instrument, including name, exchange, and type. ```APIDOC ## GET /metadata ### Description Retrieves metadata for a specific financial instrument, including name, exchange, and type. ### Method GET ### Endpoint /metadata ### Parameters #### Query Parameters - **code** (string) - Required - The code of the financial instrument to query. ``` -------------------------------- ### OpenAPI 现金流量表查询定义 Source: https://docs.tickflow.org/zh-hans/api-reference/财务数据/查询现金流量表 定义了 /v1/financials/cash-flow 接口的请求参数、认证方式及返回的现金流量表数据结构。 ```yaml openapi: 3.1.0 info: title: TickFlow 行情数据 API description: |- 高性能行情数据服务,支持 A股、ETF、美股、港股。 ## 认证方式 所有接口需要通过 `x-api-key` 请求头传递 API Key 进行认证。 ## 速率限制 根据 API Key 配置的权限,可能会有请求频率和配额限制。 ## 批量查询 部分接口同时支持 GET 和 POST 方法: - **GET**: 通过 URL 参数传递,适合少量数据 - **POST**: 通过 JSON Body 传递,适合大批量查询,不受 URL 长度限制 ## K线周期 支持的周期:1m, 5m, 10m, 15m, 30m, 60m, 4h, 1d, 1w, 1M, 1Q, 1Y - 日内周期(5m/15m/30m/60m/4h)从1m数据聚合 - 周线(1w)/月线(1M)/季线(1Q)/年线(1Y)从日线聚合 - intraday 接口当前为 Beta 版本 contact: name: TickFlow Team license: name: '' version: 1.0.0 servers: - url: https://api.tickflow.org security: - api_key: [] paths: /v1/financials/cash-flow: get: tags: - 财务数据 summary: 查询现金流量表 description: 获取指定标的的现金流量表数据,包含经营/投资/筹资三类净现金流。 operationId: get_cash_flow parameters: - name: symbols in: query description: 逗号分隔的标的代码,如 "600519.SH,000001.SZ" required: true schema: type: string - name: start_date in: query description: 起始日期过滤(可选,YYYY-MM-DD),筛选 period_end >= start_date required: false schema: type: - string - 'null' - name: end_date in: query description: 截止日期过滤(可选,YYYY-MM-DD),筛选 period_end <= end_date required: false schema: type: - string - 'null' - name: latest in: query description: 仅返回最新一期(默认 false) required: false schema: type: - boolean - 'null' responses: '200': description: 查询成功 content: application/json: schema: $ref: '#/components/schemas/CashFlowResponse' '400': description: 参数错误 content: application/json: schema: $ref: '#/components/schemas/ApiError' '401': description: 认证失败 content: application/json: schema: $ref: '#/components/schemas/ApiError' '403': description: 无权限 content: application/json: schema: $ref: '#/components/schemas/ApiError' security: - api_key: [] components: schemas: CashFlowResponse: type: object description: 现金流量表响应 required: - data properties: data: type: object additionalProperties: type: array items: $ref: '#/components/schemas/CashFlowRecord' propertyNames: type: string ApiError: type: object description: API 错误响应体 required: - code - message properties: code: type: string description: 错误代码 (如 "INVALID_PERIOD", "SYMBOL_NOT_FOUND") example: INVALID_PERIOD details: description: 详细信息 (可选,用于调试) message: type: string description: 错误消息 (人类可读) example: 'Invalid period: 2d' CashFlowRecord: type: object description: 现金流量表单期记录 required: - period_end properties: announce_date: type: - string - 'null' description: 公告日期 (YYYY-MM-DD) capex: type: - number - 'null' format: double description: 资本支出 (Capital Expenditure) net_cash_change: type: - number - 'null' format: double description: 现金及现金等价物净增加额 (Net Change in Cash) net_financing_cash_flow: type: - number - 'null' format: double description: 筹资活动现金流量净额 (Net Financing Cash Flow) net_investing_cash_flow: type: - number - 'null' format: double description: 投资活动现金流量净额 (Net Investing Cash Flow) net_operating_cash_flow: type: - number - 'null' format: double description: 经营活动现金流量净额 (Net Operating Cash Flow) period_end: type: string description: 报告期末日期 (YYYY-MM-DD) securitySchemes: api_key: type: apiKey in: header name: x-api-key ``` -------------------------------- ### POST /v1/quotes Source: https://docs.tickflow.org/zh-hans/api-reference/%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85/%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2%E5%AE%9E%E6%97%B6%E8%A1%8C%E6%83%85 This endpoint allows for batch querying of real-time market data. It supports fetching data for multiple symbols or universes simultaneously. Authentication is required via the 'x-api-key' header. ```APIDOC ## POST /v1/quotes ### Description This endpoint allows for batch querying of real-time market data. It supports fetching data for multiple symbols or universes simultaneously. Authentication is required via the 'x-api-key' header. ### Method POST ### Endpoint /v1/quotes ### Parameters #### Request Body - **symbols** (array[string] | null) - Optional - A list of symbols to query (e.g., ["600000.SH", "000001.SZ", "AAPL.US"]). - **universes** (array[string] | null) - Optional - A list of universes to query (e.g., ["CN_Equity_A", "CN_ETF"]). ### Request Example ```json { "symbols": [ "600000.SH", "000001.SZ", "AAPL.US" ], "universes": [ "CN_Equity_A", "CN_ETF" ] } ``` ### Response #### Success Response (200) - **data** (array[Quote]) - An array of quote objects containing real-time market data. #### Response Example ```json { "data": [ { "symbol": "600000.SH", "region": "SH", "last_price": 10.5, "prev_close": 10.2, "open": 10.3, "high": 10.6, "low": 10.1, "volume": 1000000, "amount": 10500000.0, "timestamp": 1678886400000 } ] } ``` #### Error Responses - **400**: Bad Request - Invalid parameters. - **401**: Unauthorized - Authentication failed. - **403**: Forbidden - Insufficient permissions. - **404**: Not Found - The specified symbol or universe does not exist. ``` -------------------------------- ### GET /v1/exchanges - List Exchanges Source: https://docs.tickflow.org/zh-hans/api-reference/交易所/获取交易所列表 Retrieves a list of all configured exchanges along with the number of symbols associated with each. ```APIDOC ## GET /v1/exchanges ### Description Returns a list of all configured exchanges and their symbol counts. ### Method GET ### Endpoint /v1/exchanges ### Parameters #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **data** (array) - A list of exchange information objects. - **exchange** (string) - The exchange code. - **region** (string) - The region the exchange belongs to. - **count** (integer) - The number of symbols on the exchange. #### Response Example ```json { "data": [ { "exchange": "XNYS", "region": "US", "count": 3000 }, { "exchange": "XNAS", "region": "US", "count": 2500 } ] } ``` #### Error Response (401) - **code** (string) - An error code. - **message** (string) - A human-readable error message. - **details** (any) - Optional details for debugging. #### Error Response Example ```json { "code": "UNAUTHENTICATED", "message": "API key is invalid or missing." } ``` ``` -------------------------------- ### Query Ex-Right Factors Source: https://docs.tickflow.org/zh-hans/api-reference/k线数据/查询除权因子 This endpoint allows you to query ex-right factors for specified symbols within a given time range. Authentication is required via an API key in the `x-api-key` header. ```APIDOC ## GET /v1/klines/ex-factors ### Description Queries ex-right factors for specified symbols. ### Method GET ### Endpoint /v1/klines/ex-factors ### Parameters #### Query Parameters - **symbols** (string) - Required - Comma-separated stock codes. - **start_time** (integer | null) - Optional - Start time (millisecond timestamp). - **end_time** (integer | null) - Optional - End time (millisecond timestamp). ### Request Example ```json { "example": "" } ``` ### Response #### Success Response (200) - **data** (object) - An object where keys are symbols and values are arrays of ExFactorEntry. #### Response Example ```json { "data": { "symbol1": [ { "timestamp": 1678886400000, "ex_factor": 1.0 } ] } } ``` #### Error Response - **400**: Bad Request (e.g., invalid parameters) - **401**: Unauthorized (e.g., invalid API key) - **403**: Forbidden (e.g., insufficient permissions) ``` -------------------------------- ### Filter Ex-Dividend Factors by Time Range Source: https://docs.tickflow.org/zh-Hans/sdk/python-examples Filters ex-dividend data by providing a start timestamp in milliseconds. ```python import datetime start = int(datetime.datetime(2020, 1, 1).timestamp() * 1000) df = tf.klines.ex_factors(["600519.SH"], start_time=start, as_dataframe=True) print(f"2020年以来共 {len(df)} 次除权") print(df) ``` -------------------------------- ### Intraday K-line Aggregation and Analysis Source: https://docs.tickflow.org/zh-Hans/sdk/python-examples Fetches and aggregates intraday K-line data, then calculates technical indicators like VWAP. It also demonstrates how to retrieve the most recent N minute K-lines. ```python # 获取 5 分钟聚合数据 df_5m = tf.klines.intraday("600000.SH", period="5m", as_dataframe=True) # 计算 VWAP(成交量加权平均价) df_5m["vwap"] = (df_5m["amount"] / df_5m["volume"]).round(2) # 获取最近 N 根分钟 K 线 df_recent = tf.klines.intraday("600000.SH", count=30, as_dataframe=True) print(f"最近 30 根: {df_recent.iloc[0]['trade_time']} ~ {df_recent.iloc[-1]['trade_time']}") ``` -------------------------------- ### Get Intraday K-lines Source: https://docs.tickflow.org/zh-Hans/sdk/python-quickstart Retrieve intraday (minute-level) K-line data for a specified symbol for the current trading day. ```APIDOC ## GET /api/klines/intraday ### Description Retrieves intraday (minute-level) K-line data for the current trading day for a given stock symbol. ### Method GET ### Endpoint /api/klines/intraday ### Parameters #### Query Parameters - **symbol** (string) - Required - The stock symbol (e.g., "600000.SH"). - **period** (string) - Optional - The period for the intraday K-lines (e.g., "1m", "5m", "15m", "30m", "60m"). Defaults to "1m". - **count** (integer) - Optional - The number of data points to retrieve. If not specified, retrieves all available data for the day. - **as_dataframe** (boolean) - Optional - If true, returns data as a pandas DataFrame. Defaults to false. ### Request Example ```python from tickflow import TickFlow tf = TickFlow(api_key="your-api-key") # Get 1-minute K-lines for the current day df = tf.klines.intraday("600000.SH", as_dataframe=True) print(f"Today has {len(df)} 1-minute K-lines") print(df.tail()) # Get the latest 5 1-minute K-lines df_last_5 = tf.klines.intraday("600000.SH", as_dataframe=True, count=5) print("Latest 5 1-minute K-lines:") print(df_last_5.tail()) # Get 5-minute K-lines for the current day df_5m = tf.klines.intraday("600000.SH", period="5m", as_dataframe=True) print(f"Today has {len(df_5m)} 5-minute K-lines") print(df_5m.tail()) ``` ### Response #### Success Response (200) - **data** (DataFrame or JSON) - Intraday K-line data including timestamp, open, high, low, close, volume, and amount for the current day. #### Response Example ```json { "symbol": "600000.SH", "name": "浦发银行", "timestamp": 1773123660000, "trade_date": "2026-03-10", "trade_time": "2026-03-10 14:21:00", "open": 9.97, "high": 9.97, "low": 9.96, "close": 9.97, "volume": 496, "amount": 494470.0 } ``` ``` -------------------------------- ### Get Financial Data Source: https://docs.tickflow.org/zh-hans/api-reference/k%E7%BA%BF%E6%95%B0%E6%8D%AE/%E6%89%B9%E9%87%8F%E6%9F%A5%E8%AF%A2-k%E7%BA%BF%E6%95%B0%E6%8D%AE Retrieves financial data including settlement price, timestamps, and volume for a given symbol. ```APIDOC ## GET /websites/tickflow/{symbol} ### Description Retrieves financial data for a specific symbol, including settlement price, timestamps, and volume. ### Method GET ### Endpoint /websites/tickflow/{symbol} ### Parameters #### Path Parameters - **symbol** (string) - Required - The trading symbol for which to retrieve data. #### Query Parameters - **start_time** (integer) - Optional - The start timestamp in milliseconds. - **end_time** (integer) - Optional - The end timestamp in milliseconds. ### Request Example (No request body for GET requests) ### Response #### Success Response (200) - **settlement_price** (double) - The settlement price. - **timestamp** (array of integer) - An array of timestamps in milliseconds. - **volume** (array of integer) - An array of trading volumes. #### Response Example ```json { "settlement_price": 150.75, "timestamp": [ 1678886400000, 1678886460000 ], "volume": [ 1000, 1500 ] } ``` ```