jqdatasdk
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesejqdatasdk 聚宽数据获取
jqdatasdk JoinQuant Data Acquisition
任务目标
Task Objectives
- 本 Skill 用于:通过聚宽数据接口获取A股市场数据、财务指标和因子数据
- 能力包含:实时行情、历史K线、财务数据、指标数据、股票信息、因子数据
- 触发条件:用户提及聚宽、jqdata、jqdatasdk或需要获取A股数据、财务信息、因子数据时
- This Skill is used to: Obtain A-share market data, financial indicators and factor data through the JoinQuant data interface
- Capabilities include: Real-time market quotes, historical K-lines, financial data, indicator data, stock information, factor data
- Trigger conditions: When users mention JoinQuant, jqdata, jqdatasdk or need to obtain A-share data, financial information, factor data
前置准备
Preparations
- 依赖说明:安装 jqdatasdk 库(已包含在 dependency 中)
- 凭证配置:需配置聚宽账号 Token(环境变量: JQDATA_TOKEN)或登录用户名及密码(环境变量: JQDATA_USERNAME、JQDATA_PASSWORD)
- 账号申请:访问 https://www.joinquant.com/ 注册账号并获取 API Token(详见 references/jqdatasdk_quickstart.md)
- Dependency description: Install the jqdatasdk library (included in dependency)
- Credential configuration: Configure JoinQuant account Token (environment variable: JQDATA_TOKEN) or login username and password (environment variables: JQDATA_USERNAME, JQDATA_PASSWORD)
- Account application: Visit https://www.joinquant.com/ to register an account and obtain API Token (see references/jqdatasdk_quickstart.md for details)
操作步骤
Operation Steps
- 标准流程:
- 确定数据需求 — 智能体理解用户意图(行情/K线/财务/因子等)
- 调用对应脚本 — 根据数据类型选择脚本
- 解析结果 — 智能体分析返回的 JSON 格式数据
- 脚本调用映射:
- 行情/K线/实时数据 →
python scripts/market_data.py --type price --code 000001.XSHE --start 2024-01-01 --end 2024-01-31 - 财务数据/指标/估值 →
python scripts/financial_data.py --type fundamentals --code 000001.XSHE --statDate 2024 - 股票列表/信息 →
python scripts/stock_info.py --type all_securities --security_type stock - 因子数据 →
python scripts/factor_data.py --code 000001.XSHE --factor valuation --start 2024-01-01 --end 2024-01-31
- 行情/K线/实时数据 →
- 可选分支:
- 当需要多只股票数据:使用 --code 参数逗号分隔
- 当需要指定频率:使用 --frequency 参数(1min/5min/15min/30min/60min/120min/daily/weekly/monthly)
- 当需要调整价格类型:使用 --fq_ref_date 参数或直接指定复权类型
- Standard process:
- Confirm data requirements — The agent understands the user's intent (market quotes/K-lines/financials/factors, etc.)
- Call the corresponding script — Select the script based on data type
- Parse results — The agent analyzes the returned JSON format data
- Script call mapping:
- Market quotes/K-lines/real-time data →
python scripts/market_data.py --type price --code 000001.XSHE --start 2024-01-01 --end 2024-01-31 - Financial data/indicators/valuation →
python scripts/financial_data.py --type fundamentals --code 000001.XSHE --statDate 2024 - Stock list/information →
python scripts/stock_info.py --type all_securities --security_type stock - Factor data →
python scripts/factor_data.py --code 000001.XSHE --factor valuation --start 2024-01-01 --end 2024-01-31
- Market quotes/K-lines/real-time data →
- Optional branches:
- When data for multiple stocks is needed: Use the --code parameter separated by commas
- When specifying frequency is needed: Use the --frequency parameter (1min/5min/15min/30min/60min/120min/daily/weekly/monthly)
- When adjusting price type is needed: Use the --fq_ref_date parameter or directly specify the right-adjustment type
使用示例
Usage Examples
- 示例1:获取股票日K线数据
- 场景/输入:用户说"查看平安银行最近一个月的K线数据"
- 预期产出:返回日期、开盘价、最高价、最低价、收盘价、成交量等OHLCV数据
- 关键要点:调用
python scripts/market_data.py --type price --code 000001.XSHE --start 2024-03-01 --end 2024-03-31 --frequency daily
- 示例2:查询财务指标
- 场景/输入:用户说"获取招商银行2023年的财务指标"
- 预期产出:返回PE、PB、ROE、营业收入、净利润等财务指标
- 关键要点:调用
python scripts/financial_data.py --type indicators --code 600036.XSHG --statDate 2023
- 示例3:获取因子数据
- 场景/输入:用户说"查询贵州茅台的估值因子"
- 预期产出:返回市盈率、市净率、市值等估值因子数据
- 关键要点:调用
python scripts/factor_data.py --code 600519.XSHG --factor valuation --start 2024-01-01 --end 2024-03-31
- Example 1: Obtain daily K-line data of stocks
- Scenario/Input: User says "Check the K-line data of Ping An Bank in the recent month"
- Expected output: Return OHLCV data such as date, opening price, highest price, lowest price, closing price, trading volume, etc.
- Key points: Call
python scripts/market_data.py --type price --code 000001.XSHE --start 2024-03-01 --end 2024-03-31 --frequency daily
- Example 2: Query financial indicators
- Scenario/Input: User says "Obtain the financial indicators of China Merchants Bank in 2023"
- Expected output: Return financial indicators such as PE, PB, ROE, operating income, net profit, etc.
- Key points: Call
python scripts/financial_data.py --type indicators --code 600036.XSHG --statDate 2023
- Example 3: Obtain factor data
- Scenario/Input: User says "Query the valuation factors of Kweichow Moutai"
- Expected output: Return valuation factor data such as price-earnings ratio, price-to-book ratio, market value, etc.
- Key points: Call
python scripts/factor_data.py --code 600519.XSHG --factor valuation --start 2024-01-01 --end 2024-03-31
资源索引
Resource Index
- 脚本:
- scripts/market_data.py (用途与参数:获取行情/K线/实时数据,支持 --type/--code/--start/--end/--frequency/--count)
- scripts/financial_data.py (用途与参数:获取财务/指标/估值数据,支持 --type/--code/--statDate/--columns)
- scripts/stock_info.py (用途与参数:获取股票列表/信息,支持 --type/--security_type/--code)
- scripts/factor_data.py (用途与参数:获取因子数据,支持 --code/--factor/--start/--end)
- 参考:
- references/jqdatasdk_quickstart.md (何时读取:首次配置或认证失败时)
- references/api.md (何时读取:需要使用聚宽 Python API、查看详细API参数说明时)
- Scripts:
- scripts/market_data.py (Purpose and parameters: Obtain market quotes/K-lines/real-time data, supports --type/--code/--start/--end/--frequency/--count)
- scripts/financial_data.py (Purpose and parameters: Obtain financial/indicator/valuation data, supports --type/--code/--statDate/--columns)
- scripts/stock_info.py (Purpose and parameters: Obtain stock list/information, supports --type/--security_type/--code)
- scripts/factor_data.py (Purpose and parameters: Obtain factor data, supports --code/--factor/--start/--end)
- References:
- references/jqdatasdk_quickstart.md (When to read: First configuration or authentication failure)
- references/api.md (When to read: Need to use JoinQuant Python API, view detailed API parameter descriptions)
注意事项
Notes
- 脚本执行需配置聚宽账号 Token 或登录用户名及密码,首次使用需先完成凭证配置
- 聚宽股票代码格式:上海市场为 XXXXXX.XSHG,深圳市场为 XXXXXX.XSHE
- 部分数据(如财务数据)可能有延迟,建议在交易日9:30-15:00之外获取
- 脚本返回 JSON 格式数据,智能体负责解析并转换为用户友好的展示
- 调用频率有限制,避免短时间内大量请求(详见聚宽官方文档)
- 首次使用建议先读取 jqdatasdk_quickstart.md 完成认证配置
- Script execution requires configuring JoinQuant account Token or login username and password, complete credential configuration first for initial use
- JoinQuant stock code format: Shanghai market is XXXXXX.XSHG, Shenzhen market is XXXXXX.XSHE
- Some data (such as financial data) may have delays, it is recommended to obtain it outside of 9:30-15:00 on trading days
- Scripts return data in JSON format, the agent is responsible for parsing and converting it into user-friendly display
- There are limits on call frequency, avoid a large number of requests in a short time (see JoinQuant official documentation for details)
- It is recommended to read jqdatasdk_quickstart.md first to complete authentication configuration for initial use