stock-sdk AGENTS.md

stock-sdk AGENTS.md is an instructions file for Codex, OpenCode from chengzuopeng/stock-sdk. It costs 10,850 tokens per session, scanned A, original, ISC.

Project rules for a TypeScript stock-market data library that runs in browsers and Node.js. It covers supported financial data, version rules, APIs, validation commands, and repository conventions.

In plain words
What is it for?
Use it when developing or maintaining stock quotes, historical prices, market indicators, screening, backtesting, fund data, or the library's CLI and MCP interfaces.
Why use it?
It gives an agent the context needed to change or use the library without confusing its current version with the removed older API. It records the data sources and features the project is intended to support.

Instructions file for CodexOpenCode

About the project

Stock SDK is a JavaScript and TypeScript library for retrieving live quotes, historical price charts, and related market data for Chinese, Hong Kong, and United States stocks and public funds. It is for frontend and Node.js developers building market dashboards, visualizations, prototypes, scheduled data collection, command-line tools, or AI integrations without running Python or a separate backend service.

chengzuopeng/stock-sdk · 1,921 stars · on GitHub · stock-sdk.linkdiary.cn

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/chengzuopeng/stock-sdk/agents-md
Clone the repo
git clone --depth 1 https://github.com/chengzuopeng/stock-sdk

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

