← Back to Skills Marketplace
idiosyncraticdragon

JoinQuant datasdk skill

by IdiosyncraticDragon · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ Security Clean
242
Downloads
0
Stars
1
Active Installs
1
Versions
Install in OpenClaw
/install jqdatasdk-skill
Description
JoinQuant (聚宽) 量化交易数据SDK开发技能。基于jqdatasdk官方库提供行情数据获取、财务数据查询、因子数据等API。用于开发量化交易策略、进行jqdatasdk二次开发、API问题排查。 适用于需要使用聚宽数据接口进行策略开发、回测验证、数据分析的场景。
README (SKILL.md)

\r \r

jqdatasdk 量化开发技能\r

\r 本技能基于 JoinQuant (聚宽) 官方 jqdatasdk SDK,帮助开发者使用 Python 进行量化交易策略开发和数据分析。\r \r

参考项目\r

\r

  • 官方 jqdatasdk: https://github.com/JoinQuant/jqdatasdk.git - 官方 Python SDK 源码\r
  • 类型定义: https://github.com/stairclimber/joinquant_api.git - 第三方 API 类型定义 (TypeScript 风格)\r \r

快速开始\r

\r

1. 安装 jqdatasdk\r

\r

pip install jqdatasdk\r
```\r
\r
### 2. 账号认证\r
\r
```python\r
import jqdatasdk as jq\r
\r
# 使用用户名密码认证\r
jq.auth('username', 'password')\r
\r
# 或使用 token 认证\r
jq.auth_by_token('your_token')\r
\r
# 检查认证状态\r
print(jq.is_auth())  # True/False\r
```\r
\r
### 3. 基础数据获取\r
\r
```python\r
import jqdatasdk as jq\r
from jqdatasdk import finance\r
\r
# 获取股票行情数据\r
df = jq.get_price('000001.XSHE', start_date='2024-01-01', end_date='2024-12-31')\r
\r
# 获取财务数据\r
from sqlalchemy import func\r
q = jq.query(\r
    finance.indicator.code,\r
    finance.indicator.pub_date,\r
    finance.indicator.eps\r
).filter(finance.indicator.code == '000001.XSHE')\r
df = jq.get_fundamentals(q, date='2024-12-31')\r
\r
# 获取指数成分股\r
stocks = jq.get_index_stocks('000300.XSHG')  # 沪深300\r
\r
# 获取交易日历\r
trade_days = jq.get_trade_days(start_date='2024-01-01', end_date='2024-12-31')\r
```\r
\r
## 核心API分类\r
\r
### 认证与配置\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `jq.auth(username, password, host=None, port=None)` | 账号密码认证 |\r
| `jq.auth_by_token(token, host=None, port=None)` | Token认证 |\r
| `jq.logout()` | 退出登录 |\r
| `jq.is_auth()` | 检查认证状态 |\r
| `jq.set_params(**params)` | 设置请求参数 |\r
\r
### 行情数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_price(security, ...)` | 获取行情数据(日/分钟) |\r
| `get_bars(security, count, unit, ...)` | 获取K线数据 |\r
| `get_ticks(security, ...)` | 获取Tick数据 |\r
| `get_current_tick(security)` | 获取实时Tick |\r
| `get_extras(info, security_list, ...)` | 获取额外数据(ST/净值等) |\r
\r
### 财务数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_fundamentals(query_object, ...)` | 查询财务数据 |\r
| `get_fundamentals_continuously(...)` | 连续查询财务数据 |\r
| `get_valuation(security_list, ...)` | 获取市值数据 |\r
| `get_history_fundamentals(...)` | 获取历史财报数据 |\r
\r
### 标的信息\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_all_securities(types, date)` | 获取所有证券信息 |\r
| `get_security_info(code, date)` | 获取证券详细信息 |\r
| `get_index_stocks(index_symbol, date)` | 获取指数成分股 |\r
| `get_industry_stocks(industry_code, date)` | 获取行业股票 |\r
| `get_concept_stocks(concept_code, date)` | 获取概念股票 |\r
\r
### 行业与概念\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_industries(name, date)` | 获取行业列表 |\r
| `get_concepts()` | 获取概念板块列表 |\r
| `get_concept(security, date)` | 获取股票所属概念 |\r
| `get_industry(security, date)` | 获取股票所属行业 |\r
\r
### 资金流向\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_money_flow(security_list, ...)` | 获取资金流向数据 |\r
| `get_money_flow_pro(security_list, ...)` | 获取专业资金流向 |\r
\r
### 融资融券\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_mtss(security_list, ...)` | 融资融券数据 |\r
| `get_margincash_stocks(date)` | 可融资标的列表 |\r
| `get_marginsec_stocks(date)` | 可融券标的列表 |\r
\r
### 期货数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_future_contracts(underlying_symbol, date)` | 期货合约列表 |\r
| `get_dominant_future(underlying_symbol, date)` | 主力合约 |\r
| `get_order_future_bar(symbol, future_type, ...)` | 连续合约行情 |\r
\r
### 因子数据\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_factor_values(securities, factors, ...)` | 因子值 |\r
| `get_all_factors()` | 所有可用因子 |\r
| `get_factor_kanban_values(...)` | 因子面板数据 |\r
| `get_factor_style_returns(...)` | 风格因子收益 |\r
| `get_factor_stats(...)` | 因子历史收益统计 |\r
\r
### Alpha因子\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_all_alpha_101(date, code, alpha)` | Alpha101因子 |\r
| `get_all_alpha_191(date, code, alpha)` | Alpha191因子 |\r
\r
### 技术分析\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `jq.technical_analysis.*` | 技术指标函数 |\r
\r
### 其他\r
\r
| 函数 | 说明 |\r
|------|------|\r
| `get_trade_days(start_date, end_date, count)` | 交易日列表 |\r
| `get_all_trade_days()` | 所有交易日 |\r
| `get_billboard_list(...)` | 龙虎榜数据 |\r
| `get_locked_shares(...)` | 限售股解禁 |\r
| `get_table_info(table)` | 数据表字段信息 |\r
\r
## 常用查询示例\r
\r
### 查询股票财务指标\r
\r
```python\r
import jqdatasdk as jq\r
from jqdatasdk import finance\r
\r
# 使用 SQLAlchemy 查询\r
q = jq.query(\r
    finance.indicator.code,\r
    finance.indicator.pub_date,\r
    finance.indicator.eps,  # 每股收益\r
    finance.indicator.net_profits,  # 净利润\r
    finance.indicator.revenue,  # 营业收入\r
    finance.indicator.total_assets,  # 总资产\r
).filter(\r
    finance.indicator.code == '000001.XSHE'\r
).order_by(\r
    finance.indicator.pub_date.desc()\r
)\r
\r
df = jq.get_fundamentals(q, date='2024-12-31')\r
print(df)\r
```\r
\r
### 查询多个股票财务数据\r
\r
```python\r
import jqdatasdk as jq\r
from jqdatasdk import finance\r
\r
# 批量查询\r
stocks = ['000001.XSHE', '000002.XSHE', '600519.XSHG']\r
q = jq.query(\r
    finance.indicator.code,\r
    finance.indicator.eps,\r
    finance.indicator.roa,\r
    finance.indicator.roe\r
).filter(\r
    finance.indicator.code.in_(stocks)\r
)\r
\r
df = jq.get_fundamentals(q, date='2024-12-31')\r
```\r
\r
### 获取市值数据\r
\r
```python\r
import jqdatasdk as jq\r
\r
# 获取多只股票的市值数据\r
stocks = ['000001.XSHE', '000002.XSHE', '600519.XSHG']\r
df = jq.get_valuation(\r
    stocks,\r
    start_date='2024-01-01',\r
    end_date='2024-12-31',\r
    fields=['code', 'day', 'pe_ratio', 'pb_ratio', 'market_cap', 'circulating_market_cap']\r
)\r
```\r
\r
### 因子策略示例\r
\r
```python\r
import jqdatasdk as jq\r
import pandas as pd\r
\r
# 获取因子数据\r
securities = jq.get_index_stocks('000300.XSHG')\r
factors_data = jq.get_factor_values(\r
    securities,\r
    factors=['pe_ratio', 'pb_ratio', 'roe'],\r
    start_date='2024-01-01',\r
    end_date='2024-12-31'\r
)\r
\r
# 处理因子数据\r
for factor_name, df in factors_data.items():\r
    print(f"Factor: {factor_name}")\r
    print(df.head())\r
```\r
\r
### 资金流向分析\r
\r
```python\r
import jqdatasdk as jq\r
\r
# 获取资金流向\r
stocks = ['000001.XSHE', '600519.XSHG']\r
df = jq.get_money_flow(\r
    stocks,\r
    start_date='2024-01-01',\r
    end_date='2024-12-31',\r
    fields=['date', 'sec_code', 'net_amount_main', 'net_pct_main']\r
)\r
```\r
\r
### 连续财务数据查询\r
\r
```python\r
import jqdatasdk as jq\r
from jqdatasdk import finance\r
\r
# 获取连续多季度财务数据\r
q = jq.query(\r
    finance.indicator.code,\r
    finance.indicator.pub_date,\r
    finance.indicator.eps,\r
    finance.indicator.net_profits\r
)\r
\r
df = jq.get_fundamentals_continuously(\r
    q,\r
    end_date='2024-12-31',\r
    count=8  # 最近8个季度\r
)\r
```\r
\r
## SQLAlchemy 查询指南\r
\r
### 常用表和字段\r
\r
```python\r
from jqdatasdk import finance\r
\r
# 财务指标表 (indicator)\r
finance.indicator.code           # 股票代码\r
finance.indicator.pub_date       # 发布日期\r
finance.indicator.eps            # 每股收益\r
finance.indicator.net_profits    # 净利润\r
finance.indicator.revenue        # 营业收入\r
finance.indicator.total_assets   # 总资产\r
finance.indicator.total_liab     # 总负债\r
finance.indicator.roe            # 净资产收益率\r
finance.indicator.roa            # 总资产收益率\r
finance.indicator.gross_profit   # 毛利率\r
finance.indicator.net_profit_margin  # 净利率\r
\r
# 资产负债表 (balance)\r
finance.balance.code\r
finance.balance.total_assets\r
finance.balance.total_liab\r
finance.balance.total_hldr_eqy_excl_min_int_shares  # 归属于母公司股东权益\r
\r
# 利润表 (income)\r
finance.income.code\r
finance.income.total_revenue\r
finance.income.oper_cost\r
finance.income.net_profit\r
\r
# 现金流量表 (cash_flow)\r
finance.cash_flow.code\r
finance.cash_flow.oper_cash_flow\r
finance.cash_flow.invest_cash_flow\r
finance.cash_flow.fin_cash_flow\r
```\r
\r
### 查询条件\r
\r
```python\r
from jqdatasdk import finance\r
import jqdatasdk as jq\r
\r
# 基本过滤\r
q = jq.query(finance.indicator).filter(\r
    finance.indicator.code == '000001.XSHE'\r
)\r
\r
# IN 查询\r
q = jq.query(finance.indicator).filter(\r
    finance.indicator.code.in_(['000001.XSHE', '000002.XSHE'])\r
)\r
\r
# 多条件\r
q = jq.query(finance.indicator).filter(\r
    finance.indicator.code == '000001.XSHE',\r
    finance.indicator.pub_date >= '2024-01-01'\r
)\r
\r
# 排序和限制\r
q = jq.query(finance.indicator).filter(\r
    finance.indicator.code == '000001.XSHE'\r
).order_by(finance.indicator.pub_date.desc()).limit(10)\r
```\r
\r
## 二次开发指南\r
\r
### 扩展新的API\r
\r
参考官方 `jqdatasdk/api.py` 的实现模式:\r
\r
```python\r
from jqdatasdk.utils import assert_auth\r
from jqdatasdk.client import JQDataClient\r
\r
@assert_auth\r
def my_custom_api(param1, param2=None):\r
    """\r
    自定义API说明\r
    \r
    :param param1: 参数1说明\r
    :param param2: 参数2说明\r
    :return: 返回值说明\r
    """\r
    return JQDataClient.instance().my_custom_api(param1=param1, param2=param2)\r
```\r
\r
### 添加新的财务表\r
\r
参考 `jqdatasdk/finance_tables.py` 的结构:\r
\r
```python\r
from sqlalchemy import Column, String, Numeric, Date\r
from jqdatasdk.finance_tables import Base\r
\r
class MyCustomTable(Base):\r
    __tablename__ = 'my_custom_table'\r
    \r
    code = Column(String(20), primary_key=True)\r
    report_date = Column(Date)\r
    field1 = Column(Numeric(20, 4))\r
    field2 = Column(Numeric(20, 4))\r
```\r
\r
### 缓存优化\r
\r
使用内置缓存装饰器:\r
\r
```python\r
from jqdatasdk.utils import hashable_lru\r
\r
@hashable_lru(maxsize=3)\r
def my_cached_function(security, start_date, end_date):\r
    """带缓存的函数"""\r
    # 实际查询逻辑\r
    return JQDataClient.instance().query(...)\r
```\r
\r
## 错误处理\r
\r
### 常见错误\r
\r
```python\r
import jqdatasdk as jq\r
\r
try:\r
    jq.auth('username', 'password')\r
    df = jq.get_price('000001.XSHE')\r
except jq.exceptions.ParamsError as e:\r
    print(f"参数错误: {e}")\r
except Exception as e:\r
    print(f"其他错误: {e}")\r
```\r
\r
### 认证错误\r
\r
```python\r
if not jq.is_auth():\r
    jq.auth('username', 'password')\r
    print("认证成功")\r
else:\r
    print("已认证")\r
```\r
\r
## 性能优化\r
\r
1. **批量查询**: 尽量使用批量接口而非循环单个查询\r
2. **缓存使用**: 对不频繁变化的数据使用 `@hashable_lru` 缓存\r
3. **字段筛选**: 只查询需要的字段减少数据传输\r
4. **日期范围**: 使用 `count` 参数代替大范围日期查询\r
\r
## 注意事项\r
\r
1. **认证要求**: 绝大多数API需要先调用 `jq.auth()` 认证\r
2. **请求限制**: 注意API的调用频率限制\r
3. **数据延迟**: 财务数据可能有延迟,注意数据发布日期\r
4. **股票代码格式**: 使用聚宽标准格式如 `000001.XSHE` (深圳) 或 `600519.XSHG` (上海)\r
\r
## 参考资源\r
\r
- 聚宽官方文档: https://www.joinquant.com/help/api/\r
- 财务数据字典: https://www.joinquant.com/data/dict/fundamentals\r
- 指数数据: https://www.joinquant.com/indexData\r
- 行业分类: https://www.joinquant.com/data/dict/plateData\r
Usage Guidance
This skill is a documentation/example pack for the official jqdatasdk and appears internally consistent. Before using: 1) Install jqdatasdk from the official PyPI/GitHub releases (pip install jqdatasdk) rather than copying third-party wheels. 2) Only provide your JoinQuant username/password or token to trusted code/runtime — avoid pasting credentials into public chats or untrusted environments. 3) Note the package requires a JoinQuant account to fetch most data and is subject to API rate limits and data licensing. 4) The skill metadata lists no homepage/source; if you need stronger provenance, verify the publisher or obtain the official SDK directly from JoinQuant (github.com/JoinQuant/jqdatasdk) before use.
Capability Analysis
Type: OpenClaw Skill Name: jqdatasdk-skill Version: 1.0.0 The skill bundle provides documentation and code examples for the JoinQuant (聚宽) jqdatasdk quantitative trading library. It covers standard API usage for market data, financial indicators, and factor analysis, including authentication procedures and extension guides. No evidence of malicious intent, data exfiltration, or prompt injection was found; the content is entirely aligned with its stated purpose of assisting in quantitative trading development.
Capability Assessment
Purpose & Capability
The skill's name/description say it's a JoinQuant (jqdatasdk) development helper and the SKILL.md contains API references and example code that directly use jqdatasdk. There are no unrelated credentials, binaries, or capabilities requested.
Instruction Scope
Runtime instructions are example Python usage of jqdatasdk (auth, get_price, get_fundamentals, etc.). They do not instruct reading system files, digging up unrelated environment variables, or calling unexpected external endpoints beyond JoinQuant documentation and GitHub references.
Install Mechanism
This is an instruction-only skill with no install spec or code to write to disk; it recommends pip install jqdatasdk which is appropriate and proportionate. No downloads from arbitrary URLs or archive extraction are present.
Credentials
The skill declares no required environment variables or credentials. Examples demonstrate using JoinQuant account credentials or tokens (which is expected for this SDK). There are no unrelated or excessive secret requests.
Persistence & Privilege
always is false and the skill is user-invocable only. It does not request permanent platform presence or system-wide configuration changes.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install jqdatasdk-skill
  3. After installation, invoke the skill by name or use /jqdatasdk-skill
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
- Initial release of the jqdatasdk-skill for Python 3.10+. - Provides comprehensive documentation and quick start guides for using the JoinQuant (聚宽) jqdatasdk, including finance, factor, and market data API usage examples. - Includes categorized API reference tables, SQLAlchemy query patterns, and common usage scenarios for algorithmic trading development. - Supports key features like authentication (account/password, token), multi-type data queries, factor analysis, funds flow, and technical indicators. - Suitable for quantitative strategy development, backtesting, and data analysis using 聚宽数据接口.
Metadata
Slug jqdatasdk-skill
Version 1.0.0
License MIT-0
All-time Installs 1
Active Installs 1
Total Versions 1
Frequently Asked Questions

What is JoinQuant datasdk skill?

JoinQuant (聚宽) 量化交易数据SDK开发技能。基于jqdatasdk官方库提供行情数据获取、财务数据查询、因子数据等API。用于开发量化交易策略、进行jqdatasdk二次开发、API问题排查。 适用于需要使用聚宽数据接口进行策略开发、回测验证、数据分析的场景。 It is an AI Agent Skill for Claude Code / OpenClaw, with 242 downloads so far.

How do I install JoinQuant datasdk skill?

Run "/install jqdatasdk-skill" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is JoinQuant datasdk skill free?

Yes, JoinQuant datasdk skill is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does JoinQuant datasdk skill support?

JoinQuant datasdk skill is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created JoinQuant datasdk skill?

It is built and maintained by IdiosyncraticDragon (@idiosyncraticdragon); the current version is v1.0.0.

💬 Comments