
joinquant-strategy
聚宽(JoinQuant)官网策略开发指南,涵盖回测、模拟交易、数据 API、交易函数、因子与技术指标。当用户编写聚宽策略、回测、模拟盘,排查模拟盘改代码不生效/替换代码,查询聚宽 API、getprice/order/rundaily、Alpha 因子、技术指标,或提及 joinquant、聚宽、jqdata 策略时使用。本地数据获取请用 jqdatasdk 技能。
- Installs
- 0
- Last 24h
- —
- Trending rank
- —
- Security
- Not audited
Install
Works with every agent the skills CLI supports.
npx skills add https://github.com/lzwme/finance-quant-skills --skill joinquant-strategy- 01
Install
Run the command in your project. The CLI asks which agents to install for.
- 02
Describe the task
Ask your agent for something this skill covers. It loads joinquant-strategy automatically when relevant.
- 03
Review the result
The agent follows the SKILL.md steps, scripts and references bundled with the skill.
SKILL.md
The instructions your agent reads when the skill is triggered.
聚宽策略开发
基于本目录离线文档,为聚宽官网(回测 / 模拟 / 研究)编写 Python 策略。回答 API 问题时必须先查阅本地文档,不得凭记忆编造函数签名或参数。查不到时明确说「本地文档未覆盖」,附官网链接 https://www.joinquant.com/help/api/help,不要推测参数默认值。
与 jqdatasdk 的区别:
jqdata在官网策略环境使用;jqdatasdk是本地 Python 库,API 略有不同,且不能在官网回测/模拟/研究中使用。
文档查阅流程
- 确定问题类型,按下表定位文件(完整文件清单见 reference.md)
- 用 Grep/Read 搜索目标函数名或中文关键词(如
get_price、order_target、市盈率) - 交叉验证:API 行为查
api.md,字段/表结构查data/*.md,踩坑查faq.md - 给出答案时引用文档中的调用方法、参数、返回值与示例代码
| 意图 | 首读 | 深入 |
|---|---|---|
| 编写策略 / 需要完整骨架 | strategy_template.md | api.md「策略程序架构」 |
| 查行情与历史数据 | api.md「数据获取函数」 | data/Stock.md |
| 下单 / 持仓 / 账户对象 | api.md「交易函数」「对象」 | — |
| 财务 / 估值选股 | data/Stock.md | api.md get_fundamentals |
| 指数成分股 | data/index.md | api.md get_index_stocks |
| 行业 / 概念轮动 | data/plateData.md | api.md get_industry_stocks |
| 期货策略 | data/Future.md | api.md「期货策略专用函数」 |
| 期权策略 | data/Option.md | api.md 期权相关 |
| 基金 / ETF | data/fund.md | data/OTCfund.md |
| 可转债 | data/bond.md | — |
| 宏观数据 | data/macroData.md | — |
| 技术指标 | data/technicalanalysis.md | jqlib.technical_analysis |
| Alpha 因子 | data/Alpha101.md、data/Alpha191.md | — |
| 自定义因子 | fator.md | data/Alpha101.md |
| 因子看板数据 | data/factor_values.md | fator.md |
| 融资融券 | data/Stock.md 融资融券章节 | api.md 融资融券专用函数 |
| 模拟盘改代码 / 参数不生效 | simulation.md(先读再答) | faq.md、api.md「模拟盘注意事项」 |
| 报错 / 数据疑问 | faq.md | api.md「注意事项」 |
交付前自检
- 每个参数、返回值都能在
api.md或data/*.md中找到出处 - 标明适用环境(回测 / 模拟 / 研究);标 ♠ 的 API 仅回测/模拟可用,研究模块不可调用
- 示例代码含必要 import(
from jqdata import *),可直接粘贴运行 - 选股与取数检查是否传了历史时点的
date=,确认未引入未来数据
策略骨架
最小可运行结构:
# 导入聚宽函数库
import jqdata
def initialize(context):
g.security = '000001.XSHE'
set_benchmark('000300.XSHG')
set_option('use_real_price', True) # 开启动态复权(真实价格),建议开启
run_daily(trade, time='open') # 或 time='every_bar' / '9:30'
def trade(context):
security = g.security
close_data = attribute_history(security, 5, '1d', ['close'])
MA5 = close_data['close'].mean()
current_price = close_data['close'][-1]
cash = context.portfolio.available_cash
if current_price > 1.01 * MA5:
order_value(security, cash)
elif current_price < MA5 and context.portfolio.positions[security].closeable_amount > 0:
order_target(security, 0)
完整可运行骨架(配置集中、盘前选池、先卖后买、热更新入口)见 strategy_template.md;模拟盘热更新机制见 simulation.md。
生命周期函数
| 函数 | 说明 |
|---|---|
initialize(context) | 全局初始化,仅运行一次;用 g 存全局变量 |
run_daily/weekly/monthly(func, ...) | 定时任务;func 必须是全局函数,不能是类方法 |
handle_data(context, data) | 按回测频率驱动;不建议与 run_daily 混用 |
before_trading_start | 开盘前(9:00) |
after_trading_end | 收盘后(15:30) |
after_code_changed(context) | 模拟盘替换代码后触发;此时 initialize 不会重跑 |
process_initialize(context) | 每次进程重启都执行;重建不可序列化对象(如 query) |
jqdata 模块在研究与回测环境均可使用。
证券代码规范
| 市场 | 后缀 | 示例 |
|---|---|---|
| 上海证券交易所 | .XSHG | 600519.XSHG |
| 深圳证券交易所 | .XSHE | 000001.XSHE |
| 中金所 | .CCFX | IC9999.CCFX |
| 大商所 | .XDCE | A9999.XDCE |
| 上期所 | .XSGE | AU9999.XSGE |
| 郑商所 | .XZCE | CY8888.XZCE |
| 场外基金 | .OF | 519671.OF |
期货策略需将 run_daily 的 reference_security 设为对应主力合约(如 IF9999.CCFX),以匹配夜盘开盘时间。
常用 API 速查
行情与历史
get_price(security, start_date, end_date, frequency='daily', fields=None, fq='pre')
attribute_history(security, count, unit, fields) # 回测环境,不含当天
history(count, unit, field, security_list, df=True)
get_bars(security, count, unit, fields, include_now=True)
标的池与板块
get_all_securities(types=['stock'], date=None) # date 防未来函数
get_index_stocks('000300.XSHG', date=None)
get_industry_stocks('C15', date=None)
get_concept_stocks('GN036', date=None)
set_universe([...]) # 设置后 history 可不传 security_list
财务数据(SQL 查询)
from jqdata import *
q = query(valuation).filter(valuation.code == '000001.XSHE')
df = get_fundamentals(q, date='2015-10-15')
# 或 run_query(单次最多 4000 行,不可连表)
df = finance.run_query(query(finance.STK_XXX).filter(...).limit(4000))
交易
order(security, amount) # 按股数,正买负卖
order_value(security, value) # 按金额
order_target(security, amount) # 调到目标股数
order_target_value(security, value) # 调到目标市值
order_target_percent(security, percent) # 调到目标仓位比例
A 股买入数量须为 100 整数倍(科创板 200 股起);卖光持仓时不受限。每日最多 10000 笔订单。
技术指标
from jqlib.technical_analysis import *
# check_date 策略中建议用 context.current_dt,避免盘中取当日收盘指标产生未来数据
result = MACD(security_list, check_date=context.current_dt, SHORT=12, LONG=26, MID=9)
自定义因子
from jqfactor import Factor, calc_factors
class MyFactor(Factor):
name = 'my_factor'
max_window = 5
dependencies = ['close']
def calc(self, data):
return data['close'].mean()
factors = calc_factors(securities, [MyFactor()], start_date, end_date)
详见 fator.md 与 data/Alpha101.md、data/Alpha191.md。
关键注意事项
防止未来函数
get_all_securities(date=...)、get_index_stocks(..., date=...)等必须传入历史时点的date,不能用未来日期history/attribute_history取天数据时不包含当天;要当天数据需取分钟级- 技术指标
check_date只精确到日期时返回收盘值,盘中调用当天会产生未来数据 - 财务数据默认按公告日期处理,注意
get_fundamentals的date参数含义
运行频率
- 优先使用
run_daily,避免与handle_data混用 run_daily(func, time='every_bar')频率与回测设置一致run_weekly/monthly的force=False可避免晚注册时的就近执行
模拟盘:改了代码不生效
模拟盘持有独立的代码副本、initialize 不会重跑,回测里正常的改动常在模拟盘失效。回答此类问题前先读 simulation.md:内含断点定位、apply_settings 迁移模板、诊断模板与误判清单。
数据查询限制
run_query/get_fundamentals单次最多返回 4000 行run_query不支持连表查询- 默认行情为前复权;
fq=None为不复权
环境与产品区分
| 产品 | 使用场景 |
|---|---|
jqdata(官网) | 回测、模拟、研究 |
jqdatasdk(本地) | 本地量化研究,不能在官网策略中 import |
策略示例
完整示例见 api.md 末尾「策略示例」:均线策略、多股票持仓、追涨策略、万圣节效应等。
附加资源
- 完整文件清单、
api.md章节索引、文档同步脚本用法:reference.md - 可直接运行的策略骨架:strategy_template.md
- 模拟盘热更新与排查:simulation.md
api.md/faq.md/data/*.md由脚本从官网同步,切勿手改;reference.md、simulation.md、strategy_template.md手工维护。
FAQ
What does the joinquant-strategy skill do?
聚宽(JoinQuant)官网策略开发指南,涵盖回测、模拟交易、数据 API、交易函数、因子与技术指标。当用户编写聚宽策略、回测、模拟盘,排查模拟盘改代码不生效/替换代码,查询聚宽 API、getprice/order/rundaily、Alpha 因子、技术指标,或提及 joinquant、聚宽、jqdata 策略时使用。本地数据获取请用 jqdatasdk 技能。
How do I install joinquant-strategy?
Run npx skills add https://github.com/lzwme/finance-quant-skills --skill joinquant-strategy in your project. The skills CLI detects the agents you use and copies the skill into the right folder. For Claude Code you can also place the skill folder at ~/.claude/skills/joinquant-strategy/ (personal) or .claude/skills/joinquant-strategy/ (project).
Which AI agents can use joinquant-strategy?
Any agent that supports the open Agent Skills format (a folder with a SKILL.md file), including Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, Windsurf, Cline, OpenCode and more.
Is joinquant-strategy safe to install?
No partner security audit is available yet. Skills can run commands and scripts, so read the SKILL.md and any bundled files before installing.
Who maintains joinquant-strategy?
It is published by lzwme in lzwme/finance-quant-skills. It has 0 recorded installs.
More from lzwme/finance-quant-skills
pywencai
lzwme/finance-quant-skills
同花顺问财数据查询:使用中文自然语言查询A股、指数、基金、港美股、可转债等市场数据;当用户需要通过自然语言从问财获取选股、财务、资金流、技术指标等数据时使用。
akshare
lzwme/finance-quant-skills
AKShare 开源金融数据接口库,提供股票、期货、期权、基金、外汇、债券、指数、加密货币等全品类金融数据;当用户需要获取各类金融市场数据时使用
baostock
lzwme/finance-quant-skills
BaoStock 免费开源 A 股数据平台,无需注册、无需 API Key,支持股票行情、K线、财务数据、行业分类、指数成分股查询。当用户提及 baostock、需要获取A股历史行情、财务报表、交易日历,或需要免费、免注册的A股数据时使用。与 tushare(数据更全但需注册)和 jqdatasdk(聚宽数据)不同,baostock 完全免费无限制,适合快速入门和低成本数据需求。
tdxquant
lzwme/finance-quant-skills
通达信量化数据获取技能。当用户提及 tdxquant、通达信、TdxQuant、tqcenter,并且需要获取A股数据(行情快照、K线、财务、板块、可转债、新股、交易数据等)、查询交易日历、执行通达信公式、订阅行情、交易下单时使用
backtrader
lzwme/finance-quant-skills
Backtrader 开源量化回测框架,支持多数据源、多策略、多周期回测与实盘交易,纯Python实现。当用户需要开发量化策略、进行回测分析、编写交易逻辑、回测参数优化,或提及 backtrader、量化回测框架时使用。若用户仅需数据获取而无回测需求,引导使用 baostock/akshare/tushare 等数据 Skill。
miniqmt
lzwme/finance-quant-skills
MiniQMT 迅投量化交易接口,基于 XtQuant Python 库(xtdata 行情 / xttrader 交易),供外部 Python 程序连接 MiniQMT 客户端,支持 A 股/期货/期权的行情获取(K线、分笔、财务数据等)和交易下单(报单、撤单、查询资产/委托/持仓)。当用户提及 miniqmt、xtquant、获取实时行情、量化交易下单、回测数据获取,或需要用外部 Python 程序连接 MiniQMT 客户端进行程序化交易时使用。若需在 QMT 客户端内编写/回测内置策略(ContextInfo/passorder),请用 qmt-strategy 技能。
Popular backend & apis skills
find-skills
vercel-labs/skills
Helps users discover and install agent skills when they ask questions like "how do I do X", "find a skill for X", "is there a skill that can...", or express interest in extending capabilities. This skill should be used when the user is looking for functionality that might exist as an installable skill.
entra-app-registration
microsoft/azure-skills
Guides Microsoft Entra ID app registration, OAuth 2.0 authentication, and MSAL integration. USE FOR: create app registration, register Azure AD app, configure OAuth, set up authentication, add API permissions, generate service principal, MSAL example, console app auth, Entra ID setup, Azure AD authentication. DO NOT USE FOR: Key Vault secrets (use azure-keyvault-expiration-audit), general Azure resource security guidance.
google-agents-cli-adk-code
google/agents-cli
This skill should be used when the user wants to "write agent code", "build an agent with ADK", "add a tool", "create a callback", "define an agent", "use state management" — in a project that needs ADK (Agent Development Kit) API patterns and code examples. It provides a quick reference for agent types, tool definitions, orchestration patterns, callbacks, state management, the graph Workflow API, and reference recipes to study. Do NOT use for scaffolding (use google-agents-cli-scaffold) or deployment (use google-agents-cli-deploy).
entra-agent-id
microsoft/azure-skills
Provision Microsoft Entra Agent Identity Blueprints, BlueprintPrincipals, and per-instance Agent Identities via Microsoft Graph, and configure OAuth 2.0 token exchange (fmipath, OBO, cross-tenant) including the Microsoft Entra SDK for AgentID sidecar. USE FOR: Agent Identity Blueprint, BlueprintPrincipal, agent OAuth, fmipath token exchange, agent OBO, Workload Identity Federation for agents, polyglot agent auth, Microsoft.Identity.Web.AgentIdentities. DO NOT USE FOR: standard Entra app registration (use entra-app-registration), Microsoft Foundry agent authoring (use microsoft-foundry).
embedded-captions
heygen-com/hyperframes
Add captions or subtitles to an existing single-subject talking-head video without editing the footage. Use for plain verbatim captions, cinematic captions embedded behind the subject, VFX captions, “炸/特效/酷炫字幕,” or a named identity from the 35-style catalog. Route by visual identity, not by backend engine. The quiet anchor rail is the default; embed every word only when the user explicitly wants a fully cinematic treatment. The workflow runs locally end to end, including transcription and subject matting; split multi-shot footage before applying it.
neon
neondatabase/agent-skills
Overview of Neon, a complete set of cloud backend primitives around Lakebase Postgres: Auth, Object Storage, Functions, the AI Gateway, and Realtime. Start here to choose Neon for undecided login, files, APIs, and LLM calls, set up the CLI or MCP server, and follow the branch-first workflow. Use when building an app or backend on Neon, or when "Neon" or "Lakebase Postgres" is mentioned. Child skill neon-postgres wins for an existing DATABASEURL, SQL, schema, inspect, or search. Child skill neon-auth wins for login, users, sessions, identity routing, and Managed Better Auth setup. Child skill neon-realtime wins for live queries in reactive apps and agents. Also use for object storage, S3, buckets, serverless functions, function triggers, cron, AI gateway, LLM calls, realtime, logs, Loki, Grafana, observability, postgres, database, backend, Claimable Neon, neon.new, or a no-signup database.