tdx2db-query

tdx2db-query is a skill for Claude Code from xbfighting/tdx2db. It costs 55 tokens per session (1,563 once invoked), scanned A, original, MIT.

A guide for querying tdx2db, a database containing Chinese A-share stock prices and market data. It covers daily and minute-level prices, moving-average screens, and checks that the synchronized data is current and complete.

In plain words
What is it for?
Use it to check synchronization status, retrieve one stock's daily or minute prices, filter the market by moving averages, find the latest trading date, and inspect sector membership.
Why use it?
It reduces mistakes when analyzing stock data, such as querying the wrong table, using an incorrectly formatted stock code, or working with an incomplete database.

Skill for Claude Code

Written for Claude Code: installed under .claude/. Also seen: mentions AGENTS.md.

Install

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.

agentmods
npx agentmods add skills/xbfighting/tdx2db/tdx2db-query
Any agent
npx skills add xbfighting/tdx2db --skill tdx2db-query
Clone the repo
git clone --depth 1 https://github.com/xbfighting/tdx2db

Made for: Claude Code.

Wrote 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.

agentmods badge for tdx2db-query

README.md
[![agentmods](https://agentmods.dev/badge/skills/xbfighting/tdx2db/tdx2db-query.svg)](https://agentmods.dev/skills/xbfighting/tdx2db/tdx2db-query)
Your own site
<a href="https://agentmods.dev/skills/xbfighting/tdx2db/tdx2db-query"><img src="https://agentmods.dev/badge/skills/xbfighting/tdx2db/tdx2db-query.svg" alt="Measured on agentmods" height="20"></a>
Per session 55 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,563 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5.1 $0.00055 $0.01563
Opus 5 $0.00028 $0.00781
Sonnet 5 $0.00011 $0.00313
Haiku 4.5 $0.00006 $0.00156

Measured 6d ago against content hash cf71bccd3686, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

tdx2db-query 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 6d ago.

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.

.claude/skills/tdx2db-query/SKILL.md · 109 lines

How it starts

The opening of the file, as written. The whole thing — 109 lines — stays where its author put it; the contents beside it link to each section on GitHub.

tdx2db 数据库查询手册

数据库由 tdx2db sync 写入(PostgreSQL / MySQL / SQLite,连接配置见项目 .env)。查询前先读 AGENTS.md 的 schema 与陷阱清单;本 skill 提供可直接套用的操作模板。

第一步永远是确认数据状态

tdx2db status --json

关注三点:daily_data.latest 是否为预期交易日;rows/codes 是否符合常识(全市场约 4000+ 只);warnings 是否为空。任何分析在数据不新鲜/不完整时都是白做。

SQL 模板

单票日线(含缠论均线族)

SELECT date, open, high, low, close, volume, amount,
       ma5, ma13, ma21, ma34, ma55, ma89, ma144, ma233
FROM daily_data
WHERE code = :code6      -- 6 位纯数字,如 '600036',不带 sh/sz 前缀!
  AND date BETWEEN :start AND :end
ORDER BY date;

某日全市场截面(成熟股票)

SELECT code, close, ma5, ma13, ma21, ma34, ma55, ma89, ma144, ma233
FROM daily_data
WHERE date = :d AND ma233 IS NOT NULL;   -- ma233 非空 ≈ 上市满一年,天然剔除次新股

最新可用交易日

SELECT MAX(date) FROM daily_data WHERE ma5 IS NOT NULL;

分钟线(表按周期选:minute5_data / minute15_data / minute30_data / minute60_data)

SELECT datetime, open, high, low, close, volume, amount
FROM minute30_data
WHERE code = :code6 AND datetime BETWEEN :start AND :end
ORDER BY datetime;

周线/月线:无独立表,取日线后 pandas resample('W')/resample('ME') 聚合(open=first, high=max, low=min, close=last, volume/amount=sum)。

板块成分 / 个股板块归属(block_type ∈ 行业/概念/指数/地区/风格/特殊)

-- 板块 → 成分(行业为 881 研究行业,一/二/三级各一行,按名或 block_code 定位)
SELECT code FROM block_stock_relation
WHERE block_type = '行业' AND block_name = '煤炭开采';

-- 全部二级行业(≈ 通达信导出 CSV 的行业口径,板块强弱迭代用这个)
SELECT DISTINCT block_name FROM block_stock_relation
WHERE block_type = '行业' AND block_level = 2;

-- 个股 → 全部板块归属
SELECT block_type, block_code, block_name FROM block_stock_relation WHERE code = :code6;

-- 板块成分 JOIN 行情(北交所成员在行情表无数据,JOIN 自然过滤)
SELECT d.code, d.close, d.ma233
FROM block_stock_relation b JOIN daily_data d ON d.code = b.code
WHERE b.block_type = '概念' AND b.block_name = '人形机器人' AND d.date = :d;

板块表为全量快照(随 sync 更新,无历史版本);板块名以 tdxzs.cfg 官方全名为准,跨口径对齐用 block_code。

换手率 / 次新股过滤(股本与上市日期在 stock_info,万股,快照口径)

-- 换手率(%):volume(手)/ltag(万股) 单位差恰好抵消;股本变动点前的历史值失真
SELECT d.date, d.volume / s.ltag AS turnover_pct
FROM daily_data d JOIN stock_info s ON RIGHT(s.code, 6) = d.code
WHERE d.code = :code6 ORDER BY d.date DESC LIMIT 20;

-- 剔除次新股(上市不足 500 天)
SELECT RIGHT(code, 6) FROM stock_info WHERE list_date < CURRENT_DATE - 500;

Read the full file on GitHub · 109 lines

Changes

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.

  1. 6d ago First seen · 109 lines · 55 tokens per session scan A cf71bccd3686

Subscribe to this mod's changes

tdx2db-query is a skill published in the GitHub repository xbfighting/tdx2db (149 stars, last pushed 14d ago), licensed MIT. It adds 55 tokens to every session and 1,563 once invoked, about $0.0003 per session on Opus 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.

Related

Other skills, from other repositories

ee

Working pattern for enterprise-edition features in Grida — the commercial/hosted concerns (entitlement, BYOD, billing) on top of the OSS core. Anchor for the GRIDA-EE: grep marker, (ee) route group, -hosted package suffix, and namespaced grida schema. Use when adding or touching an EE-only feature, or deciding whether…

gridaco/grida · 103 tokens

hithink-finance-data

用于 Agent 通过 hithink-finance CLI 管理本地 DuckDB:初始化、同步、状态、校验、迁移、修复、清理、删除、只读 SQL、导出;远端实时数据转对应业务 skill。.

HiThink-Tech/Financial-API · 60 tokens

ee-billing

Surface workflow for billing in Grida — Stripe (subscriptions) + Metronome (AI credit ledger). The stable contracts: gridabilling. is not REST-exposed (views/RPCs only), fnbillingapply are the single mutation points, webhook receivers are GRIDA-SEC-001, BYOK is the GRIDA-SEC-003 carve-out. Use when touching…

gridaco/grida · 127 tokens

trading-manual-writer

为"全品种操盘手册"系列撰写单个章节/小节。面向投资小白和散户,每次写一小节。输入小节标题和参考信息,输出图文并茂(含SVG插图)的Markdown文件,保存到项目markdown/目录。触发条件:用户提到"写操盘手册"、"写一节"、"写章节"、"散户操盘"、"金融工具讲解"、"写投资小白教程"、"帮我写操盘手册的XX章节",或提供了一个金融品种/操盘主题名称并希望生成教学内容。即使用户只说"帮我写黄金操盘那一章"或"可转债怎么讲给小白听",也应使用本skill。.

digoal/blog · 185 tokens

multi-expert-analyzer

针对通用问题进行多领域专家联合分析, 综合稿产生前必经 fact-checker 与 red-team 两道独立校验。适用场景: 用户提出跨领域或不确定领域的复杂问题, 需要从多个专家角度分别搜证并相互校验后综合成文, 例如该不该买房、该不该跳槽、是否进入某个赛道等。触发关键词: 多角度分析、专家分析、综合分析、多视角、跨领域分析、从不同角度看、深度分析。问题只属于单一明确领域时, 优先使用该领域的专门 skill, 例如纯财务用 finance-core-analysis、纯技术用 software-architect。输出 (全部 markdown 保存到当前项目 markdown/ 目录): (1) 每位专家的中间分析稿…

digoal/blog · 292 tokens

retail-trading-manual-writer

Write and save Chinese beginner-friendly paid manual subsections for "全品种操盘手册", a retail-investor education/subscription product covering the full 17-chapter + appendix outline from digoal's 2026-05-28 article. Use when the user provides a subsection title or asks to continue/complete the manual for 投资小白/散户…

digoal/blog · 140 tokens