pp-yahoo-finance

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Yahoo Finance — Printing Press CLI

Yahoo Finance — Printing Press CLI

Prerequisites: Install the CLI

前提条件:安装CLI

This skill drives the
yahoo-finance-pp-cli
binary. You must verify the CLI is installed before invoking any command from this skill. If it is missing, install it first:
  1. Install via the Printing Press installer:
    bash
    npx -y @mvanhorn/printing-press install yahoo-finance --cli-only
  2. Verify:
    yahoo-finance-pp-cli --version
  3. Ensure
    $GOPATH/bin
    (or
    $HOME/go/bin
    ) is on
    $PATH
    .
If the
npx
install fails (no Node, offline, etc.), fall back to a direct Go install (requires Go 1.23+):
bash
go install github.com/mvanhorn/printing-press-library/library/commerce/yahoo-finance/cmd/yahoo-finance-pp-cli@latest
If
--version
reports "command not found" after install, the install step did not put the binary on
$PATH
. Do not proceed with skill commands until verification succeeds.
本技能基于
yahoo-finance-pp-cli
二进制文件运行。在调用本技能的任何命令前,必须确认CLI已安装。若未安装,请先执行以下步骤:
  1. 通过Printing Press安装程序安装:
    bash
    npx -y @mvanhorn/printing-press install yahoo-finance --cli-only
  2. 验证安装:
    yahoo-finance-pp-cli --version
  3. 确保
    $GOPATH/bin
    (或
    $HOME/go/bin
    )已添加到
    $PATH
    环境变量中。
npx
安装失败(无Node环境、离线等情况),可改用Go直接安装(需Go 1.23+版本):
bash
go install github.com/mvanhorn/printing-press-library/library/commerce/yahoo-finance/cmd/yahoo-finance-pp-cli@latest
若安装后执行
--version
提示“command not found”,说明安装程序未将二进制文件添加到
$PATH
中。在验证成功前,请勿执行技能相关命令。

When to Use This CLI

何时使用本CLI

Use this CLI when the user asks about:
  • stock, ETF, or fund quotes
  • chart history or price ranges
  • fundamentals or quote summary modules
  • options chains or simple moneyness filtering
  • trending symbols or predefined market screeners
  • ticker search and autocomplete
  • local watchlists
  • portfolio cost basis and unrealized P&L
Do not use it when the user specifically needs:
  • real-time streaming tick data
  • exchange-grade paid data feeds
  • broker/account actions like order entry
当用户询问以下内容时,可使用本CLI:
  • 股票、ETF或基金报价
  • 图表历史或价格区间
  • 基本面数据或报价摘要模块
  • 期权链或简单实值筛选
  • 热门代码或预定义市场筛选器
  • 代码搜索与自动补全
  • 本地观察列表
  • 投资组合成本基准与未实现盈亏
以下情况请勿使用本CLI:
  • 需要实时流式报价数据
  • 需要交易所级别的付费数据馈送
  • 需要经纪商/账户操作(如下单)

Best Command Mapping

最佳命令映射

  • "How is AAPL doing?" →
    yahoo-finance-pp-cli quote --symbols AAPL --agent
  • "Give me a deeper view on Microsoft" →
    yahoo-finance-pp-cli quote summary MSFT --agent
  • "Show me NVDA for the last year" →
    yahoo-finance-pp-cli chart NVDA --range 1y --interval 1wk --agent
  • "What are the top gainers today?" →
    yahoo-finance-pp-cli screener --scr-ids day_gainers --agent
  • "What is trending in the US?" →
    yahoo-finance-pp-cli trending US --agent
  • "Track my portfolio" →
    yahoo-finance-pp-cli portfolio perf --agent
  • "Compare AAPL, MSFT, and NVDA" →
    yahoo-finance-pp-cli compare AAPL MSFT NVDA --agent
  • "Show me SPY options expiring soon" →
    yahoo-finance-pp-cli options-chain SPY --max-dte 45 --agent
  • "AAPL表现如何?" →
    yahoo-finance-pp-cli quote --symbols AAPL --agent
  • "给我详细介绍下微软" →
    yahoo-finance-pp-cli quote summary MSFT --agent
  • "展示NVDA过去一年的走势" →
    yahoo-finance-pp-cli chart NVDA --range 1y --interval 1wk --agent
  • "今天涨幅最高的股票有哪些?" →
    yahoo-finance-pp-cli screener --scr-ids day_gainers --agent
  • "美国市场热门标的有哪些?" →
    yahoo-finance-pp-cli trending US --agent
  • "追踪我的投资组合" →
    yahoo-finance-pp-cli portfolio perf --agent
  • "对比AAPL、MSFT和NVDA" →
    yahoo-finance-pp-cli compare AAPL MSFT NVDA --agent
  • "展示即将到期的SPY期权" →
    yahoo-finance-pp-cli options-chain SPY --max-dte 45 --agent

