
Rqdata Python
Wire Ricequant RQData Python APIs correctly for Chinese equities, futures, options, and calendars without silent contract-code mistakes.
Install
npx skills add https://github.com/ricequant/ricequant-skills --skill rqdata-pythonWhat is this skill?
- CLI code_index_manager.py workflow for resolving instruments (e.g. 贵州茅台) by market and type
- Step guides for futures underlying symbols (IF, CU) and contract lists including dominant contracts
- Option chains for futures, ETF, and single-stock underlyings with underlying lookup patterns
- Documents common pitfalls such as unvalidated tickers and wrong trading-calendar API names
- Points to --help on bundled scripts before running production queries
Adoption & trust: 1 installs on skills.sh; 26 GitHub stars; 2/3 security scanners passed (skills.sh audits); trending (+100% hot-view momentum).
Recommended Skills
Journey fit
Build is where you integrate market data providers into agents, backtests, or ops scripts; RQData is an external data API integration, not a launch or grow tactic. Integrations fits because the skill centers on querying contracts, calendars, and prices through RQData with validated symbols and documented API traps.
Common Questions / FAQ
Is Rqdata Python safe to install?
skills.sh reports 2 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.
SKILL.md
READMESKILL.md - Rqdata Python
# 一般资产合约代码获取指南 分两步执行: 1. 查看命令行帮助获取使用方法:`python ~/.claude/skills/rqdata-python/scripts/code_index_manager.py --help` 2. 执行获取脚本获取资产代码 ```bash python ~/.claude/skills/rqdata-python/scripts/code_index_manager.py --query "贵州茅台" --market cn --type CS ``` # 期货contract获取指南 分三步执行: 1. 推断期货品种(underlying symbol),例如沪深300期货为'IF',铜期货为'CU'等 2. 使用获取到的期货品种(underlying symbol)调用期货API获取期货合约 - 可获取可交易合约列表 - 可获取主力合约 # 期权contract获取指南 分三步执行: 1. 推断期权类型 - 期货期权 - ETF期权 - 个股期权 - 其他类型期权 2. 获取期权标的(underlying) - 期货期权:underlyiny就是期货品种,例如铜期权的underlying是`CU` - ETF期权:使用命令行获取underlying,例如50ETF使用命令行`python ~/.claude/skills/rqdata-python/scripts/code_index_manager.py -q "50ETF" -m cn -t ETF`获取underlying - 个股期权:和ETF期权的underlying获取方法一致 - 其他类型期权:自行推断如何获取 3. 使用获取到的期权标的(underlying)调用期权API获取期权合约 # RQData API常见错误使用陷阱(以及正确使用方式) ## 1. 未验证合约代码是否符合 Ricequant 规范 ```python df = rqdatac.get_price('600000', start_date='20230101', end_date='20230110') ``` ## 2. 交易日历未使用RQData API 错误代码: ```python trading_dates = rqdatac.get_trading_calendar('SSE', start_date='2025-12-01', end_date='2025-12-31') ``` 正确方式:查阅合约查询相关API文档,发现应该使用`get_trading_dates`API #!/usr/bin/env python3 """ API 索引管理器 - 快速定位 API 在文档中的位置 """ from pathlib import Path from typing import Dict, List, Optional import re import logging # 配置日志(INFO级别) logging.basicConfig( level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s" ) logger = logging.getLogger("APIIndexManager") class APIIndexManager: """API 索引管理器""" def __init__(self, api_index_dir: Optional[str] = None): """ 初始化 API 索引管理器 Args: api_index_dir: api_index 目录路径 """ if api_index_dir is None: skill_root = Path(__file__).parent.parent self.api_index_dir = skill_root / "cache" / "api_index" else: self.api_index_dir = Path(api_index_dir) logger.info( f"API Index Manager initialized with directory: {self.api_index_dir}" ) # 内存缓存:{document_name: {api_name: line_info}} self.memory_cache: Dict[str, Dict[str, dict]] = {} def _parse_api_index_file(self, document_name: str) -> Dict[str, dict]: """解析 api_index 文件,构建 API 到行号的映射""" logger.info(f"Parsing API index for document: {document_name}") # 将文档名转换为索引文件名 index_file_name = f"{document_name.replace('.md', '')}_index.md" index_file_path = self.api_index_dir / index_file_name if not index_file_path.exists(): error_msg = f"API index file not found: {index_file_path}" logger.error(error_msg) raise FileNotFoundError( f"{error_msg}\nPlease run init_skill.py to generate API indices." ) # 读取索引文件 try: with open(index_file_path, "r", encoding="utf-8") as f: content = f.read() except Exception as e: error_msg = f"Error reading index file {index_file_path}: {e}" logger.error(error_msg) raise IOError(error_msg) # 解析表格中的 API 信息 api_mapping = {} table_pattern = re.compile(r"\|\s*`([^`]+)`\s*\|\s*([^\|]+)\|\s*(\d+)\s*\|") for line in content.splitlines(): match = table_pattern.match(line) if match: api_name = match.group(1).strip() description = match.group(2).strip() line_number = int(match.group(3).strip()) api_mapping[api_name] = { "line_number": line_number, "description": description, "document_name": document_name, } logger.info(f"Parsed {len(api_mapping)} APIs from {document_name}") return api_mapping def get_api_location(self, api_name: str, document_name: str) -> dict: """获取 API 在文档中的位置(单个 API)""" logger.info( f"Getting location for API '{a