tdx2db AGENTS.md

An agent guide for tdx2db, a tool that reads stock data from the TongdaXin market application and writes it to PostgreSQL, MySQL, or SQLite for SQL queries.

In plain words
What is it for?
Use it to sync Chinese stock prices, inspect database coverage, update stock lists and sector relationships, and write SQL queries against daily or minute-level market data.
Why use it?
It explains the database tables, configuration, commands, and checks needed to sync data reliably. It also warns that a successful command exit does not by itself prove that data was written.

Instructions file for CodexOpenCode

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 instructions/xbfighting/tdx2db/agents-md
Clone the repo
git clone --depth 1 https://github.com/xbfighting/tdx2db

Made for: Codex, OpenCode.

Per session 2,222 This file is loaded in full into every session.
When invoked 2,222 The same file — it is already loaded in full.
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 $0.02222 $0.02222
Opus 5 $0.01111 $0.01111
Sonnet 5 $0.00444 $0.00444
Haiku 4.5 $0.00222 $0.00222

Measured 2d ago against content hash 4203d683fb9d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

tdx2db AGENTS.md 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 2d 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.

AGENTS.md · 117 lines

How it starts

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

AGENTS.md

面向 AI agent 的 tdx2db 使用指南。你(agent)在装有 tdx2db 的环境中同步、查询 A 股行情数据时,本文档是首要参考。贡献代码请另见 CLAUDE.mdCONTRIBUTING.md

这是什么

tdx2db 读取本地通达信(TDX)行情软件的数据文件,增量同步到 PostgreSQL / MySQL / SQLite。产出物是一个可直接 SQL 查询的行情数据库——你不需要通过 tdx2db 读数据,直接查库即可;tdx2db 只负责写入。

通达信盘后数据下载 → tdx2db sync → 数据库 ← 你的 SQL 查询

CLI 速查

tdx2db sync                  # 日常唯一命令:增量同步日线 + 5/15/30/60 分钟线
tdx2db status                # 只读:每表行数/覆盖股票数/日期范围(不需要 TDX_PATH)
tdx2db status --json         # 机器可读,优先用这个
tdx2db stock-list --db-only  # 同步股票列表

配置经 .env(从当前工作目录向上逐级查找)或全局参数 --tdx-path / --db-type / --db-name 等。密码只能放 .env,无命令行参数。退出码:0 成功,非 0 失败——但退出码 0 不代表数据写入成功,必须用 status 验证(见下"同步后验证")。

数据库 Schema

唯一约束 说明
daily_data (code, date) 日线 OHLCV + 11 条均线
minute{5,15,30,60}_data (code, datetime) 分钟线;15/30/60 由 5 分钟重采样
stock_info code 股票列表:真实名称、zgb/ltag 总股本/流通A股(万股)、capital_date/list_date
block_stock_relation (block_type, block_name, code) 板块-个股关系,全量快照;block_type ∈ 行业/概念/指数/地区/风格/特殊
  • 行情表通用列:code, market, datetime, date, open, high, low, close, volume, amount, ma5, ma10, ma13, ma21, ma34, ma55, ma60, ma89, ma144, ma233, ma250
  • 均线:ma13/21/34/55/89/144/233 是斐波那契窗口(缠论强弱分析主力),ma233 常被当作年线;上市天数不足窗口的行为 NULL
  • 周线/月线没有表,由日线 resample 得到
  • 收录范围:深市 000/001/002/300/301、沪市 60xxxx/688xxx;无北交所、ETF、指数

典型查询(内部项目验证过的形态)

-- 1. 单票日线区间 + 均线
SELECT date, open, high, low, close, volume, amount,
       ma5, ma13, ma21, ma34, ma55, ma89, ma144, ma233
FROM daily_data
WHERE code = '600036' AND date BETWEEN '2026-01-01' AND '2026-07-01'
ORDER BY date;

-- 2. 某日全市场截面(maN IS NOT NULL 兼作"数据成熟"哨兵,排除上市不足 N 日的新股)
SELECT code, close, ma5, ma13, ma233
FROM daily_data
WHERE date = '2026-07-03' AND ma233 IS NOT NULL;

-- 3. 最新交易日探测(加 ma5 条件确保当日指标已计算完成)
SELECT MAX(date) FROM daily_data WHERE ma5 IS NOT NULL;

-- 4. 按板块取成分(行业含一/二/三级;block_level=2 ≈ 通达信导出 CSV 的行业口径)
SELECT code FROM block_stock_relation
WHERE block_type = '行业' AND block_name = '煤炭开采';

SELECT DISTINCT block_name FROM block_stock_relation
WHERE block_type = '行业' AND block_level = 2;   -- 全部二级行业(板块强弱迭代口径)

-- 5. 按个股查板块归属
SELECT block_type, block_code, block_name FROM block_stock_relation
WHERE code = '000001';

-- 6. 换手率(%):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 = '000001' ORDER BY d.date DESC LIMIT 20;
-- 注意:股本为当前快照,股本变动点之前的历史换手率失真(精确历史需 gbbq)
-- list_date 上市日期可用于次新股过滤:WHERE s.list_date < CURRENT_DATE - 500

Read the full file on GitHub · 117 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. 2d ago First seen · 117 lines · 2,222 tokens per session scan A 4203d683fb9d

Subscribe to this mod's changes

tdx2db AGENTS.md is an instructions file published in the GitHub repository xbfighting/tdx2db (148 stars, last pushed 11d ago), licensed MIT. It adds 2,222 tokens to every session, about $0.0111 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 instructions, from other repositories

teamdynamix-mcp teamdynamix.instructions.md

Instructions for GitHub Copilot when operating against a TeamDynamix instance via the MCP server.

selfagency/teamdynamix-mcp · 822 tokens

teamdynamix-mcp copilot-instructions.md

Copilot instructions for selfagency/teamdynamix-mcp, covering github copilot instructions, project goals, mcp architecture rules, typescript standards and error handling rules.

selfagency/teamdynamix-mcp · 485 tokens

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 6,785 tokens

spec-kit AGENTS.md

AGENTS.md instructions for github/spec-kit, covering agents.md, about spec kit and specify, quickstart — add a new integration in 5 steps, integration architecture and integrationmanifest — file tracking.

github/spec-kit · 7,104 tokens

codex AGENTS.md

AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.

openai/codex · 5,182 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,345 tokens