$npx -y skills add himself65/finance-skills --skill earnings-previewGenerate 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.
| 1 | # Earnings Preview Skill |
| 2 | |
| 3 | Generates a pre-earnings briefing using Yahoo Finance data via [yfinance](https://github.com/ranaroussi/yfinance). Pulls together upcoming earnings date, consensus estimates, historical accuracy, analyst sentiment, and key financial context — everything you need before an earnings call. |
| 4 | |
| 5 | **Important**: Data is for research and educational purposes only. Not financial advice. yfinance is not affiliated with Yahoo, Inc. |
| 6 | |
| 7 | --- |
| 8 | |
| 9 | ## Step 1: Ensure yfinance Is Available |
| 10 | |
| 11 | **Current environment status:** |
| 12 | |
| 13 | ``` |
| 14 | !`python3 -c "import yfinance; print('yfinance ' + yfinance.__version__ + ' installed')" 2>/dev/null || echo "YFINANCE_NOT_INSTALLED"` |
| 15 | ``` |
| 16 | |
| 17 | If `YFINANCE_NOT_INSTALLED`, install it: |
| 18 | |
| 19 | ```python |
| 20 | import subprocess, sys |
| 21 | subprocess.check_call([sys.executable, "-m", "pip", "install", "-q", "yfinance"]) |
| 22 | ``` |
| 23 | |
| 24 | If already installed, skip to the next step. |
| 25 | |
| 26 | --- |
| 27 | |
| 28 | ## Step 2: Identify the Ticker and Gather All Data |
| 29 | |
| 30 | Extract the ticker symbol from the user's request. If they mention a company name without a ticker, look it up. Then fetch all relevant data in one script to minimize API calls. |
| 31 | |
| 32 | ```python |
| 33 | import yfinance as yf |
| 34 | import pandas as pd |
| 35 | from datetime import datetime |
| 36 | |
| 37 | ticker = yf.Ticker("AAPL") # replace with actual ticker |
| 38 | |
| 39 | # --- Core data --- |
| 40 | info = ticker.info |
| 41 | calendar = ticker.calendar |
| 42 | |
| 43 | # --- Estimates --- |
| 44 | earnings_est = ticker.earnings_estimate |
| 45 | revenue_est = ticker.revenue_estimate |
| 46 | |
| 47 | # --- Historical track record --- |
| 48 | earnings_hist = ticker.earnings_history |
| 49 | |
| 50 | # --- Analyst sentiment --- |
| 51 | price_targets = ticker.analyst_price_targets |
| 52 | recommendations = ticker.recommendations |
| 53 | |
| 54 | # --- Recent financials for context --- |
| 55 | quarterly_income = ticker.quarterly_income_stmt |
| 56 | quarterly_cashflow = ticker.quarterly_cashflow |
| 57 | ``` |
| 58 | |
| 59 | ### What to extract from each source |
| 60 | |
| 61 | | Data Source | Key Fields | Purpose | |
| 62 | |---|---|---| |
| 63 | | `calendar` | Earnings Date, Ex-Dividend Date | When earnings are and key dates | |
| 64 | | `earnings_estimate` | avg, low, high, numberOfAnalysts, yearAgoEps, growth (for 0q, +1q, 0y, +1y) | Consensus EPS expectations | |
| 65 | | `revenue_estimate` | avg, low, high, numberOfAnalysts, yearAgoRevenue, growth | Revenue expectations | |
| 66 | | `earnings_history` | epsEstimate, epsActual, epsDifference, surprisePercent | Beat/miss track record | |
| 67 | | `analyst_price_targets` | current, low, high, mean, median | Street price targets | |
| 68 | | `recommendations` | Buy/Hold/Sell counts | Sentiment distribution | |
| 69 | | `quarterly_income_stmt` | TotalRevenue, NetIncome, BasicEPS | Recent trajectory | |
| 70 | |
| 71 | --- |
| 72 | |
| 73 | ## Step 3: Build the Earnings Preview |
| 74 | |
| 75 | Assemble the data into a structured briefing. The goal is to give the user everything they need in one glance. |
| 76 | |
| 77 | ### Section 1: Earnings Date & Key Info |
| 78 | |
| 79 | Report the upcoming earnings date from `calendar`. Include: |
| 80 | - Company name, ticker, sector, industry |
| 81 | - Upcoming earnings date (and whether it's before/after market) |
| 82 | - Current stock price and recent performance (1-week, 1-month) |
| 83 | - Market cap |
| 84 | |
| 85 | ### Section 2: Consensus Estimates |
| 86 | |
| 87 | Present the current quarter estimates from `earnings_estimate` and `revenue_estimate`: |
| 88 | |
| 89 | | Metric | Consensus | Low | High | # Analysts | Year Ago | Growth | |
| 90 | |---|---|---|---|---|---|---| |
| 91 | | EPS | $1.42 | $1.35 | $1.50 | 28 | $1.26 | +12.7% | |
| 92 | | Revenue | $94.3B | $92.1B | $96.8B | 25 | $89.5B | +5.4% | |
| 93 | |
| 94 | If the estimate range is unusually wide (high/low spread > 20% of consensus), note that as a sign of high uncertainty. |
| 95 | |
| 96 | ### Section 3: Historical Beat/Miss Track Record |
| 97 | |
| 98 | From `earnings_history`, show the last 4 quarters: |
| 99 | |
| 100 | | Quarter | EPS Est | EPS Actual | Surprise | Beat/Miss | |
| 101 | |---|---|---|---|---| |
| 102 | | Q3 2024 | $1.35 | $1.40 | +3.7% | Beat | |
| 103 | | Q2 2024 | $1.30 | $1.33 | +2.3% | Beat | |
| 104 | | Q1 2024 | $1.52 | $1.53 | +0.7% | Beat | |
| 105 | | Q4 2023 | $2.10 | $2.18 | +3.8% | Beat | |
| 106 | |
| 107 | Summarize: "AAPL has beaten EPS estimates in 4 of the last 4 quarters by an average of 2.6%." |
| 108 | |
| 109 | ### Section 4: Analyst Sentiment |
| 110 | |
| 111 | From `recommendation |