Unique Capabilities

独特功能

watchlist

watchlist
(观察列表)

Save named ticker groups locally for reuse across commands.
bash
yahoo-finance-pp-cli watchlist create tech
yahoo-finance-pp-cli watchlist add tech AAPL MSFT NVDA GOOG
在本地保存命名的代码组,以便在多个命令中重复使用。
bash
yahoo-finance-pp-cli watchlist create tech
yahoo-finance-pp-cli watchlist add tech AAPL MSFT NVDA GOOG

portfolio

portfolio
(投资组合)

Track local lots with purchase date and cost basis, then join them with live quotes.
bash
yahoo-finance-pp-cli portfolio add AAPL 50 185.50 --purchased 2024-06-15
yahoo-finance-pp-cli portfolio perf --agent
yahoo-finance-pp-cli portfolio gains --agent
追踪包含购买日期和成本基准的本地持仓,并与实时报价关联。
bash
yahoo-finance-pp-cli portfolio add AAPL 50 185.50 --purchased 2024-06-15
yahoo-finance-pp-cli portfolio perf --agent
yahoo-finance-pp-cli portfolio gains --agent

digest

digest
(摘要)

Summarize a watchlist into biggest gainers and losers.
bash
yahoo-finance-pp-cli digest --watchlist tech --agent
将观察列表汇总为涨幅最高和跌幅最大的标的。
bash
yahoo-finance-pp-cli digest --watchlist tech --agent

compare

compare
(对比)

Show a normalized multi-symbol comparison.
bash
yahoo-finance-pp-cli compare AAPL MSFT GOOG NVDA --agent
展示标准化的多标的对比结果。
bash
yahoo-finance-pp-cli compare AAPL MSFT GOOG NVDA --agent

sparkline

sparkline
(迷你走势图)

Render a compact terminal sparkline from recent chart data.
bash
yahoo-finance-pp-cli sparkline AAPL --range 3mo
基于近期图表数据在终端渲染紧凑的迷你走势图。
bash
yahoo-finance-pp-cli sparkline AAPL --range 3mo

sql

sql

Run SQL directly against the local Yahoo/watchlist/portfolio database.
bash
yahoo-finance-pp-cli sql "SELECT watchlist, COUNT(*) FROM watchlist_members GROUP BY watchlist" --agent
直接对本地Yahoo/观察列表/投资组合数据库执行SQL查询。
bash
yahoo-finance-pp-cli sql "SELECT watchlist, COUNT(*) FROM watchlist_members GROUP BY watchlist" --agent

fx

fx
(汇率转换)

Convert currencies without manually building Yahoo FX pair symbols.
bash
yahoo-finance-pp-cli fx USD EUR --amount 100 --agent
无需手动构建Yahoo汇率对代码即可转换货币。
bash
yahoo-finance-pp-cli fx USD EUR --amount 100 --agent

options-chain

options-chain
(期权链)

Filter Yahoo's raw chain into a usable options view by moneyness and DTE.
bash
yahoo-finance-pp-cli options-chain AAPL --moneyness otm --max-dte 45 --type calls --agent
根据实值状态和到期天数(DTE)将Yahoo原始期权链筛选为可用视图。
bash
yahoo-finance-pp-cli options-chain AAPL --moneyness otm --max-dte 45 --type calls --agent

auth login-chrome

auth login-chrome

Import a browser session when Yahoo blocks the automatic crumb bootstrap from the current IP.
bash
yahoo-finance-pp-cli auth login-chrome --cookies ~/yahoo-cookies.json --crumb abc123
当Yahoo从当前IP自动获取crumb失败时,导入浏览器会话。
bash
yahoo-finance-pp-cli auth login-chrome --cookies ~/yahoo-cookies.json --crumb abc123

Command Reference

命令参考

