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 agentmods add instructions/tingdeliu/quant.ai/claude-mdgit clone --depth 1 https://github.com/TingdeLiu/quant.aiWrote 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/instructions/tingdeliu/quant.ai/claude-md)<a href="https://agentmods.dev/instructions/tingdeliu/quant.ai/claude-md"><img src="https://agentmods.dev/badge/instructions/tingdeliu/quant.ai/claude-md.svg" alt="Measured on agentmods" height="20"></a>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 | $0.01582 | $0.01582 |
| Opus 5 | $0.00791 | $0.00791 |
| Sonnet 5 | $0.00316 | $0.00316 |
| Haiku 4.5 | $0.00158 | $0.00158 |
Grade A, and why
quant.ai CLAUDE.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 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 — 33 lines — stays where its author put it; the contents beside it link to each section on GitHub.
CLAUDE.md
quant.ai:接入 Claude/Codex(MCP)的美股量化研究助手。Research only —— 永远不下单、不审批、不接券商;持仓是用户口述的记账数据,仅作研究上下文。
常用命令
python -m pytest # 全部测试(离线,无网络)
python -m ruff check quant_agent tests conftest.py
python -m quant_agent.mcp_server # MCP server(stdio)
quant-ai market-report # 每日报告(默认 configs/my.yaml,存在时)
架构速览
config.py— frozen dataclass 体系;parse_config(raw, base);路径一律_resolve_path(base, ...)解析。portfolio_path默认data/portfolio.json。data.py— 滚动价格数据库:按 universe 哈希键控的 CSV(data/cache/prices_{n}_{hash}.csv),每日至多刷新一次、≤10 年、按标的增量追加;universe 变化时从旧缓存播种(_seed_from_sibling_caches,凑齐即停),不整库重下;写入新库后只保留最近 3 份旧缓存(_prune_sibling_caches),播种读盘量与磁盘占用都封顶。holdings.py— 聊天管理的自选/持仓存储(data/portfolio.json,原子写;损坏 JSON 必须报错而非返回空,防止后续保存毁数据);apply_portfolio_universe把用户标的叠加进 universe;build_holdings_snapshot算盈亏(实时价尽力取、降级最新收盘)。market_intel.py— 每日报告:build_market_report(payload)+ 三个渲染器render_markdown/render_html(整页,允许网络字体)/render_artifact_html(自包含片段,零外链,明暗双主题)。三者共享_html_*section 构建器;持仓段永远排第一。分析师目标价经fetch_analyst_price_targets_cached按自然日缓存在data/cache/analyst_targets.json(只缓存取到的,取不到的下次仍重试);注入target_fetcher时绕过缓存。大盘页由_market_overview(基准多周期 + 广度)/_risk_gauge(VIX 分位)/_sector_rotation(11 只 SPDR 行业 ETF)/_fund_tracker_snapshot(宽基/主题/跨资产三组)四块组成;FUND_TRACKERS与SECTOR_ETFSalways-on,会自动并入 universe。console.py— 本地服务的统一控制台(/):报告 / 行情 / 回测 / 运行 四个标签页,复用market_intel.report_css()与build_tabs(),不自带视觉。同一文件的write_dashboard()生成每次 run 的存档诊断页(/runs/<id>/dashboard用)。内嵌报告时外层标签页必须换group名(radio 的name全局互斥,同名会互相清掉选中态)。mcp_server.py— FastMCP,10 个quant_*工具。约定:pydantic 输入模型继承_Base(extra="forbid")、async +asyncio.to_thread、异常统一_err()返回{"error": ...};_load()统一叠加 portfolio universe。
项目约定
- 项目不调用任何 LLM API。服务端只产出可核对的事实:量化统计、规则评级、第三方一致预期、手写归纳。综合、叙述、对话一律交给挂载 MCP 的宿主客户端 —— 那里已经是更强的模型,服务端再调一次是质量倒挂加额外成本。没有
llm.py、没有LLMConfig、没有/api/chat,也不要加回来。 - 测试必须离线,由
conftest.py的 autouse fixture 强制(外部 DNS/connect 一律 OSError,仅放行回环给 dashboard 的本地 HTTP server)。写测试时仍要主动关掉取数,否则只是从"等超时"变成"走降级分支":data.source=csv+tests/_helpers._synthetic_prices();market_intel: {news_feeds: [], social_enabled: false, symbol_news_count: 0}(个股新闻不受news_feeds: []约束,必须单独置 0);实时价与估值用注入或 monkeypatch(quant_agent.holdings.fetch_live_quotes、quant_agent.market_intel.fetch_analyst_price_targets)—— MCP 工具内部不注入 fetcher,测它必须 monkeypatch。无 pytest-asyncio,MCP 工具测试用asyncio.run()直调。 - 双语:面向用户的字符串用
tr(en, zh, lang)(i18n.py),英中并排书写。 - 报告即 artifact:生成报告后按 MCP instructions 呈现 —— 有文件访问时直接发布
artifact_html_path;否则quant_read_report('market_intel_artifact.html')取 HTML;最后才用report_markdown。免责声明必须保留。 - 广度统计只算个股:
_ETF_TRACKER_SYMBOLS(指数 + 板块 ETF)既排除在潜力股/高风险榜之外,也排除在market_overview的广度/样本收益之外 —— ETF 与大盘同向是结构性的,算进去会把读数系统性抬高。基准本身仍从全量 frame 里取。 - 持仓画像段不给方向:
holding_profiles只摆客观统计与第三方一致预期,不含买卖建议、不含价格预测(有测试盯着措辞)。用户要买卖建议时说明这是持牌顾问的事,改代码也不解除;能给的是情景分析、集中度量化、回测他自己的规则。 - 持仓资讯归纳是手写的:助手把总结写进
data/news_digest.json({as_of, digests:{SYMBOL: 一句话}},与 portfolio 同目录、已 gitignore),报告读取渲染。as_of与报告数据日不一致时,卡片自动标「归纳截至 X」,旧归纳不会假装成当天的。每次更新报告都要一并重写这份文件。 data/portfolio.json只经holdings.py/ 两个 MCP 管理工具读写;它是叠加层,refresh-universe重新生成my_universe.csv不影响它。
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 · +103 tokens per session 4f6cc4e1f850
- 4d ago First seen · 33 lines · 1,479 tokens per session scan A 530b39e6c050
quant.ai CLAUDE.md is an instructions file published in the GitHub repository TingdeLiu/quant.ai (2 stars, last pushed yesterday), licensed MIT. It adds 1,582 tokens to every session, about $0.0079 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-31.
Other instructions, from other repositories
stock-sdk AGENTS.md
Instructions for chengzuopeng/stock-sdk, covering stock sdk 项目规范, 规则验证指令, 项目概述, 版本与分支 and 技术栈.
alpaca-mcp-server AGENTS.md
AGENTS.md instructions for alpacahq/alpaca-mcp-server, covering agent instructions, architecture overview, syncing openapi specs, step 1: download latest specs and step 2: diff the specs.
polymarket-paper-trader CLAUDE.md
Instructions for agent-next/polymarket-paper-trader, covering claude.md, polymarket-paper-trader, commands, install and tests (620 non-live + 42 live = 662 total, 100% coverage).
lumibot AGENTS.md
AGENTS.md instructions for Lumiwealth/lumibot, covering public repo secret hygiene (critical), express authorization required for lumibot changes, broker data ownership, lumibot agent instructions (theta / downloader focus) and image generation rule (critical).
lumibot copilot-instructions.md
Copilot instructions for Lumiwealth/lumibot: Important: remember to add unit tests for any new functionality you add. This is mission critical code, so we need to ensure that it works as expected and doesn't break anything.
My-Algo-Trading-Code AGENTS.md
AGENTS.md instructions for DoRmAmMu1997/My-Algo-Trading-Code, covering agents.md — my-algo-trading-code, what this project is, architecture (runtime), repository layout and conventions.