tdx2db: Instructions file for Codex

AGENTS.md

tdx2db AGENTS.md is an instructions file for Codex, OpenCode from xbfighting/tdx2db. It costs 2,222 tokens per session, scanned A, original, MIT.

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

Written for Codex and OpenCode: the file is AGENTS.md. Also seen: mentions CLAUDE.md; mentions AGENTS.md.

This is xbfighting/tdx2db's own configuration. It tells Codex and OpenCode 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/AGENTS.md
Clone the repo
git clone --depth 1 https://github.com/xbfighting/tdx2db

Made for: Codex, OpenCode.

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 AGENTS.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/xbfighting/tdx2db/agents-md/github.svg)](https://agentmods.dev/instructions/xbfighting/tdx2db/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/xbfighting/tdx2db/agents-md"><img src="https://agentmods.dev/badge/instructions/xbfighting/tdx2db/agents-md/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 AGENTS.md

Your own site · 80×15
<a href="https://agentmods.dev/instructions/xbfighting/tdx2db/agents-md"><img src="https://agentmods.dev/badge/instructions/xbfighting/tdx2db/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
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. A grade says what 26 rules found in the file — not that it is safe.
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.02222 $0.02222
Opus 5.5 $0.00889 $0.00889
Sonnet 5.5 $0.00444 $0.00444
Haiku 4.5 $0.00222 $0.00222

Measured 2mo ago against content hash 4203d683fb9d, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 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.

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.md 与 CONTRIBUTING.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. 2mo 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 (177 stars, last pushed 1mo ago), licensed MIT. It adds 2,222 tokens to every session, about $0.0089 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 AGENTS.md compared with instructions from other repositories

tdx2db AGENTS.md next to 6 instructions from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
tdx2db AGENTS.mdxbfighting/tdx2dbInstructions file1771mo agoMITA2,222Codex, OpenCode
vscode buildNext.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA9,719GitHub Copilot
next.js AGENTS.mdvercel/next.jsInstructions file143ktodayMITA7,461Codex, OpenCode
langchain AGENTS.mdlangchain-ai/langchainInstructions file149ktodayMITA4,680Codex, OpenCode
vscode oss-third-party-notices.instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA5,516GitHub Copilot
vscode copilot-instructions.mdmicrosoft/vscodeInstructions file195ktodayMITA3,093GitHub Copilot
deepseek-harness AGENTS.mddeepseek-ai/deepseek-harnessInstructions file275k2d agoMITA4,313Codex, OpenCode