himself65/finance-skills

earnings-recap

Generate a post-earnings analysis for any stock using Yahoo Finance data.

Zobacz źródło
Oryginalny dokument Skill

Treść z repozytorium z zachowaniem nagłówków, przykładów, kodu, tabel, linków i obrazów.

Earnings Recap Skill

Generates a post-earnings analysis using Yahoo Finance data via yfinance. Covers the actual vs estimated numbers, surprise magnitude, stock price reaction, and financial context — a complete picture of what happened.

Important: Data is for research and educational purposes only. Not financial advice. yfinance is not affiliated with Yahoo, Inc.


Step 1: Ensure yfinance Is Available

Current environment status:

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

If YFINANCE_NOT_INSTALLED, install it:

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

If already installed, skip to the next step.


Step 2: Identify the Ticker and Gather Data

Extract the ticker from the user's request. Fetch all relevant post-earnings data in one script.

python
import yfinance as yf
import pandas as pd
from datetime import datetime, timedelta

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

# --- Earnings result ---
earnings_hist = ticker.earnings_history

# --- Financial statements ---
quarterly_income = ticker.quarterly_income_stmt
quarterly_cashflow = ticker.quarterly_cashflow
quarterly_balance = ticker.quarterly_balance_sheet

# --- Price reaction ---
# Get ~30 days of history to capture the reaction window
hist = ticker.history(period="1mo")

# --- Context ---
info = ticker.info
news = ticker.news
recommendations = ticker.recommendations

What to extract

Data SourceKey FieldsPurpose
earnings_historyepsEstimate, epsActual, epsDifference, surprisePercentBeat/miss result
quarterly_income_stmtTotalRevenue, GrossProfit, OperatingIncome, NetIncome, BasicEPSActual financials
history()Close prices around earnings dateStock price reaction
infocurrentPrice, marketCap, forwardPECurrent context
newsRecent headlinesEarnings-related news

Step 3: Determine the Most Recent Earnings

The most recent earnings result is the first row (most recent date) in earnings_history. Use its date to:

  1. Identify the earnings date for the price reaction analysis
  2. Match to the corresponding quarter in the financial statements
  3. Calculate stock price reaction — compare the close before earnings to the next trading day's close (or open, depending on whether earnings were before/after market)

Price reaction calculation

python
import numpy as np

# Find the earnings date from earnings_history index
earnings_date = earnings_hist.index[0]  # most recent

# Get daily prices around the earnings date
hist_extended = ticker.history(start=earnings_date - timedelta(days=5),
                                end=earnings_date + timedelta(days=5))

# The reaction is typically measured as:
# - Close on the last trading day before earnings -> Close on the first trading day after
# Be careful with before/after market reports
if len(hist_extended) >= 2:
    pre_price = hist_extended['Close'].iloc[0]
    post_price = hist_extended['Close'].iloc[-1]
    reaction_pct = ((post_price - pre_price) / pre_price) * 100

Note: The exact reaction window depends on when the company reported (before market open vs after close). The price data will reflect this — look for the biggest gap between consecutive closes near the earnings date.


Step 4: Build the Earnings Recap

Section 1: Headline Result

Lead with the key numbers:

  • EPS: Actual vs. Estimate, beat/miss by how much, surprise %
  • Revenue: Actual vs. prior year (from quarterlyincomestmt TotalRevenue)
  • Stock reaction: % move on earnings day

Example: "AAPL beat Q3 EPS estimates by 3.7% ($1.40 actual vs $1.35 expected). Revenue grew 5.4% YoY to $94.3B. The stock rose +2.1% on the report."

Section 2: Earnings vs. Estimates Detail

MetricEstimateActualSurprise
EPS$1.35$1.40+$0.05 (+3.7%)

If the user asked about a specific quarter (not the most recent), look further back in earnings_history.

Section 3: Quarterly Financial Trends

Show the last 4 quarters of key metrics from quarterly_income_stmt:

QuarterRevenueYoY GrowthGross MarginOperating MarginEPS
Q3 2024$94.3B+5.4%46.2%30.1%$1.40
Q2 2024$85.8B+4.9%46.0%29.8%$1.33
Q1 2024$119.6B+2.1%45.9%33.5%$2.18
Q4 2023$89.5B-0.3%45.2%29.2%$1.26

Calculate margins from the raw financials:

  • Gross Margin = GrossProfit / TotalRevenue
  • Operating Margin = OperatingIncome / TotalRevenue

Section 4: Stock Price Reaction

  • The % move on the earnings day/next session
  • How it compares to the stock's average earnings-day move (calculate the average absolute move from the last 4 earnings dates in earnings_history)
  • Where the stock is now relative to the earnings-day move (has it held, given back gains, extended further?)

Section 5: Context & What Changed

Based on the data, note:

  • Whether margins expanded or compressed vs prior quarter
  • Any notable changes in revenue growth trajectory
  • How the beat/miss compares to the stock's historical pattern (from the full earnings_history)
  • Current analyst sentiment from recommendations if available

