mcpField
E
earnings-recap

earnings-recap

github.com/himself65数据与数据库3.5k3.4k 次安装3 天前更新
代码仓库

关于 earnings-recap

面向金融研究者和投资者的财报回顾 Skill,使用 yfinance 分析实际业绩、与预期的差异、股价反应和近期财务趋势。内容围绕实际值与预期值展开,保持事实性,不提供投资建议。

主要功能

  1. 01实际 EPS 与预期对比
  2. 02EPS 惊喜幅度
  3. 03财报前后的股价反应
  4. 04近期营收与利润率趋势
  5. 05分析师情绪与财务背景

适用场景

  1. 01回顾公司最新财报
  2. 02对比本季度与过往季度业绩
  3. 03评估财报发布后的市场反应

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/himself65/finance-skills --skill earnings-recap

安装后在 Claude Code 中输入/earnings-recap确认已加载。

附带文件README.mdreferences/api_reference.md

详细介绍

盈利回顾技能

如果宿主尚未执行以下 shell 探测(例如,在 Codex 中),请先使用其 shell 工具运行 ! 包裹的命令,再选择设置路径。使用实际输出;如果无法访问 shell,请说明此限制。

通过 yfinance 使用 Yahoo Finance 数据生成财报发布后的分析。涵盖实际值与预估值、超预期幅度、股价反应和财务背景,全面呈现财报发布后的情况。

重要提示:数据仅供研究和教育用途,不构成财务建议。yfinance 与 Yahoo, Inc. 无关联。


第 1 步:确保 yfinance 可用

当前环境状态:

!`python3 -c "exec('try:\n import yfinance\n print(\'yfinance \' + yfinance.__version__ + \' installed\')\nexcept Exception:\n print(\'YFINANCE_NOT_INSTALLED\')')"`

如果显示 YFINANCE_NOT_INSTALLED,请安装:

import subprocess, sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance"])

如果已安装,请跳至下一步。


第 2 步:识别股票代码并收集数据

从用户的请求中提取股票代码。在一个脚本中获取所有相关的财报发布后数据。

import yfinance as yf
import pandas as pd

ticker = yf.Ticker("AAPL")  # replace with actual ticker

# --- Earnings results ---
earnings_dates = ticker.get_earnings_dates(limit=12)  # report timestamps, newest first
earnings_hist = ticker.earnings_history               # last 4 quarters, indexed by fiscal quarter-end, oldest first

# --- Financial statements (about five quarters, newest first) ---
quarterly_income = ticker.quarterly_income_stmt
quarterly_cashflow = ticker.quarterly_cashflow
quarterly_balance = ticker.quarterly_balance_sheet

# --- Context ---
info = ticker.info
news = ticker.news
recommendations = ticker.recommendations
提取内容
数据来源关键字段用途
get_earnings_dates()财报日期、EPS 预估值、已公布 EPS、超预期(%)确定是哪次财报、发布时间,以及超预期或不及预期的情况
earnings_historyepsEstimate、epsActual、epsDifference、surprisePercent按财季列出最近四个季度的业绩
quarterly_income_stmtTotalRevenue、GrossProfit、OperatingIncome、NetIncome、BasicEPS实际财务数据
history()每次财报发布前后的每日收盘价股价反应
infocurrentPrice、marketCap、forwardPE当前背景信息
news最新新闻标题财报相关新闻

第 3 步:找到财报并衡量市场反应

earnings_history 按财季末日期建立索引,而非按财报公布日期,因此请从 get_earnings_dates() 获取财报时间:最近一次财报是最新一行含有 Reported EPS 的记录。其时间戳(美国东部时间)决定市场反应窗口:时间为 16:00 或之后,表示公司在收盘后公布财报;更早则表示在开盘前公布,偶尔也可能是在交易时段内公布。如果用户询问的是特定季度,请改用对应行。

def earnings_reaction(ticker, report_ts):
    """% move from the last close before the report to the first close after it."""
    daily = ticker.history(start=(report_ts - pd.Timedelta(days=10)).date(),
                           end=(report_ts + pd.Timedelta(days=10)).date())
    closes = daily["Close"]
    days = closes.index.date
    d = report_ts.date()
    if report_ts.hour >= 16:  # reported after the close: report-day close -> next close
        pre, post = closes[days <= d], closes[days > d]
    else:                     # before the open or intraday: prior close -> report-day close
        pre, post = closes[days < d], closes[days >= d]
    if pre.empty or post.empty:
        return None           # the reaction session hasn't closed yet
    return (post.iloc[0] / pre.iloc[-1] - 1) * 100

reported = earnings_dates[earnings_dates["Reported EPS"].notna()]
latest_ts = reported.index[0]
reaction_pct = earnings_reaction(ticker, latest_ts)

# Typical earnings-day move over the prior four reports
prior_moves = [earnings_reaction(ticker, ts) for ts in reported.index[1:5]]
avg_abs_move = pd.Series([abs(m) for m in prior_moves if m is not None]).mean()

如果 reaction_pct 为 None,表示财报是在最近一次收盘后公布的;请说明常规交易时段的反应尚未出现(如果用户需要,可调用盘中 history(..., prepost=True) 查看盘后波动)。


第 4 步:撰写财报回顾

涵盖以下方面,并先呈现结果:

  1. 核心结果 — EPS 实际值与预估值及超预期百分比、营收同比增长率,以及股价反应。
  2. 预估值与实际值 — 所问季度的 EPS 预估值、实际值和超预期幅度(金额及百分比)。
  3. 季度趋势 — 最近几个季度的营收、毛利率、营业利润率和 EPS;根据财务报表计算利润率(毛利 / 营收、营业利润 / 营收)。yfinance 通常会返回约五个季度的数据,因此只有最新季度可计算同比增长(第 0 列与第 4 列对比);其他季度应展示环比变化,不要臆造对比数据。
  4. 股价反应 — 反应时段内的股价变动、与此前四次财报发布期间股票平均绝对涨跌幅的对比,以及此后股价是守住、回吐还是扩大了涨幅。
  5. 变化情况 — 利润率相较上一季度的变化、营收增长趋势是否转变、此次超预期表现与公司的常见模式相比如何,以及当前分析师情绪(如有)。

步骤 5:回复用户

开篇先给出标题,说明这是哪个季度、何时报出的业绩、超预期还是低于预期、营收增长情况以及市场反应,然后再列出支持数据的表格。说明关键之处:这是一次有意义的超预期,还是仅仅达到较低的门槛;趋势是在改善还是恶化。保持客观,不要提供投资建议。

注明适用的免责声明:Yahoo Finance 数据无法涵盖电话会议中的所有内容(如业绩指引、分部详情);营收是根据财务报表与去年同期比较,而非与营收预期比较;股价反应可能受到当天整体市场走势的影响;本内容不构成财务建议。


参考文件

  • references/api_reference.md — yfinance 盈利历史和财务报表方法的详细 API 参考

需要准确的方法签名或处理财务数据中的边缘情况时,请阅读参考文件。

评论

支持 Markdown