tdx2db: Skill for Claude Code

.claude/skills/tdx2db-query/SKILL.md

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.

This is xbfighting/tdx2db's own configuration. It tells Claude Code how to work on tdx2db itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything tdx2db configures →

Reuse

Borrowing it

Nothing to install: this file belongs to xbfighting/tdx2db. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/xbfighting/tdx2db/master/.claude/skills/tdx2db-query/SKILL.md
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/github.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/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.

agentmods 80×15 button for tdx2db-query

Your own site · 80×15
<a href="https://agentmods.dev/skills/xbfighting/tdx2db/tdx2db-query"><img src="https://agentmods.dev/badge/skills/xbfighting/tdx2db/tdx2db-query.svg" alt="Reviewed on agentmods" width="80" 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. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
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.5 $0.00022 $0.00625
Sonnet 5.5 $0.00011 $0.00313
Haiku 4.5 $0.00006 $0.00156

Measured 2mo ago against content hash cf71bccd3686, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 2mo 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. 2mo 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 (177 stars, last pushed 1mo ago), licensed MIT. It adds 55 tokens to every session and 1,563 once invoked, about $0.0002 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.

Related

tdx2db-query compared with skills from other repositories

tdx2db-query next to 6 skills from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
tdx2db-queryxbfighting/tdx2dbSkill1771mo agoMITA55Claude Code
accounting-software-selectionsickn33/agentic-awesome-skillsSkill49ktodayMITA37Claude Code
accounting-audit-system-buildersickn33/agentic-awesome-skillsSkill49ktodayMITA41Claude Code
erp-sqlmicrosoft/Dataverse-skillsSkill255todayMITA69Claude Code
trading-manual-writerdigoal/blogSkill8.6k3d agoGPL-2.0A185Claude Code, Codex
multi-expert-analyzerdigoal/blogSkill8.6k3d agoGPL-2.0A292Codex
retail-trading-manual-writerdigoal/blogSkill8.6k3d agoGPL-2.0A140Codex