ai_ths_moni_trading_mcp: Instructions file for Claude Code

CLAUDE.md

ai_ths_moni_trading_mcp CLAUDE.md is an instructions file for Claude Code from trading-a/ai_ths_moni_trading_mcp. It costs 2,254 tokens per session, scanned A, original, MIT.

Project instructions for a service that lets AI agents interact with the Tonghuashun stock-trading system through a logged-in browser. It describes the project structure, commands, tests, browser setup, and available account, order, deal, and market-order operations.

In plain words
What is it for?
Use it when working on this MCP service, running its Python tests or smoke checks, troubleshooting browser setup, or changing its account, order, deal, and cancellation tools.
Why use it?
It gives a coding agent the project-specific information needed to install dependencies, run tests, start the service, and understand its browser connection requirements.

Instructions file for Claude Code

Written for Claude Code: the file is CLAUDE.md. Also seen: mentions CLAUDE.md; mentions Claude Code.

This is trading-a/ai_ths_moni_trading_mcp's own configuration. It tells Claude Code how to work on ai_ths_moni_trading_mcp 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 ai_ths_moni_trading_mcp configures →

Reuse

Borrowing it

Nothing to install: this file belongs to trading-a/ai_ths_moni_trading_mcp. 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/trading-a/ai_ths_moni_trading_mcp/main/CLAUDE.md
Clone the repo
git clone --depth 1 https://github.com/trading-a/ai_ths_moni_trading_mcp

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 ai_ths_moni_trading_mcp CLAUDE.md

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

Your own site · 80×15
<a href="https://agentmods.dev/instructions/trading-a/ai_ths_moni_trading_mcp/claude-md"><img src="https://agentmods.dev/badge/instructions/trading-a/ai_ths_moni_trading_mcp/claude-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 2,254 This file is loaded in full into every session.
When invoked 2,254 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.02254 $0.02254
Opus 5 $0.01127 $0.01127
Sonnet 5 $0.00451 $0.00451
Haiku 4.5 $0.00225 $0.00225

Measured 11d ago against content hash b8b0eb135fa4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

ai_ths_moni_trading_mcp 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 11d 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.md · 165 lines

How it starts

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

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

项目概述

把同花顺交易系统封装成通用 stdio MCP 服务ths-stock-trading-mcp),供各类 AI Agent 调用。 浏览器由人工启动并登录,服务通过 Chrome 调试端口(9222)挂接现有浏览器操作页面,不启动 新浏览器、不存储凭证。提供 5 个工具:query_account_and_positions / query_deals / query_orders / place_order(仅市价)/ cancel_order

常用命令

环境全部用项目内 .venv(Windows 路径 .venv/Scripts/python.exe)。

# 安装依赖
.venv/Scripts/python.exe -m pip install -r requirements.txt

# 运行全部测试
.venv/Scripts/python.exe -m pytest -v
# 单个测试(pytest.ini 设了 asyncio_mode=auto,async 测试函数自动收集)
.venv/Scripts/python.exe -m pytest tests/test_tools_place_order.py::test_place_order_buy -v

# 启动 MCP 服务(stdio,等待客户端连接)
.venv/Scripts/python.exe server.py

# 真实浏览器端到端(需浏览器已登录)
PYTHONPATH=. .venv/Scripts/python.exe scripts/e2e.py
# MCP stdio 协议冒烟
PYTHONPATH=. .venv/Scripts/python.exe scripts/mcp_smoke.py

人工前置步骤:运行 启动浏览器.bat → 登录同花顺 → 进入交易页面(标题「同花顺虚拟交易所」)。 不满足时工具返回中文报错(见「浏览器前置」)。

架构

server.py       FastMCP(stdio) 入口,注册 5 个 async 工具(薄层)
ths/
  browser.py    CDP 挂接 9222 + 健康检查(未开/未找到页/未登录→三类错误)
  selectors.py  全部真实 DOM 选择器(唯一来源,页面改版只改这里)
  actions.py    页面导航(左侧菜单)、place_market_order、cancel_order、弹窗辅助
  parsers.py    表头驱动表格解析(thead th 为键)+ 账户(id 节点) 读取
  config.py     读取项目根 config.yaml(slow_ms 慢速观察模式)
  errors.py     ThsError / BrowserNotRunningError / TradingPageNotFoundError / NotLoggedInError
config.yaml     服务配置(cdp_endpoint / slow_ms / delays 下单撤单步骤延时)
.mcp.json       Claude Code 接入配置

核心设计:

  • 全链路 async:FastMCP 在 asyncio 事件循环执行 async 工具;Playwright Sync API 会抛 「It looks like you are using Playwright Sync API inside the asyncio loop」。因此 browser/actions/parsers 的页面操作与 server 工具一律 async(Playwright Async API)。 新增页面操作时必须 await,且不得引入 sync Playwright。
  • 选择器集中:真实页面 DOM 集中在 ths/selectors.py(如 table[name='qryChicang']#sjwtbuySubmit#promptWinContainer)。交易页 <meta charset="gbk">、面板经 AJAX 按需加载;市价委托的代码框填码后经联想列表点选加载行情并填充市价类型下拉 (页面自带联想因硬编码 http 地址被 https 混合内容拦截永不弹出,由我们注入 JSONP 数据自渲染列表后点击,见 actions._load_and_click_stock)。
  • 健康检查:每个工具先 browser.get_trading_page()——连不上 9222 / 找不到标题页 / 未登录(#topUser 无「你好」)→ 抛对应中文错误,不继续操作。
  • 下单/撤单:place 走「市价委托→买入/卖出→填码(延时 suggest_wait)→联想点选 股票→选『剩余撤销』→填数量→提交→ymprompt 确认弹窗→读结果弹窗」;cancel 走「撤单 面板→按委托号勾选 checkbox→点撤单→确认」。点选后先校验行情已刷新(股票名精确等于 期望名称 + 最新价为数字,防残留上一只行情误判),quote_timeout 超时则不点下单、 返回「下单失败:行情数据未加载…未提交委托」;其余 Playwright 超时统一转 ThsError("操作超时,请人工检查页面状态。")

Read the full file on GitHub · 165 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. 11d ago First seen · 165 lines · 2,254 tokens per session scan A b8b0eb135fa4

Subscribe to this mod's changes

ai_ths_moni_trading_mcp CLAUDE.md is an instructions file published in the GitHub repository trading-a/ai_ths_moni_trading_mcp (1 stars, last pushed 18d ago), licensed MIT. It adds 2,254 tokens to every session, about $0.0113 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.

Related

Other instructions, from other repositories

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,296 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,153 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

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,469 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).

microsoft/vscode · 5,001 tokens