sec-edgar-skill by eng0ai/eng0-template-skills
npx skills add https://github.com/eng0ai/eng0-template-skills --skill sec-edgar-skill关键:在任何 EdgarTools 操作之前运行此设置:
from edgar import set_identity
set_identity("Your Name your.email@example.com") # SEC 要求身份识别
这是 SEC 的法律要求。没有它,操作将失败。
必须安装 EdgarTools:
pip install edgartools
始终首先使用 .to_context() - 它提供的摘要可减少 56-89% 的令牌:
| 对象 | repr() 令牌数 | .to_context() 令牌数 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 节省 |
|---|
| 公司 | ~750 | ~75 | 90% |
| 文件 | ~125 | ~50 | 60% |
| XBRL | ~2,500 | ~275 | 89% |
| 报表 | ~1,250 | ~400 | 68% |
规则: 首先调用 .to_context() 以了解可用的内容,然后再深入分析。
from edgar import get_filings
# 获取最近的 10-K 文件
filings = get_filings(form="10-K")
# 按日期范围筛选
filings = get_filings(form="10-K", year=2024, quarter=1)
# 多种表格类型
filings = get_filings(form=["10-K", "10-Q"])
from edgar import get_current_filings
# 从 RSS 源获取今天的文件
current = get_current_filings()
# 按表格类型筛选
current_10k = get_current_filings().filter(form="10-K")
from edgar import Company
# 通过股票代码
company = Company("AAPL")
# 通过 CIK
company = Company("0000320193")
# 获取公司的文件
filings = company.get_filings(form="10-K")
latest_10k = filings.latest()
最适合跨期间比较趋势:
company = Company("AAPL")
# 获取多个期间的利润表
income = company.income_statement(periods=5)
print(income) # 显示 5 年的数据
# 获取资产负债表
balance = company.balance_sheet(periods=3)
# 获取现金流量表
cashflow = company.cash_flow_statement(periods=3)
最适合全面的单文件分析:
company = Company("AAPL")
filing = company.get_filings(form="10-K").latest()
# 获取 XBRL 数据
xbrl = filing.xbrl()
# 访问财务报表
statements = xbrl.statements
income_stmt = statements.income_statement
balance_sheet = statements.balance_sheet
cash_flow = statements.cash_flow_statement
from edgar import Company
companies = ["AAPL", "MSFT", "GOOGL"]
for ticker in companies:
company = Company(ticker)
income = company.income_statement(periods=3)
print(f"\n{ticker} 收入趋势:")
print(income)
from edgar import Company
company = Company("NVDA")
filing = company.get_filings(form="10-K").latest()
# 获取文件元数据
print(filing.to_context())
# 获取全文(昂贵 - 50K+ 令牌)
# text = filing.text()
# 获取特定章节
# items = filing.items() # 风险因素、管理层讨论与分析等
from edgar import Company
company = Company("TSLA")
insider_filings = company.get_filings(form="4") # 表格 4 = 内幕交易
for filing in insider_filings[:10]:
print(filing.to_context())
from edgar import get_filings
# 获取最近的科技公司 10-K 文件(使用 SIC 代码)
# SIC 7370-7379 = 计算机编程、数据处理
filings = get_filings(form="10-K", year=2024)
# 检索后按公司特征筛选
from edgar import Company
company = Company("AMZN")
# 5 年利润表
income = company.income_statement(periods=20) # 20 个季度 = 5 年
# 5 年资产负债表
balance = company.balance_sheet(periods=20)
print("利润表趋势:")
print(income)
print("\n资产负债表趋势:")
print(balance)
关键区别:
filing = company.get_filings(form="10-K").latest()
# 在文件文档内搜索(在 10-K 中查找文本)
results = filing.search("climate risk")
# 搜索 API 文档(查找如何使用 EdgarTools)
docs_results = filing.docs.search("how to extract")
不要混淆这两者!
company = Company("AAPL")
company.to_context() # 摘要及可用操作
company.name # 公司名称
company.cik # CIK 号码
company.sic # SIC 代码
company.industry # 行业描述
company.get_filings() # 访问文件
filing.to_context() # 摘要
filing.form # 表格类型 (10-K, 10-Q 等)
filing.filing_date # 提交日期
filing.accession_number
filing.text() # 完整文档文本(昂贵)
filing.markdown() # Markdown 格式
filing.xbrl() # XBRL 财务数据
filing.items() # 文档章节
xbrl = filing.xbrl()
xbrl.to_context() # 摘要
xbrl.statements # 所有财务报表
xbrl.facts # 个别事实/指标
stmt = xbrl.statements.income_statement
print(stmt) # ASCII 表格格式
stmt.to_dataframe() # Pandas DataFrame
# 错误 - 昂贵且容易出错
text = filing.text()
# 尝试从文本中正则解析收入...
# 正确 - 结构化且准确
income = company.income_statement(periods=3)
# 错误 - 浪费令牌
text = filing.text() # 50K+ 令牌
# 正确 - 最少令牌
print(filing.to_context()) # ~50 令牌
| 表格 | 描述 | 用例 |
|---|---|---|
| 10-K | 年度报告 | 全年财务数据、业务描述 |
| 10-Q | 季度报告 | 季度财务数据 |
| 8-K | 当期报告 | 重大事件(并购、高管变动) |
| DEF 14A | 委托声明书 | 高管薪酬、董事会信息 |
| 4 | 内幕交易 | 内部人士股票交易 |
| 13F | 机构持仓 | 对冲基金持有的资产 |
| S-1 | IPO 注册 | 上市前文件 |
| 424B | 招股说明书 | 债券/股票发行 |
from edgar import Company
try:
company = Company("INVALID")
except Exception as e:
print(f"未找到公司:{e}")
# 检查文件是否存在
filings = company.get_filings(form="10-K")
if len(filings) == 0:
print("未找到 10-K 文件")
详细文档请参阅:
或使用内置文档:
from edgar import Company
company = Company("AAPL")
company.docs.search("how to get revenue")
每周安装次数
78
代码库
GitHub 星标数
3
首次出现
2026年1月22日
安全审计
安装于
codex69
gemini-cli66
opencode66
github-copilot63
cursor63
amp57
CRITICAL: Run this setup before ANY EdgarTools operations:
from edgar import set_identity
set_identity("Your Name your.email@example.com") # SEC requires identification
This is a SEC legal requirement. Operations will fail without it.
EdgarTools must be installed:
pip install edgartools
ALWAYS use.to_context() first - it provides summaries with 56-89% fewer tokens:
| Object | repr() tokens | .to_context() tokens | Savings |
|---|---|---|---|
| Company | ~750 | ~75 | 90% |
| Filing | ~125 | ~50 | 60% |
| XBRL | ~2,500 | ~275 | 89% |
| Statement | ~1,250 | ~400 | 68% |
Rule: Call .to_context() first to understand what's available, then drill down.
from edgar import get_filings
# Get recent 10-K filings
filings = get_filings(form="10-K")
# Filter by date range
filings = get_filings(form="10-K", year=2024, quarter=1)
# Multiple form types
filings = get_filings(form=["10-K", "10-Q"])
from edgar import get_current_filings
# Get today's filings from RSS feed
current = get_current_filings()
# Filter by form type
current_10k = get_current_filings().filter(form="10-K")
from edgar import Company
# By ticker
company = Company("AAPL")
# By CIK
company = Company("0000320193")
# Get company's filings
filings = company.get_filings(form="10-K")
latest_10k = filings.latest()
Best for comparing trends across periods:
company = Company("AAPL")
# Get income statement for multiple periods
income = company.income_statement(periods=5)
print(income) # Shows 5 years of data
# Get balance sheet
balance = company.balance_sheet(periods=3)
# Get cash flow
cashflow = company.cash_flow_statement(periods=3)
Best for comprehensive single-filing analysis:
company = Company("AAPL")
filing = company.get_filings(form="10-K").latest()
# Get XBRL data
xbrl = filing.xbrl()
# Access financial statements
statements = xbrl.statements
income_stmt = statements.income_statement
balance_sheet = statements.balance_sheet
cash_flow = statements.cash_flow_statement
from edgar import Company
companies = ["AAPL", "MSFT", "GOOGL"]
for ticker in companies:
company = Company(ticker)
income = company.income_statement(periods=3)
print(f"\n{ticker} Revenue Trend:")
print(income)
from edgar import Company
company = Company("NVDA")
filing = company.get_filings(form="10-K").latest()
# Get filing metadata
print(filing.to_context())
# Get full text (expensive - 50K+ tokens)
# text = filing.text()
# Get specific sections
# items = filing.items() # Risk factors, MD&A, etc.
from edgar import Company
company = Company("TSLA")
insider_filings = company.get_filings(form="4") # Form 4 = insider trades
for filing in insider_filings[:10]:
print(filing.to_context())
from edgar import get_filings
# Get recent tech 10-Ks (use SIC codes)
# SIC 7370-7379 = Computer Programming, Data Processing
filings = get_filings(form="10-K", year=2024)
# Filter by company characteristics after retrieval
from edgar import Company
company = Company("AMZN")
# 5-year income statement
income = company.income_statement(periods=20) # 20 quarters = 5 years
# 5-year balance sheet
balance = company.balance_sheet(periods=20)
print("Income Statement Trend:")
print(income)
print("\nBalance Sheet Trend:")
print(balance)
CRITICAL DISTINCTION:
filing = company.get_filings(form="10-K").latest()
# Search WITHIN the filing document (finds text in the 10-K)
results = filing.search("climate risk")
# Search API DOCUMENTATION (finds how to use EdgarTools)
docs_results = filing.docs.search("how to extract")
Do NOT mix these up!
company = Company("AAPL")
company.to_context() # Summary with available actions
company.name # Company name
company.cik # CIK number
company.sic # SIC code
company.industry # Industry description
company.get_filings() # Access filings
filing.to_context() # Summary
filing.form # Form type (10-K, 10-Q, etc.)
filing.filing_date # Date filed
filing.accession_number
filing.text() # Full document text (EXPENSIVE)
filing.markdown() # Markdown format
filing.xbrl() # XBRL financial data
filing.items() # Document sections
xbrl = filing.xbrl()
xbrl.to_context() # Summary
xbrl.statements # All financial statements
xbrl.facts # Individual facts/metrics
stmt = xbrl.statements.income_statement
print(stmt) # ASCII table format
stmt.to_dataframe() # Pandas DataFrame
# BAD - expensive and error-prone
text = filing.text()
# try to regex parse revenue from text...
# GOOD - structured and accurate
income = company.income_statement(periods=3)
# BAD - wastes tokens
text = filing.text() # 50K+ tokens
# GOOD - minimal tokens
print(filing.to_context()) # ~50 tokens
| Form | Description | Use Case |
|---|---|---|
| 10-K | Annual report | Full-year financials, business description |
| 10-Q | Quarterly report | Quarterly financials |
| 8-K | Current report | Material events (M&A, exec changes) |
| DEF 14A | Proxy statement | Executive comp, board info |
| 4 | Insider trading | Stock transactions by insiders |
| 13F | Institutional holdings | What hedge funds own |
| S-1 | IPO registration | Pre-IPO filings |
| 424B | Prospectus |
from edgar import Company
try:
company = Company("INVALID")
except Exception as e:
print(f"Company not found: {e}")
# Check if filings exist
filings = company.get_filings(form="10-K")
if len(filings) == 0:
print("No 10-K filings found")
For detailed documentation, see:
Or use the built-in docs:
from edgar import Company
company = Company("AAPL")
company.docs.search("how to get revenue")
Weekly Installs
78
Repository
GitHub Stars
3
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykWarn
Installed on
codex69
gemini-cli66
opencode66
github-copilot63
cursor63
amp57
DOCX文件创建、编辑与分析完整指南 - 使用docx-js、Pandoc和Python脚本
51,800 周安装
| Bond/stock offerings |