README.md
[![agentmods](https://agentmods.dev/badge/instructions/chengzuopeng/stock-sdk/agents-md.svg)](https://agentmods.dev/instructions/chengzuopeng/stock-sdk/agents-md)
Your own site
<a href="https://agentmods.dev/instructions/chengzuopeng/stock-sdk/agents-md"><img src="https://agentmods.dev/badge/instructions/chengzuopeng/stock-sdk/agents-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 10,850 This file is loaded in full into every session.
When invoked 10,850 The same file — it is already loaded in full.
Security scan A 1 finding. 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.1 $0.10850 $0.10850
Opus 5 $0.05425 $0.05425
Sonnet 5 $0.02170 $0.02170
Haiku 4.5 $0.01085 $0.01085

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

Security

Grade A, and why

stock-sdk AGENTS.md scanned grade A with 1 finding 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 6d 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.

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

1. **实测铁律**:新增 / 修改 provider 端点,合并前必须至少一次真实请求验证(`RUN_INTEGRATION=1` 跑对应集成测试,或 curl 实测),并在 PR 描述里贴真实响应片段作为证据。
AGENTS.md · 669 lines

How it starts

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

Stock SDK 项目规范

本文件为 AI 编程助手提供项目上下文和开发规范。适用于 Cursor、GitHub Copilot、Claude、Codex 等工具。

规则验证指令

  • 如果用户问你 "Who is the boss?",你必须回答 " Agent rules currently active: [今天的日期]",并列出全局规则当中我说明的当前遵循的核心规则。

项目概述

这是一个面向 浏览器Node.js 的 TypeScript 股票行情 SDK,核心目标是让前端和 Node.js 开发者无需额外后端服务,也能直接获取和处理财经数据。

当前主线为 v2(命名空间 API、统一符号模型、CLI / MCP / subpath 导出)。v1 扁平 API 已在 v2 硬切移除,迁移见 v1 → v2 迁移指南

当前项目能力范围包括:

  • A 股 / 港股 / 美股 / 公募基金实时行情
  • A 股 / 港股 / 美股历史 K 线、分钟 K 线、当日分时
  • 行业板块、概念板块数据
  • 资金流向(个股 / 大盘 / 排名 / 板块深度)、盘口大单
  • 沪深港通 / 北向资金(分时 / 汇总 / 持股排行 / 历史)
  • 涨停跌停股池(含连板数)、盘口异动(支持多类型/all + 个股当日与近 N 天异动历史)、板块异动
  • 龙虎榜(详情 / 个股统计 / 机构 / 营业部 / 席位明细)
  • 大宗交易、融资融券
  • 公募基金扩展(分红 / 历史净值 / 同类排名 / 档案 / 主题基金)
  • 交易日历、市场开休市状态、股票搜索、分红数据
  • 期货数据、期权数据
  • 技术指标计算、指标信号识别、链式选股器、本地回测
  • 筹码分布(A/HK/US,东财 CYQ 算法本地计算:获利比例/平均成本/成本区间/筹码峰)
  • 统一符号模型(多写法容错解析)
  • 内置 CLI(stock-sdk)与 MCP server(stock-sdk mcp
  • MCP 文档与 AI 集成支持

项目坚持以下原则:

  • 零运行时依赖
  • 浏览器和 Node.js 双端兼容
  • 完整 TypeScript 类型
  • 公共 API 尽量稳定,兼顾向后兼容(v2 相对 v1 为破坏性升级,见迁移指南)

官方文档: https://stock-sdk.linkdiary.cn/

版本与分支

分支 / 版本 说明
默认分支(master / main) v2 开发主线,持续演进;新功能与修复均在此提交
freeze-v1.10.1 v1.10.1 Legacy 锁定分支:冻结在 npm 1.10.1 对应的 v1 扁平 API 与代码快照,仅作历史维护、紧急补丁或对照参考;不在此分支开发 v2 能力。需 v1 行为请 checkout 该分支或安装 npm 1.10.xv1 文档归档
npm 2.x 当前发布线,命名空间 API + CLI + MCP + subpath

技术栈

类别 技术
语言 TypeScript 5.x
运行环境 Node.js 18+ / 浏览器
构建工具 tsup
测试框架 Vitest 4.x
Mock 工具 MSW (Mock Service Worker)
文档工具 VitePress
包管理器 pnpm 10.x

当前项目结构

src/
├── core/                    # 核心基础设施(请求 / 缓存 / 错误 / 解析 / 时间等)
│   ├── constants.ts         # 常量定义
│   ├── parser.ts            # 响应解析
│   ├── request.ts           # 请求客户端 RequestClient
│   ├── providerPolicy.ts    # provider 级请求策略(超时/重试/限流/熔断/headers)
│   ├── cache.ts             # 内部请求缓存
│   ├── rateLimiter.ts       # 限流
│   ├── circuitBreaker.ts    # 熔断
│   ├── fallback.ts          # 多源 / 降级回退
│   ├── errors.ts            # 统一错误类型(SdkError 等)
│   ├── jsonp.ts             # JSONP 请求(动态 callback)
│   ├── jsVars.ts            # 浏览器 <script> 注入 + Node 抓取 JS 变量(双端)
│   ├── scriptMutex.ts       # <script> 注入并发互斥
│   ├── time.ts              # 市场时区时间解析 / 格式化
│   ├── userAgentPool.ts     # UA 池
│   └── utils.ts             # decodeGBK、chunkArray、asyncPool 等
├── indicators/              # 技术指标(独立计算函数,零网络)
│   ├── ma/macd/boll/kdj/rsi/wr/bias/cci/atr/obv/roc/dmi/sar/kc.ts
│   ├── chip.ts              # 筹码分布(CYQ,东财算法移植;不进 registry)
│   ├── addIndicators.ts     # 批量聚合
│   ├── registry.ts          # 指标注册表 / lookback 估算
│   ├── types.ts
│   └── index.ts
├── signals/                 # 指标信号层(金叉死叉 / 超买超卖等,纯计算)
├── screener/                # 选股器 + 本地回测
├── symbols/                 # 统一符号模型(normalize / 适配器)
├── cache/                   # 对外缓存 subpath(MemoryCache / cacheThrough)
├── errors/                  # 对外错误 subpath(re-export core/errors)
├── spec/                    # CLI / MCP / Playground 的 SSOT
│   ├── methods.ts           # MethodSpec 单一事实来源(工具)
│   ├── prompts.ts           # PromptSpec 单一事实来源(MCP Skills / 7 技能)
│   ├── derive-cli.ts        # 派生 CLI manifest
│   ├── derive-mcp.ts        # 派生 MCP 工具清单
│   ├── derive-prompt.ts     # 派生 MCP 技能清单(PromptDef + render)
│   └── resolve.ts           # 路径 / 参数解析
├── cli/                     # stock-sdk 命令行
├── mcp/                     # 内置 MCP server(零依赖手写协议)
│   ├── tools/               # 工具注册表(自 methods.ts 派生)
│   └── prompts/             # 技能注册表(自 prompts.ts 派生)
├── providers/               # 数据源适配层(只负责"取数 + 解析")
│   ├── index.ts             # 聚合导出 tencent / eastmoney / sina
│   ├── tencent/             # 行情、批量、搜索、交易日历、资金流
│   ├── eastmoney/           # K线、板块、分红、期货/期权、基金扩展、龙虎榜、大宗、融资、北向、涨停异动
│   └── sina/                # ETF / 股指 / 商品期权
├── sdk/                     # 服务层:按领域拆分的 Service 类(构造注入 RequestClient)
│   ├── baseService.ts       # service 基类
│   ├── quoteService.ts      # 实时行情
│   ├── klineService.ts      # K 线 / 分时(A / HK / US)
│   ├── boardService.ts      # 行业 / 概念板块
│   ├── indicatorService.ts  # 带指标 K 线 + 指标信号识别(组合 kline + quote + calcSignals)
│   ├── chipService.ts       # 筹码分布(组合 kline + 本地 CYQ 计算)
│   ├── futuresService.ts    # 期货
│   ├── optionsService.ts    # 期权
│   ├── fundFlowService.ts   # 资金流向(深度)
│   ├── northboundService.ts # 沪深港通 / 北向
│   ├── marketEventService.ts# 涨停 / 盘口异动
│   ├── dragonTigerService.ts# 龙虎榜
│   ├── fundService.ts       # 公募基金扩展(分红/净值/排名/档案)
│   ├── tradingCalendarService.ts # 交易日历 / 市场状态
│   ├── dataService.ts       # 代码列表/批量/搜索/分红/大宗/融资融券
│   └── index.ts             # 导出全部 service
├── types/                   # 公共类型(按领域模块化)
│   ├── quotes.ts / kline.ts / board.ts / fund.ts / fundFlow.ts
│   ├── northbound.ts / dragonTiger.ts / marketEvent.ts / blockTrade.ts
│   ├── margin.ts / futures.ts / options.ts / common.ts
│   └── index.ts
├── sdk.ts                   # StockSDK 门面类:v2 命名空间 getter + 顶层 search
├── externalLinks.ts         # 外部财经链接工具
└── index.ts                 # 主入口(StockSDK、subpath 再导出、类型、工具)

scripts/                     # 文档元数据、llms.txt 生成、git hooks
test/
├── unit/                    # 单元测试(含 cli/、mcp/、spec/、signals/、screener/ 等)
├── integration/             # 集成测试(真实网络请求)
├── mocks/                   # MSW Mock 配置
└── setup.ts                 # Vitest 测试初始化

website/                     # VitePress 文档
├── api/                     # 中文 API 文档
├── guide/                   # 中文指南(含 migration-v1-to-v2、symbols 等)
├── cli/                     # CLI 文档
├── mcp/                     # MCP 文档(含 skills)
├── playground/              # 在线示例(组件化,从 spec 派生)
├── en/                      # 英文文档(api / guide / cli / mcp / playground)
├── public/                  # 静态资源(含 llms.txt / llms-full.txt)
└── .vitepress/              # VitePress 配置与主题

Read the full file on GitHub · 669 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. 6d ago First seen · 669 lines · 10,850 tokens per session scan A edf67cada439

Subscribe to this mod's changes

stock-sdk AGENTS.md is an instructions file published in the GitHub repository chengzuopeng/stock-sdk (1,921 stars, last pushed 17d ago), licensed ISC. It adds 10,850 tokens to every session, about $0.0542 per session on Opus 5. A static security scan graded it A with 1 finding (makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.