Market data:
  • yahoo-finance-pp-cli quote --symbols AAPL,MSFT
  • yahoo-finance-pp-cli quote summary AAPL
  • yahoo-finance-pp-cli chart AAPL --range 1mo --interval 1d
  • yahoo-finance-pp-cli fundamentals AAPL --type annualTotalRevenue
  • yahoo-finance-pp-cli insights --symbol AAPL
  • yahoo-finance-pp-cli options AAPL
  • yahoo-finance-pp-cli recommendations AAPL
  • yahoo-finance-pp-cli screener --scr-ids day_gainers
  • yahoo-finance-pp-cli trending US
  • yahoo-finance-pp-cli search "apple"
  • yahoo-finance-pp-cli autocomplete --query appl
Local-state and derived workflows:
  • yahoo-finance-pp-cli watchlist create|add|remove|list|show|delete
  • yahoo-finance-pp-cli portfolio add|list|remove|perf|gains
  • yahoo-finance-pp-cli digest
  • yahoo-finance-pp-cli compare
  • yahoo-finance-pp-cli sparkline
  • yahoo-finance-pp-cli sql
  • yahoo-finance-pp-cli fx
  • yahoo-finance-pp-cli options-chain
Utilities:
  • yahoo-finance-pp-cli sync
  • yahoo-finance-pp-cli workflow archive
  • yahoo-finance-pp-cli workflow status
  • yahoo-finance-pp-cli export
  • yahoo-finance-pp-cli import
  • yahoo-finance-pp-cli doctor
  • yahoo-finance-pp-cli auth status
  • yahoo-finance-pp-cli auth logout
  • yahoo-finance-pp-cli auth login-chrome
市场数据类:
  • yahoo-finance-pp-cli quote --symbols AAPL,MSFT
  • yahoo-finance-pp-cli quote summary AAPL
  • yahoo-finance-pp-cli chart AAPL --range 1mo --interval 1d
  • yahoo-finance-pp-cli fundamentals AAPL --type annualTotalRevenue
  • yahoo-finance-pp-cli insights --symbol AAPL
  • yahoo-finance-pp-cli options AAPL
  • yahoo-finance-pp-cli recommendations AAPL
  • yahoo-finance-pp-cli screener --scr-ids day_gainers
  • yahoo-finance-pp-cli trending US
  • yahoo-finance-pp-cli search "apple"
  • yahoo-finance-pp-cli autocomplete --query appl
本地状态与衍生工作流类:
  • yahoo-finance-pp-cli watchlist create|add|remove|list|show|delete
  • yahoo-finance-pp-cli portfolio add|list|remove|perf|gains
  • yahoo-finance-pp-cli digest
  • yahoo-finance-pp-cli compare
  • yahoo-finance-pp-cli sparkline
  • yahoo-finance-pp-cli sql
  • yahoo-finance-pp-cli fx
  • yahoo-finance-pp-cli options-chain
工具类:
  • yahoo-finance-pp-cli sync
  • yahoo-finance-pp-cli workflow archive
  • yahoo-finance-pp-cli workflow status
  • yahoo-finance-pp-cli export
  • yahoo-finance-pp-cli import
  • yahoo-finance-pp-cli doctor
  • yahoo-finance-pp-cli auth status
  • yahoo-finance-pp-cli auth logout
  • yahoo-finance-pp-cli auth login-chrome

Practical Recipes

实用示例

Morning briefing over a watchlist

基于观察列表的晨间简报

bash
yahoo-finance-pp-cli watchlist create tech
yahoo-finance-pp-cli watchlist add tech AAPL MSFT NVDA GOOG META
yahoo-finance-pp-cli digest --watchlist tech --agent
bash
yahoo-finance-pp-cli watchlist create tech
yahoo-finance-pp-cli watchlist add tech AAPL MSFT NVDA GOOG META
yahoo-finance-pp-cli digest --watchlist tech --agent

Track a real portfolio with cost basis

追踪带成本基准的真实投资组合

bash
yahoo-finance-pp-cli portfolio add AAPL 50 185.50 --purchased 2024-06-15
yahoo-finance-pp-cli portfolio add MSFT 20 340.00 --purchased 2024-03-01
yahoo-finance-pp-cli portfolio perf --agent
yahoo-finance-pp-cli portfolio gains --agent
bash
yahoo-finance-pp-cli portfolio add AAPL 50 185.50 --purchased 2024-06-15
yahoo-finance-pp-cli portfolio add MSFT 20 340.00 --purchased 2024-03-01
yahoo-finance-pp-cli portfolio perf --agent
yahoo-finance-pp-cli portfolio gains --agent

Compare several large-cap names

对比多个大盘股

bash
yahoo-finance-pp-cli compare AAPL MSFT NVDA GOOG --agent
bash
yahoo-finance-pp-cli compare AAPL MSFT NVDA GOOG --agent

