dsh-us-stocks

toolsinstall failsnpmMIT

US stock quotes, price history, financial statements, analyst consensus and news via yahoo-finance2.

下载量 / Downloads
1,014
测试时间 / Tested
2026-11-06
DSH 版本 / Version
0.2.2-rc.1

Install

dsh plugin --profile web add dsh-us-stocks

Sandbox test results

StageResult
1 install✗
2 list—
3 mount—
4 boot—
First error
dsh: initialized profile web at /home/node/.dsh/profiles/web

Four stages run in an isolated sandbox: install (network on) → list → mount → boot (last three with no network).

README

dsh-us-stocks

[English](README.md) | 中文

<p align="center">

<img src="./assets/readme/cover.png" alt="dsh-us-stocks 封面" width="300">

</p>

给 DeepSeek Harness 用的美股行情数据插件,基于 yahoo-finance2。

提供行情、历史 K 线、财务报表、分析师共识、新闻、股东结构六个专用工具,无需模型自行解析网页。

<p align="center">

<img src="./assets/readme/overview.zh.svg" alt="六个工具覆盖行情、K 线、财报、分析师、新闻与股东。同一 AAPL 任务:未装载 31 次调用 / 213 秒,装载后 5 次 / 33 秒。" width="960">

</p>

效果对比

下表为同一任务在装载与未装载本插件两种条件下的实测结果,模型与运行环境一致。任务内容:AAPL 的现价、近三个月走势、最近几个季度财务、分析师评级和近期新闻。

· 未装载本插件 · 装载本插件

步骤 · 14 步 · 2 步

工具调用 · 31 次 · 5 次

整体耗时 · 213.5 秒 · 33.2 秒

调用构成 · 16 次 web_search、15 次 bash · 任务需要的每个工具各一次

在缺少行情数据工具的情况下,模型只能依靠网页搜索与 shell 命令,逐个页面抓取并解析。其余 33 秒主要为模型推理耗时,不在本插件的作用范围内;数据获取本身占 2.6 秒。

<details>

<summary>验收基准 — AAPL</summary>

Acceptance benchmark — AAPL

  ✅ get_quote           2016ms  305.93 USD (+0.2195%), mcap 4464.80B
  ✅ get_history          446ms  62 bars 2026-05-18..2026-08-14
  ✅ get_financials      2181ms  4 income / 4 balance / 4 cash-flow periods
  ✅ get_analyst_view    2492ms  buy from 41 analysts, target 322.2844
  ✅ get_news             632ms  8 headlines, latest "Google is using a $29 gadget to tighten its gri…"
  ✅ get_ownership       3135ms  66.48% institutional across 7709 filers, insiders net 35206 shares over 6m

  tool calls        6
  wall clock        3.14s (concurrent)
  payload           26.2 KiB across 6 results

</details>

可用 npm run benchmark 自行复现,亦可指定其他标的:npm run benchmark -- TTMI。

安装

懒人版

直接对你的 DeepSeek Harness 说:

安装一下这个插件:https://github.com/Realyujie/dsh-us-stocks

它会读这份 README 并自行执行安装命令。过程中会请求文件系统权限,因为 profile 目录在会话工作区之外。

手动安装

若 dsh 已在 PATH 中:

dsh plugin --profile web add dsh-us-stocks

若不在——通过 npx 启动 Harness 时即属此种情况,因为可执行文件只存在于 npx 缓存中——改用 npx 调用:

npx @deepseek-ai/dsh plugin --profile web add dsh-us-stocks

下文所有命令同理:把 dsh 换成 npx @deepseek-ai/dsh 前缀即可;或用 npm install -g @deepseek-ai/dsh 全局安装一次,之后统一使用简写形式。

后续更新:

dsh plugin --profile web update dsh-us-stocks

更新后需重启 profile——插件是在启动时组装插件树的过程中解析的。

本地开发则让 profile 指向检出目录,改动在 npm run build 并重启后生效:

dsh plugin --profile web add link:/absolute/path/to/dsh-us-stocks

dsh plugin 是转发给 profile 目录下的 pnpm,并会同步维护 profile 的 dsh.profile.bundles 列表,不需要手动注册。

本插件注册服务端的 agent 工具,同时附带一个很小的浏览器半边,用于绘制 get_history 一节所述的 K 线图;在 TUI 或 headless profile 下该半边不存在,六个工具照常可用。

工具

工具 · 返回内容