Step 5: Respond to the User

Present the recap as a clean, structured summary:

  1. Lead with the headline: "AAPL reported Q3 2024 earnings on [date]: Beat EPS by 3.7%, revenue +5.4% YoY."
  2. Show the tables for detail
  3. Highlight what matters: Was this a meaningful beat or a low-bar situation? Is the trend improving or deteriorating?
  4. Keep it factual — present the data, avoid making investment recommendations

Caveats to include

  • Yahoo Finance data may not include all details from the earnings call (guidance, segment breakdowns)
  • Revenue estimates are harder to compare precisely — yfinance provides YoY comparison from financial statements
  • Price reaction may be influenced by broader market moves on the same day
  • This is not financial advice

Reference Files

  • references/api_reference.md — Detailed yfinance API reference for earnings history and financial statement methods

Read the reference file when you need exact method signatures or to handle edge cases in the financial data.

z tego samego repozytorium

Więcej Skills

Wszystkie Skills
himself65
Społeczność

company-valuation

Estimate the intrinsic value of a public company using DCF, relative (peer multiple) and sum-of-parts (SOTP) methods, then triangulate to an implied share price with upside/downside versus the current market price. Use this skill whenever the user asks: "what is AAPL worth", "valuation of NVDA", "fair value of TSLA", "intrinsic value", "DCF for MSFT", "build a DCF", "discounted cash flow", "WACC", "terminal value", "implied share price", "upside to fair value", "is X overvalued/undervalued", "relative valuation", "peer comparison valuation", "EV/EBITDA target", "SOTP", "sum of the parts", "how much is [company] worth", "price target from fundamentals", "value this company", or any ticker in the context of computing intrinsic or relative valuation. Default to running ALL three methods (DCF + relative + SOTP-if-applicable) and presenting a blended implied price with a sensitivity table. Do not answer valuation questions from memory — always run the workflow.

instalacje
2
GitHub Stars
3,3 tys.
Aktualizacja
27 sie
himself65
Społeczność

earnings-preview

Generate a pre-earnings briefing for any stock using Yahoo Finance data. Use this skill whenever the user wants to prepare for an upcoming earnings report, understand what analysts expect, review a company's beat/miss track record, or get a quick overview before an earnings call. Triggers include: "earnings preview for AAPL", "what to expect from TSLA earnings", "MSFT reports next week", "earnings preview", "pre-earnings analysis", "what are analysts expecting for NVDA", "earnings estimates for", "will GOOGL beat earnings", "earnings beat/miss history", "upcoming earnings", "before earnings", "earnings setup", "consensus estimates", "earnings whisper", "EPS expectations", "what's the street expecting", "earnings season preview", any mention of preparing for or previewing an earnings report, or any request to understand expectations ahead of a company's earnings date. Always use this skill when the user mentions a ticker in context of upcoming earnings, even if they don't say "preview" explicitly.

instalacje
2
GitHub Stars
3,3 tys.
Aktualizacja
27 sie
himself65
Społeczność

estimate-analysis

Deep-dive into analyst estimates and revision trends for any stock using Yahoo Finance data. Use when the user wants to understand analyst estimate direction, how EPS or revenue forecasts changed over time, compare estimate distributions, or analyze growth projections across periods. Triggers: "estimate analysis for AAPL", "analyst estimate trends for NVDA", "EPS revisions for TSLA", "how have estimates changed for MSFT", "estimate revisions", "EPS trend", "revenue estimates", "consensus changes", "analyst estimates", "estimate distribution", "growth estimates for", "estimate momentum", "revision trend", "forward estimates", "next quarter estimates", "annual estimates", "estimate spread", "bull vs bear estimates", "estimate range", or any request about tracking or comparing analyst estimates/revisions. Use this skill when the user asks about estimates beyond a simple lookup — if they want context, trends, or analysis, this is the right skill.

instalacje
2
GitHub Stars
3,3 tys.
Aktualizacja
27 sie
himself65
Społeczność

etf-premium

Calculate ETF premium/discount vs NAV via Yahoo Finance, and decompose single-day surges into NAV-driven vs structural components (gamma squeeze, dealer hedging, blocked AP arbitrage). Use whenever the user asks about an ETF's premium or discount, NAV comparison, why an ETF diverged from its holdings, or how much of a move is dealer-hedging-driven. Triggers: "ETF premium", "ETF discount", "NAV premium", "is SPY at a premium", "BITO premium", "IBIT premium", "bond ETF discount", "trading above/below NAV", "ETF premium screener", "biggest discount", "compare ETF NAV", "ETF arbitrage", "ETF gamma squeeze", "ETF premium surge", "decompose ETF move", "dealer gamma exposure", "GEX for ETF", "why did this ETF jump", "premium convergence", "AP arbitrage blocked", or any request about the gap between an ETF's price and underlying value. Especially relevant for leveraged, inverse, international, bond, commodity, and crypto ETFs.

instalacje
2
GitHub Stars
3,3 tys.
Aktualizacja
27 sie