Fallback when Yahoo blocks your IP

Yahoo IP封禁时的解决方案

bash
yahoo-finance-pp-cli auth login-chrome --cookies ~/yahoo-cookies.json --crumb abc123
yahoo-finance-pp-cli doctor
bash
yahoo-finance-pp-cli auth login-chrome --cookies ~/yahoo-cookies.json --crumb abc123
yahoo-finance-pp-cli doctor

Session Model

会话模型

Yahoo Finance uses a crumb/cookie session model, not an API key model.
  • first live request: the CLI tries to bootstrap the session automatically
  • if Yahoo blocks that bootstrap with HTTP 429: use
    auth login-chrome
  • inspect cached state:
    auth status
  • clear a bad cached session:
    auth logout
Yahoo Finance采用crumb/ Cookie会话模型,而非API密钥模型。
  • 首次实时请求:CLI尝试自动初始化会话
  • 若Yahoo返回HTTP 429错误阻止初始化:使用
    auth login-chrome
    命令
  • 查看缓存状态:
    auth status
  • 清除无效缓存会话:
    auth logout

Agent Mode

Agent模式

Add
--agent
when you want machine-oriented output.
It expands to:
  • --json
  • --compact
  • --no-input
  • --no-color
  • --yes
Useful companion flags:
  • --select <fields>
  • --dry-run
  • --no-cache
  • --data-source auto|live|local
  • --rate-limit <n>
当需要面向机器的输出时,添加
--agent
参数。
该参数等价于同时设置:
  • --json
  • --compact
  • --no-input
  • --no-color
  • --yes
实用的配套参数:
  • --select <fields>
  • --dry-run
  • --no-cache
  • --data-source auto|live|local
  • --rate-limit <n>

Filtering output

输出筛选

--select
accepts dotted paths to descend into nested responses; arrays traverse element-wise:
bash
yahoo-finance-pp-cli <command> --agent --select id,name
yahoo-finance-pp-cli <command> --agent --select items.id,items.owner.name
Use this to narrow huge payloads to the fields you actually need — critical for deeply nested API responses.
--select
接受点路径以遍历嵌套响应;数组会逐个元素遍历:
bash
yahoo-finance-pp-cli <command> --agent --select id,name
yahoo-finance-pp-cli <command> --agent --select items.id,items.owner.name
使用该参数可将庞大的响应缩小到实际需要的字段——这在处理深度嵌套的API响应时至关重要。

Response envelope

响应信封

Data-layer commands wrap output in
{"meta": {...}, "results": <data>}
. Parse
.results
for data and
.meta.source
to know whether it's
live
or local. The
N results (live)
summary is printed to stderr only when stdout is a TTY; piped/agent consumers see pure JSON on stdout.
数据层命令会将输出包裹在
{"meta": {...}, "results": <data>}
结构中。解析
.results
获取数据,通过
.meta.source
判断数据是
live
(实时)还是本地缓存。仅当stdout为TTY时,
N results (live)
摘要才会打印到stderr;管道/Agent消费者只会在stdout看到纯JSON。

Exit Codes

退出码

CodeMeaning
0Success
2Usage error
3Resource not found
4Session/auth-style error
5API error
7Rate limited
10Config error
代码含义
0成功
2使用错误
3资源未找到
4会话/认证类错误
5API错误
7速率限制
10配置错误

Argument Parsing

参数解析

Given
$ARGUMENTS
:
  1. Empty,
    help
    , or
    --help
    → run
    yahoo-finance-pp-cli --help
  2. install
    → install CLI
  3. install mcp
    → install MCP server
  4. Anything else → map the user request to the best command above and run it with
    --agent
针对
$ARGUMENTS
  1. 为空、
    help
    --help
    → 执行
    yahoo-finance-pp-cli --help
  2. install
    → 安装CLI
  3. install mcp
    → 安装MCP服务器
  4. 其他内容 → 将用户请求映射到上述最匹配的命令,并添加
    --agent
    参数执行

MCP Server Installation

MCP服务器安装

bash
go install github.com/mvanhorn/printing-press-library/library/commerce/yahoo-finance/cmd/yahoo-finance-pp-mcp@latest
claude mcp add yahoo-finance yahoo-finance-pp-mcp
bash
go install github.com/mvanhorn/printing-press-library/library/commerce/yahoo-finance/cmd/yahoo-finance-pp-mcp@latest
claude mcp add yahoo-finance yahoo-finance-pp-mcp

Direct Use

