Earnings Calendar
Overview
This skill retrieves upcoming earnings announcements for US stocks using the Financial Modeling Prep (FMP) API. It focuses on companies with significant market capitalization (mid-cap and above, over $2B) that are likely to impact market movements. The skill generates organized markdown reports showing which companies are reporting earnings over the next week, grouped by date and timing (before market open, after market close, or time not announced).
Key Features:
- - Uses FMP API for reliable, structured earnings data
- Filters by market cap (>$2B) to focus on market-moving companies
- Includes EPS and revenue estimates
- Multi-environment support (CLI, Desktop, Web)
- Flexible API key management
- Organized by date, timing, and market cap
Prerequisites
FMP API Key
This skill requires a Financial Modeling Prep API key.
Get Free API Key:
- 1. Visit: https://site.financialmodelingprep.com/developer/docs
- Sign up for free account
- Receive API key immediately
- Free tier: 250 API calls/day (sufficient for weekly earnings calendar)
API Key Setup by Environment:
Claude Code (CLI):
CODEBLOCK0
Claude Desktop:
Set environment variable in system or configure MCP server.
Claude Web:
API key will be requested during skill execution (stored only for current session).
Core Workflow
Step 1: Get Current Date and Calculate Target Week
CRITICAL: Always start by obtaining the accurate current date.
Retrieve the current date and time:
- - Use system date/time to get today's date
- Note: "Today's date" is provided in the environment ( tag)
- Calculate the target week: Next 7 days from current date
Date Range Calculation:
CODEBLOCK1
Why This Matters:
- - Earnings calendars are time-sensitive
- "Next week" must be calculated from the actual current date
- Provides accurate date range for API request
Format dates in YYYY-MM-DD for API compatibility.
Step 2: Load FMP API Guide
Before retrieving data, load the comprehensive FMP API guide:
CODEBLOCK2
This guide contains:
- - FMP API endpoint structure and parameters
- Authentication requirements
- Market cap filtering strategy (via Company Profile API)
- Earnings timing conventions (BMO, AMC, TAS)
- Response format and field descriptions
- Error handling strategies
- Best practices and optimization tips
Step 3: API Key Detection and Configuration
Detect API key availability based on environment.
Multi-Environment API Key Detection:
3.1 Check Environment Variable (CLI/Desktop)
CODEBLOCK3
If environment variable is set, proceed to Step 4.
3.2 Prompt User for API Key (Desktop/Web)
If environment variable not found, use AskUserQuestion tool:
Question Configuration:
CODEBLOCK4
3.2.1 If user chooses "No, get free key":
Provide instructions:
CODEBLOCK5
3.3 Request API Key Input
If user has API key, request input:
Prompt:
CODEBLOCK6
Store API key in session variable:
CODEBLOCK7
Confirm with user:
CODEBLOCK8
Step 4: Retrieve Earnings Data via FMP API
Use the Python script to fetch earnings data from FMP API.
Script Location:
CODEBLOCK9
Execution:
Option A: With Environment Variable (CLI):
CODEBLOCK10
Option B: With Session API Key (Desktop/Web):
CODEBLOCK11
Script Workflow (automatic):
- 1. Validates API key and date parameters
- Calls FMP Earnings Calendar API for date range
- Fetches company profiles (market cap, sector, industry)
- Filters companies with market cap >$2B
- Normalizes timing (BMO/AMC/TAS)
- Sorts by date → timing → market cap (descending)
- Outputs JSON to stdout
Expected Output Format (JSON):
CODEBLOCK12
Save to file (recommended for use with report generator):
CODEBLOCK13
Or capture to variable:
CODEBLOCK14
Error Handling:
If script returns errors:
- - 401 Unauthorized: Invalid API key → Verify key or re-enter
- 429 Rate Limit: Exceeded 250 calls/day → Wait or upgrade plan
- Empty Result: No earnings in date range → Expand date range or note in report
- Connection Error: Network issue → Retry or use cached data if available
Step 5: Process and Organize Data
Once earnings data is retrieved (JSON format), process and organize it:
5.1 Parse JSON Data
Load JSON data from script output:
CODEBLOCK15
Or if saved to file:
CODEBLOCK16
5.2 Verify Data Structure
Confirm data includes required fields:
- - ✓ symbol
- ✓ companyName
- ✓ date
- ✓ timing (BMO/AMC/TAS)
- ✓ marketCap
- ✓ sector
5.3 Group by Date
Group all earnings announcements by date:
- - Sunday, [Full Date] (if applicable)
- Monday, [Full Date]
- Tuesday, [Full Date]
- Wednesday, [Full Date]
- Thursday, [Full Date]
- Friday, [Full Date]
- Saturday, [Full Date] (if applicable)
5.4 Sub-Group by Timing
Within each date, create three sub-sections:
- 1. Before Market Open (BMO)
- After Market Close (AMC)
- Time Not Announced (TAS)
Data is already sorted by timing from the script, so maintain this order.
5.5 Within Each Timing Group
Companies are already sorted by market cap descending (script output):
- - Mega-cap (>$200B) first
- Large-cap ($10B-$200B) second
- Mid-cap ($2B-$10B) third
This prioritization ensures the most market-moving companies are listed first.
5.6 Calculate Summary Statistics
Compute:
- - Total Companies: Count of all companies in dataset
- Mega/Large Cap Count: Count where marketCap >= $10B
- Mid Cap Count: Count where marketCap between $2B and $10B
- Peak Day: Day of week with most earnings announcements
- Sector Distribution: Count by sector (Technology, Healthcare, Financial, etc.)
- Highest Market Cap Companies: Top 5 companies by market cap
Step 6: Generate Markdown Report
Use the report generation script to create a formatted markdown report from the JSON data.
Script Location:
CODEBLOCK17
Execution:
Option A: Output to stdout:
CODEBLOCK18
Option B: Save to file:
CODEBLOCK19
What the script does:
- 1. Loads earnings data from JSON file
- Groups by date and timing (BMO/AMC/TAS)
- Sorts by market cap within each group
- Calculates summary statistics
- Generates formatted markdown report
- Outputs to stdout or saves to file
The script automatically handles all formatting including:
- - Proper markdown table structure
- Date grouping and day names
- Market cap sorting
- EPS and revenue formatting
- Summary statistics calculation
Report Structure:
CODEBLOCK20
Formatting Best Practices:
- - Use markdown tables for clean presentation
- Bold important company names (mega-cap) if desired
- Include market cap in human-readable format ($3.0T, $150B, $5.2B) - already formatted by script
- Group logically by date then timing
- Include summary section at top for quick overview
- Add EPS and revenue estimates if available
Step 7: Quality Assurance
Before finalizing the report, verify:
Data Quality Checks:
- 1. ✓ All dates fall within the target week (next 7 days)
- ✓ Market cap values are present for all companies
- ✓ Each company has timing specified (BMO/AMC/TAS)
- ✓ Companies are sorted by market cap within each section
- ✓ Summary statistics are accurate
- ✓ Report generation date is clearly stated
- ✓ EPS and revenue estimates included where available
Completeness Checks:
- 1. ✓ All days of the target week are included (even if no earnings)
- ✓ Major known companies are not missing (verify against external sources if needed)
- ✓ Sector information is included where available
- ✓ Timing reference section is present
- ✓ Data sources are credited (FMP API)
Format Checks:
- 1. ✓ Markdown tables are properly formatted
- ✓ Dates are consistently formatted
- ✓ Market caps use consistent units (B for billions, T for trillions)
- ✓ All sections follow template structure
- ✓ No placeholder text ([PLACEHOLDER]) remains
- ✓ EPS and revenue estimates properly formatted
Step 8: Save and Deliver Report
Save the generated report with an appropriate filename:
Filename Convention:
CODEBLOCK21
Example: INLINECODE0
The filename date represents the report generation date, not the earnings week.
Delivery:
- - Save the markdown file to the working directory
- Inform the user that the report has been generated
- Provide a brief summary of key findings (e.g., "45 companies reporting next week, with Apple and Microsoft on Monday")
Example Summary:
CODEBLOCK22
Fallback Mode (Step 8 Alternative): Manual Data Entry
If API access is unavailable or user chooses to skip API:
Provide Instructions for Manual Entry:
CODEBLOCK23
Process Manual Input:
- 1. Parse user-provided earnings data
- Organize by date, timing, and market cap
- Generate report using same template
- Note in report: "Data Source: Manual Entry"
Use Cases and Examples
Use Case 1: Weekly Review (Primary Use Case)
User Request: "Get next week's earnings calendar"
Workflow:
- 1. Get current date (e.g., November 2, 2025)
- Calculate target week (November 3-9, 2025)
- Load FMP API guide
- Detect/request API key
- Fetch earnings data:
python scripts/fetch_earnings_fmp.py 2025-11-03 2025-11-09 > earnings_data.json
- 6. Generate markdown report:
python scripts/generate_report.py earnings_data.json earnings_calendar_2025-11-02.md
- 7. Notify user with summary
Complete One-Liner:
CODEBLOCK26
Use Case 2: Focused on Specific Day
User Request: "What earnings are coming out Monday?"
Workflow:
- 1. Get current date and identify next Monday (e.g., November 4, 2025)
- Fetch full week data (same as Use Case 1)
- Generate full report but highlight Monday section
- Provide verbal summary of Monday's earnings with emphasis
Use Case 3: Mega-Cap Focus
User Request: "Show me earnings for companies over $100B market cap next week"
Workflow:
- 1. Fetch full earnings data (script already filters >$2B)
- Process and organize as normal
- When generating report, add a "Mega-Cap Focus" section at top
- Filter tables to show only companies >$100B
- Note: Still include full data in appendix for reference
Use Case 4: Sector-Specific
User Request: "What tech companies have earnings next week?"
Workflow:
- 1. Fetch full earnings data
- Process and organize as normal
- Filter results by sector = "Technology"
- Generate report with focus on technology sector
- Note: Template structure remains the same; content is filtered
Troubleshooting
Problem: API key not working
Solutions:
- - Verify API key is correct (copy-paste carefully)
- Check if API key is active (login to FMP dashboard)
- Ensure no extra spaces before/after key
- Try generating new API key from FMP dashboard
Problem: Script returns empty results
Solutions:
- - Verify date range is in future (not past dates)
- Check date format is YYYY-MM-DD
- Try wider date range (e.g., 14 days instead of 7)
- Verify companies actually have announced earnings dates for that week
Problem: Missing major companies
Solutions:
- - Company may not have announced earnings date yet
- Some companies announce dates very late (1-2 days before)
- Cross-reference with company investor relations website
- Market cap may have dropped below $2B threshold
Problem: Rate limit hit (429 error)
Solutions:
- - Free tier: 250 calls/day
- Each weekly report uses ~3-5 API calls
- Check if other tools/scripts are using same API key
- Wait 24 hours for rate limit reset
- Consider upgrading to paid tier if needed frequently
Problem: Script execution error
Solutions:
- - Verify Python 3 is installed: INLINECODE1
- Install requests library: INLINECODE2
- Check script has execute permissions: INLINECODE3
- Run with python3 explicitly: INLINECODE4
Best Practices
Do's
✓ Always get current date first before any data retrieval
✓ Use FMP API as primary source for reliability
✓ Store API key in environment variable for CLI usage
✓ Sort by market cap to prioritize high-impact companies
✓ Group by date then timing for logical organization
✓ Include summary statistics for quick overview
✓ Credit data sources in report footer
✓ Use clean markdown tables for readability
✓ Provide timing reference section for clarity
✓ Note data freshness and potential for changes
✓ Include EPS and revenue estimates when available
Don'ts
✗ Don't assume "next week" without calculating from current date
✗ Don't omit timing information (BMO/AMC/TAS)
✗ Don't mix date formats within report (stay consistent)
✗ Don't include micro/small-cap unless specifically requested
✗ Don't forget to sort by market cap within sections
✗ Don't share API key in conversations or reports
✗ Don't include earnings from current week or past dates
✗ Don't generate report without quality assurance checks
✗ Don't commit API keys to version control
Security Notes
API Key Security
Important Reminders:
- 1. ✓ Use free tier API keys for testing
- ✓ Rotate keys regularly
- ✓ Don't share conversations containing API keys
- ✓ Set API key as environment variable for CLI
- ✓ Keys provided in chat are session-only (forgotten after session ends)
- ✗ Never commit API keys to Git repositories
- ✗ Never use production API keys with sensitive data access
Best Practice:
For Claude Code (CLI), always use environment variable:
CODEBLOCK27
For Claude Web, understand that:
- - API key entered in chat is temporary
- Stored only in conversation context
- Not saved to disk
- Forgotten when session ends
Resources
FMP API:
- - Main Documentation: https://site.financialmodelingprep.com/developer/docs
- Get API Key: https://site.financialmodelingprep.com/developer/docs
- Earnings Calendar API: https://site.financialmodelingprep.com/developer/docs/earnings-calendar-api
- Company Profile API: https://site.financialmodelingprep.com/developer/docs/companies-key-metrics-api
- Pricing/Rate Limits: https://site.financialmodelingprep.com/developer/docs/pricing
Supplementary Sources (for verification):
- - Seeking Alpha: https://seekingalpha.com/earnings/earnings-calendar
- Yahoo Finance: https://finance.yahoo.com/calendar/earnings
- MarketWatch: https://www.marketwatch.com/tools/earnings-calendar
Skill Resources:
- - FMP API Guide: INLINECODE5
- Python Script: INLINECODE6
- Report Template: INLINECODE7
Summary
This skill provides a reliable, API-driven approach to generating weekly earnings calendars for US stocks. By using FMP API, it ensures structured, accurate data with additional insights like EPS/revenue estimates. The multi-environment support makes it flexible for CLI, Desktop, and Web usage, while the fallback mode ensures functionality even without API access.
Key Workflow: Date Calculation → API Key Setup → API Data Retrieval → Processing → Report Generation → QA → Delivery
Output: Clean, organized markdown report with earnings grouped by date/timing/market cap, including summary statistics and trading considerations.
盈利日历
概述
本技能使用Financial Modeling Prep (FMP) API检索美国股票的即将发布的盈利公告。它专注于可能影响市场走势的大市值公司(中盘股及以上,市值超过20亿美元)。该技能生成结构化的Markdown报告,显示未来一周哪些公司发布盈利报告,按日期和发布时间(盘前、盘后或未公布时间)分组。
主要特点:
- - 使用FMP API获取可靠、结构化的盈利数据
- 按市值(>20亿美元)筛选,聚焦影响市场的公司
- 包含每股收益和营收预估
- 多环境支持(CLI、桌面端、Web端)
- 灵活的API密钥管理
- 按日期、发布时间和市值组织
前置条件
FMP API密钥
本技能需要Financial Modeling Prep API密钥。
获取免费API密钥:
- 1. 访问:https://site.financialmodelingprep.com/developer/docs
- 注册免费账户
- 立即获取API密钥
- 免费套餐:每天250次API调用(足够每周盈利日历使用)
按环境设置API密钥:
Claude Code (CLI):
bash
export FMPAPIKEY=your-api-key-here
Claude桌面端:
在系统中设置环境变量或配置MCP服务器。
Claude Web端:
在执行技能时会请求API密钥(仅当前会话存储)。
核心工作流程
步骤1:获取当前日期并计算目标周
关键:始终从获取准确的当前日期开始。
获取当前日期和时间:
- - 使用系统日期/时间获取今天的日期
- 注意:今天的日期在环境标签()中提供
- 计算目标周:从当前日期起未来7天
日期范围计算:
当前日期:[例如,2025年11月2日]
目标周开始:[当前日期 + 1天,例如,2025年11月3日]
目标周结束:[当前日期 + 7天,例如,2025年11月9日]
为何重要:
- - 盈利日历具有时效性
- 下周必须从实际当前日期计算
- 为API请求提供准确的日期范围
以YYYY-MM-DD格式格式化日期,以便API兼容。
步骤2:加载FMP API指南
在检索数据之前,加载全面的FMP API指南:
读取:references/fmpapiguide.md
该指南包含:
- - FMP API端点结构和参数
- 身份验证要求
- 市值筛选策略(通过公司简介API)
- 盈利时间惯例(BMO、AMC、TAS)
- 响应格式和字段描述
- 错误处理策略
- 最佳实践和优化技巧
步骤3:API密钥检测和配置
根据环境检测API密钥可用性。
多环境API密钥检测:
3.1 检查环境变量(CLI/桌面端)
bash
if [ ! -z $FMPAPIKEY ]; then
echo ✓ 在环境中找到API密钥
APIKEY=$FMPAPI_KEY
fi
如果设置了环境变量,则继续执行步骤4。
3.2 提示用户输入API密钥(桌面端/Web端)
如果未找到环境变量,使用AskUserQuestion工具:
问题配置:
问题:此技能需要FMP API密钥来检索盈利数据。您有FMP API密钥吗?
标题:API密钥
选项:
1. 是的,我现在提供 → 继续执行3.3
2. 没有,获取免费密钥 → 显示说明(3.2.1)
3. 跳过API,使用手动输入 → 跳转到步骤8(备用模式)
3.2.1 如果用户选择没有,获取免费密钥:
提供说明:
要获取免费的FMP API密钥:
- 1. 访问:https://site.financialmodelingprep.com/developer/docs
- 点击获取免费API密钥或注册
- 创建账户(邮箱+密码)
- 立即获取API密钥
- 免费套餐包含每天250次API调用(足够日常使用)
获得API密钥后,请选择是的,我现在提供继续。
3.3 请求API密钥输入
如果用户有API密钥,请求输入:
提示:
请在下方粘贴您的FMP API密钥:
(您的API密钥仅在此对话会话中存储,会话结束时将被遗忘。如需定期使用,请考虑设置FMPAPIKEY环境变量。)
将会话变量中的API密钥存储:
API_KEY = [用户输入]
向用户确认:
✓ API密钥已接收并存储用于此会话。
安全提示:
- - API密钥仅存储在当前的对话上下文中
- 不会保存到磁盘或持久存储
- 会话结束时将被遗忘
- 如果此对话包含您的API密钥,请不要分享
正在继续检索盈利数据...
步骤4:通过FMP API检索盈利数据
使用Python脚本从FMP API获取盈利数据。
脚本位置:
scripts/fetchearningsfmp.py
执行:
选项A:使用环境变量(CLI):
bash
python scripts/fetchearningsfmp.py 2025-11-03 2025-11-09
选项B:使用会话API密钥(桌面端/Web端):
bash
python scripts/fetchearningsfmp.py 2025-11-03 2025-11-09 ${API_KEY}
脚本工作流程(自动):
- 1. 验证API密钥和日期参数
- 调用FMP盈利日历API获取日期范围
- 获取公司简介(市值、板块、行业)
- 筛选市值>20亿美元的公司
- 标准化时间(BMO/AMC/TAS)
- 按日期→时间→市值(降序)排序
- 输出JSON到stdout
预期输出格式(JSON):
json
[
{
symbol: AAPL,
companyName: Apple Inc.,
date: 2025-11-04,
timing: AMC,
marketCap: 3000000000000,
marketCapFormatted: $3.0T,
sector: Technology,
industry: Consumer Electronics,
epsEstimated: 1.54,
revenueEstimated: 123400000000,
fiscalDateEnding: 2025-09-30,
exchange: NASDAQ
},
...
]
保存到文件(推荐用于报告生成器):
bash
python scripts/fetchearningsfmp.py 2025-11-03 2025-11-09 ${APIKEY} > earningsdata.json
或捕获到变量:
bash
earningsdata=$(python scripts/fetchearningsfmp.py 2025-11-03 2025-11-09 ${APIKEY})
错误处理:
如果脚本返回错误:
- - 401未授权:API密钥无效 → 验证密钥或重新输入
- 429速率限制:超过每天250次调用 → 等待或升级套餐
- 空结果:日期范围内无盈利 → 扩展日期范围或在报告中注明
- 连接错误:网络问题 → 重试或使用缓存数据(如有)
步骤5:处理和组织数据
检索到盈利数据(JSON格式)后,进行处理和组织:
5.1 解析JSON数据
从脚本输出加载JSON数据:
python
import json
earningsdata = json.loads(earningsjson_string)
或如果保存到文件:
python
with open(earnings_data.json, r) as f:
earnings_data = json.load(f)
5.2 验证数据结构
确认数据包含所需字段:
- - ✓ 股票代码
- ✓ 公司名称
- ✓ 日期
- ✓ 时间(BMO/AMC/TAS)
- ✓ 市值
- ✓ 板块
5.3 按日期分组
将所有盈利公告按日期分组:
- - 星期日,[完整日期](如适用)
- 星期一,[完整日期]
- 星期二,[完整日期]
- 星期三,[完整日期]
- 星期四,[完整日期]
- 星期五,[完整日期]
- 星期六,[完整日期](如适用)
5.4 按时间子分组
在每个日期内,创建三个子部分:
- 1. 盘前(BMO)
- 盘后(AMC)
- 时间未公布(TAS)
数据已按脚本中的时间排序,因此保持此顺序。
5.5 在每个时间组内
公司已按市值降序排序(脚本输出):
- - 超大盘股(>2000亿美元)优先
- 大盘股(100亿-2000亿美元)其次
- 中盘股(20亿-100亿美元)最后
此优先级确保最具市场影响力的公司