quant.ai AGENTS.md

Development instructions for a research-only assistant for US stock-market analysis that connects to Codex and MCP. MCP is a standard way for an agent to use external tools.

In plain words
What is it for?
Maintaining price data, tracking user-provided holdings, calculating performance, and producing daily market reports in Markdown or HTML.
Why use it?
They describe the project’s structure, commands, data handling, and safety boundary, including that it must not place trades.

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/tingdeliu/quant.ai/agents-md
Clone the repo
git clone --depth 1 https://github.com/TingdeLiu/quant.ai

Made for: Codex, OpenCode.

Per session 844 This file is loaded in full into every session.
When invoked 844 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.00844 $0.00844
Opus 5 $0.00422 $0.00422
Sonnet 5 $0.00169 $0.00169
Haiku 4.5 $0.00084 $0.00084

Measured yesterday against content hash 7a804da8ab62, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

quant.ai 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 yesterday.

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 · 29 lines

How it starts

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

AGENTS.md

quant.ai:接入 Codex/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),不整库重下。
  • 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 构建器;持仓段永远排第一。
  • mcp_server.py — FastMCP,10 个 quant_* 工具。约定:pydantic 输入模型继承 _Baseextra="forbid")、async + asyncio.to_thread、异常统一 _err() 返回 {"error": ...}_load() 统一叠加 portfolio universe。

项目约定

  • 项目不调用任何 LLM API。服务端只产出可核对的事实:量化统计、规则评级、第三方一致预期、手写归纳。综合、叙述、对话交给挂载 MCP 的宿主客户端。没有 llm.py、没有 LLMConfig、没有 /api/chat,也不要加回来。
  • 测试必须离线data.source=csv + tests/_helpers._synthetic_prices()market_intel: {news_feeds: [], social_enabled: false, symbol_news_count: 0};实时价用注入/monkeypatch(quant_agent.holdings.fetch_live_quotes)。无 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。免责声明必须保留。
  • data/portfolio.json 只经 holdings.py / 两个 MCP 管理工具读写;它是叠加层,refresh-universe 重新生成 my_universe.csv 不影响它。

Read the full file on GitHub · 29 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. yesterday First seen · 29 lines · 844 tokens per session scan A 7a804da8ab62

Subscribe to this mod's changes

quant.ai AGENTS.md is an instructions file published in the GitHub repository TingdeLiu/quant.ai (2 stars, last pushed 18d ago), licensed MIT. It adds 844 tokens to every session, about $0.0042 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.