get_quote · 最新价、涨跌、日内区间、成交量、市值、市盈率、每股收益、每股净资产、股息率、52 周区间、均线、上次和下次财报日。ETF 与共同基金另有费率、规模、分类、资产配置、滚动收益与前十大持仓

get_history · 日/周/月 K 线 OHLCV 及复权收盘价,附窗口内的分红与拆股,纯结构化数据

get_financials · 利润表、资产负债表、现金流量表科目,季度或年度,含报表货币与 TTM 比率

get_analyst_view · 共识评级、逐月买入/持有/卖出家数、目标价、EPS 与营收预期、近期券商评级变动、EPS 超预期记录

get_news · 近期新闻标题,含发布方、时间和链接

get_ownership · 内部人与机构持股比例、最大机构与基金股东(含季度仓位变动)、内部人近六个月买卖汇总

get_quote

参数 · 类型 · 说明

ticker · string,必填 · 例如 AAPL、BRK-B

财报日期拆成 last_earnings_date 和 next_earnings_date 两个字段返回,因为上游将二者合并在同一字段中。next_earnings_date_is_estimate 用于标记该日期为按财报节奏推算所得,而非公司正式确认。在十个标的的抽样中约有一半为预估值,建议读取该字段确认,不宜直接假定。

currency 是股票的交易货币,financial_currency 是公司的报表货币。ADR 的这两者不一致,而 get_financials 中的数字仅以后者计价。

上游虽然返回了分析师评级,本工具有意不包含该字段。共识评级与目标价统一由 get_analyst_view 提供,使仅需行情数据的调用方不会一并收到投资建议。

ETF 与共同基金会额外返回 fund_expense_ratio_percent(并附同类均值)、fund_total_assets、fund_category、fund_family、fund_asset_allocation_percent、fund_trailing_returns_percent 和 fund_top_holdings。这些来自第二次上游请求,仅在行情确认该标的为基金后才发出,个股不承担任何额外开销;基金的一次查询耗时约为个股的三倍。该请求失败时仍返回行情本体,并附一条 warning。

关于基金字段有三点写在响应内的 fund_notes 里,而不只写在这里——因为读这些数字的对象读的是响应:

  • 对基金而言,trailing_pe、price_to_book、book_value_per_share、eps_trailing_twelve_months 是成分股的加权聚合值,不是某一家公司的数据。不加标注时会被当成对该基金的估值判断。
  • 费率按上游原样透传,偶有错误——实测 FXAIX 报 0.42%,实际为 0.015%。
  • fund_trailing_returns_percent 沿用上游的混合口径:ytd 到 one_year 是区间收益,而 three_year_annualized、five_year_annualized、ten_year_annualized 是年化值。字段名直接标明口径 —— 五年期这两种口径能差出四倍。
  • fund_top_holdings 受上游限制最多 10 条,因此以 fund_top_holdings_coverage_percent 说明这些持仓合计占基金的比例。实测该比例从 VXUS 的 14% 到 XLE 的 73% 不等,无法据此计算两只基金之间的重叠度。债券、商品与反向基金完全不返回持仓,此时该字段直接缺失而非为空。

get_history

参数 · 类型 · 说明

ticker · string,必填 ·

range · 枚举 · 5d 1mo 3mo 6mo 1y 2y 5y 10y max,默认 1y

start_date / end_date · string · yyyy-MM-dd,指定 start_date 时覆盖 range

interval · 枚举 · 1h 1d 1wk 1mo,默认 1d。单次调用 1h 约覆盖 5 周,1d 约 2 年,1wk 约 8 年,1mo 约 35 年

limit · 整数 · 保留最近 N 根,1–500。默认返回窗口内全部

K 线按时间从旧到新排列。1d/1wk/1mo 的 date 是 yyyy-MM-dd;1h 则是完整 ISO 时间戳——这个粒度下同一天会有多根 K 线,若只保留日期会让它们的标签全部相同。

interval: "1h" 另受上游限制,历史最多回溯约 730 天,与请求窗口大小无关。range 或 start_date 超出这个范围会直接返回 invalid_argument,而不是其他档位那种"已裁剪"的警告——因为 Yahoo 对此是直接拒绝整个请求,而非退而求其次给一部分数据。

在 Web UI 中,该调用会渲染成 K 线图——蜡烛实体、上下影线、成交量副图、价格网格线,鼠标悬停显示当根 OHLC——所用数据与模型收到的完全是同一份,因此图与数字不会出现分

…(truncated)

Rendered from the README published on npm. Formatted only, not edited.

Versions

Published on npm::3,最后更新 2026-08-16

Links

GitHub · Homepage · npm

Same category