直接使用流程

  1. Check whether
    yahoo-finance-pp-cli
    is installed.
  2. If not installed, offer CLI installation.
  3. Choose the command that matches the user's intent most directly.
  4. Run with
    --agent
    unless the user explicitly wants human-formatted output.
  5. If Yahoo is rate-limiting this machine, guide the user to
    auth login-chrome
    .
<!-- pr-218-features -->
  1. 检查
    yahoo-finance-pp-cli
    是否已安装。
  2. 若未安装,提供CLI安装选项。
  3. 选择与用户意图最匹配的命令。
  4. 除非用户明确需要面向人类的格式化输出,否则添加
    --agent
    参数执行。
  5. 若Yahoo对当前机器进行速率限制,引导用户执行
    auth login-chrome
    命令。
<!-- pr-218-features -->

Agent Workflow Features

Agent工作流特性

This CLI exposes three shared agent-workflow capabilities patched in from cli-printing-press PR #218.
本CLI提供三个从cli-printing-press PR #218中引入的通用Agent工作流功能。

Named profiles

命名配置文件

Persist a set of flags under a name and reuse them across invocations.
bash
undefined
将一组参数保存为命名配置文件,以便在多次调用中复用。
bash
undefined

Save the current non-default flags as a named profile

将当前非默认参数保存为命名配置文件

yahoo-finance-pp-cli profile save <name>
yahoo-finance-pp-cli profile save <name>

Use a profile — overlays its values onto any flag you don't set explicitly

使用配置文件——其值会覆盖未显式设置的参数

yahoo-finance-pp-cli --profile <name> <command>
yahoo-finance-pp-cli --profile <name> <command>

List / inspect / remove

列出/查看/删除配置文件

yahoo-finance-pp-cli profile list yahoo-finance-pp-cli profile show <name> yahoo-finance-pp-cli profile delete <name> --yes

Flag precedence: explicit flag > env var > profile > default.
yahoo-finance-pp-cli profile list yahoo-finance-pp-cli profile show <name> yahoo-finance-pp-cli profile delete <name> --yes

参数优先级:显式参数 > 环境变量 > 配置文件 > 默认值。

--deliver

--deliver

Route command output to a sink other than stdout. Useful when an agent needs to hand a result to a file, a webhook, or another process without plumbing.
bash
yahoo-finance-pp-cli <command> --deliver file:/path/to/out.json
yahoo-finance-pp-cli <command> --deliver webhook:https://hooks.example/in
File sinks write atomically (tmp + rename). Webhook sinks POST
application/json
(or
application/x-ndjson
when
--compact
is set). Unknown schemes produce a structured refusal listing the supported set.
将命令输出路由到stdout以外的目标。当Agent需要将结果传递到文件、Webhook或其他进程而无需额外处理时非常有用。
bash
yahoo-finance-pp-cli <command> --deliver file:/path/to/out.json
yahoo-finance-pp-cli <command> --deliver webhook:https://hooks.example/in
文件目标会以原子方式写入(先写入临时文件再重命名)。Webhook目标会POST
application/json
(设置
--compact
时为
application/x-ndjson
)。未知协议会返回结构化提示,列出支持的协议类型。

feedback

feedback(反馈)

Record in-band feedback about this CLI from the agent side of the loop. Local-only by default; safe to call without configuration.
bash
yahoo-finance-pp-cli feedback "what surprised you or tripped you up"
yahoo-finance-pp-cli feedback list         # show local entries
yahoo-finance-pp-cli feedback clear --yes  # wipe
Entries append to
~/.yahoo-finance-pp-cli/feedback.jsonl
as JSON lines. When
YAHOO_FINANCE_FEEDBACK_ENDPOINT
is set and either
--send
is passed or
YAHOO_FINANCE_FEEDBACK_AUTO_SEND=true
, the entry is also POSTed upstream (non-blocking — local write always succeeds).
从Agent端记录关于本CLI的内置反馈。默认仅本地存储;无需配置即可安全调用。
bash
yahoo-finance-pp-cli feedback "what surprised you or tripped you up"
yahoo-finance-pp-cli feedback list         # 显示本地记录
yahoo-finance-pp-cli feedback clear --yes  # 清除记录
记录会以JSON行格式追加到
~/.yahoo-finance-pp-cli/feedback.jsonl
。当设置了
YAHOO_FINANCE_FEEDBACK_ENDPOINT
且传递了
--send
参数或
YAHOO_FINANCE_FEEDBACK_AUTO_SEND=true
时,记录还会被POST到上游(非阻塞——本地写入始终成功)。