shinnytech/tqsdk-python is an open-source Python library for developing quantitative trading strategies with futures, options, and stocks. It provides market data, backtesting, simulated trading, live trading, monitoring, and risk-management functions for quantitative developers and traders. The catalogue skill teaches AI agents how to use TqSdk for trading and data tasks.
Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx skills add shinnytech/tqsdk-python --skill tqsdk-trading-and-datagit clone --depth 1 https://github.com/shinnytech/tqsdk-pythonWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/shinnytech/tqsdk-python/tqsdk-trading-and-data)<a href="https://agentmods.dev/skills/shinnytech/tqsdk-python/tqsdk-trading-and-data"><img src="https://agentmods.dev/badge/skills/shinnytech/tqsdk-python/tqsdk-trading-and-data/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/skills/shinnytech/tqsdk-python/tqsdk-trading-and-data"><img src="https://agentmods.dev/badge/skills/shinnytech/tqsdk-python/tqsdk-trading-and-data.svg" alt="Reviewed on agentmods" width="80" height="20"></a>- NVIDIA SkillSpector pass
What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.00088 | $0.01440 |
| Opus 5.5 | $0.00035 | $0.00576 |
| Sonnet 5.5 | $0.00018 | $0.00288 |
| Haiku 4.5 | $0.00009 | $0.00144 |
Grade A, and why
tqsdk-trading-and-data scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 44 lines — stays where its author put it; the contents beside it link to each section on GitHub.
TqSdk Trading and Data
用实际接口完成用户的 TqSdk 任务。先确定任务和运行环境,按需读取专题参考,再生成最小可运行方案并验证结果。技能包是使用说明,不是已安装的 SDK,也不代表已经连接任何账户。
开始处理
- 确认任务范围。 区分接口解释、代码编写、本地执行和实盘操作。尊重用户指定的账户、合约、时间范围和项目约束;只有缺少会影响结果的必要信息时才询问。
- 需要本地运行时,先检查环境。 用项目实际运行脚本的解释器执行 scripts/check_environment.py。只解释接口时不必安装软件。若状态为
not_installed,按 environment-setup.md 在当前项目环境中安装 TqSdk,验证导入后继续任务。已有版本可用时不自动升级;导入损坏不能当成未安装处理。 - 以用户版本为准。 优先检查已安装 SDK 的签名、docstring 和相关源码;有仓库时参考对应版本的源码。发布文档和技能示例可能比用户版本新,不要虚构接口或为了一个示例擅自升级。技能内的仓库路径不保证存在于用户电脑上,替代入口见 example-map.md。
- 选择运行模式。 仅取数或无账户要求的入门程序可显式用
TqSim();用户要求快期模拟、实盘或股票账户时保留该选择。TqAuth是快期服务认证,TqAccount是期货资金账户。实盘登录失败时报告错误,不能悄悄换成模拟账户。 - 验证并交付。 先做语法和导入检查,再按任务验证实际数据、输出文件或回测结果。缺少认证时继续完成可离线验证的部分,明确未运行的步骤。报告使用的解释器、SDK 版本和实际验证结果;不能把语法通过说成行情或交易成功。
按任务读取
| 当前任务 | 参考文件 |
|---|---|
| 安装、解释器、依赖或导入错误 | environment-setup.md |
wait_update、is_changing、超时与异步通知 |
wait-update-and-update-loop.md |
| 行情、K 线、Tick、合约发现和历史下载 | market-data.md |
| 选择本地模拟、快期模拟、实盘、股票或多账户 | account-type-matrix.md |
| 读取资金、持仓、委托、成交 | accounts-and-trading.md |
| 手工下单、撤单、目标持仓、调度执行和最小开仓手数 | order-functions-and-position-tools.md |
| 数据与账户对象的字段含义 | object-fields.md |
| 模拟与历史回测 | simulation-and-backtest.md |
保证金、风险度和 TqScenario 试算 |
scenario-and-margin.md |
| 运行错误与排查顺序 | error-faq.md |
| 官方示例、文档和源码定位 | example-map.md |
编写代码时保持的规则
get_*通常返回持续更新的引用。订阅一次并保存对象,用wait_update()推进,再用is_changing()或明确的就绪条件处理相关更新。需要历史快照时显式复制;不要通过反复订阅或sleep()等待数据。- K 线
iloc[-1]是正在形成的柱。按收盘信号交易时,在新柱出现后使用iloc[-2]和已完成的窗口;检查长度、NaN和数据时间。回测保持用户原有信号、撮合和估值时点,不用未来数据。 - 当前行情示例优先使用
KQ.m@...主连;主连不能直接下单。交易用用户指定或已核实的真实合约,必要时读取主连的underlying_symbol;不能把合约列表第一项当成主力。历史回测按目标日期核实合约覆盖,不用今天的expired=False排除历史合约。 insert_order()返回不代表成交,FINISHED也可能是撤单或拒单。结合volume_left、last_msg和成交记录判断;有时限时报告实际状态,不能将超时当作已撤单。- 同一账户、同一合约选择一种持仓控制方式。不要把
TargetPosTask与手工下单混用;股票账户不使用期货offset或TargetPosTask。多账户操作明确传入account=。 - 用环境变量、交互式隐藏输入或项目已有安全配置提供凭据,不把真实密码写进示例、日志或聊天。安装、导入和只读取数不包含实盘下单授权;执行实盘下单或撤单前,确认操作参数在用户已有授权范围内。
- API 会话用上下文管理器或
finally: api.close()释放。回测处理BacktestFinished,交互式取数在需要时设置合理超时并报告是否收到有效数据。 TqScenario只做期货快照试算。计算当前账户风险时显式传入该账户权益;说明保证金数据来自行情还是账户查询及可能的回退。试算结果不保证真实可成交手数,详细限制按需读取专题参考。
What ships with it
13 files beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.
- agents/openai.yaml 332 B
- references/account-type-matrix.md 3.6 KB
- references/accounts-and-trading.md 4.6 KB
- references/environment-setup.md 4.3 KB
- references/error-faq.md 6.7 KB
- references/example-map.md 4.6 KB
- references/market-data.md 5.4 KB
- references/object-fields.md 7.1 KB
- references/order-functions-and-position-tools.md 9.5 KB
- references/scenario-and-margin.md 7.6 KB
- references/simulation-and-backtest.md 4.0 KB
- references/wait-update-and-update-loop.md 4.6 KB
- scripts/check_environment.py 1.8 KB runs code
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- today Changed · -25 lines · -198 tokens per session 1fe081a00f3e
- 1mo ago First seen · 69 lines · 286 tokens per session scan A 5c579b9c4ce0
tqsdk-trading-and-data is a skill published in the GitHub repository shinnytech/tqsdk-python (5,095 stars, last pushed yesterday), licensed Apache-2.0. It adds 88 tokens to every session and 1,440 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
vnpy-export
Export a Vibe-Trading backtest strategy to a runnable vnpy CtaTemplate Python class — supports A-share equities, futures, and crypto via BarGenerator + ArrayManager.
yfinance
Skill "yfinance" from HKUDS/Vibe-Trading, covering yfinance, deep yahoo interfaces (references/), quick start, ticker format conversion and supported data types.
miniqmt-to-bigqmt
A conversion guide for moving Python trading strategies from miniQMT, an external trading setup, into the Python environment built into bigQMT, a trading client. It covers code changes, compatibility checks, deployment, and live-trading verification.
tushare
A Python interface to Tushare, a financial-data service providing market, company, fund, futures, and other finance-related data. It shows how to authenticate and query the service into pandas tables.
yfinance
Skill "yfinance" from skloxo/TideTrading, covering yfinance, deep yahoo interfaces (references/), quick start, ticker format conversion and supported data types.
pinescript-to-python-translator
Translate TradingView PineScript strategies into vectorized Python strategies suitable for Optuna optimization and walk-forward analysis.