mcpField
S
sec-edgar-skill

sec-edgar-skill

github.com/rebyteai-template数据与数据库17254 次安装19 周前更新
代码仓库

关于 sec-edgar-skill

sec-edgar-skill 是借助 EdgarTools 查询和分析 SEC EDGAR 文件及财务数据的技能,适用于公司研究、申报监控和跨公司比较。它覆盖文件检索、结构化 XBRL 数据和文件内搜索,并强调先读取精简上下文。

主要功能

  1. 01按表格类型和日期检索申报文件
  2. 02查看公司及最新申报信息
  3. 03提取多期财务报表与 XBRL 数据
  4. 04搜索申报文件正文
  5. 05分析 Form 4 内部人交易
  6. 06优先读取精简上下文

适用场景

  1. 01比较多家公司的收入趋势
  2. 02分析最新 10-K 年报
  3. 03跟踪 Form 4 内部人交易
  4. 04监控指定类型的近期申报

安装

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

$npx skills add https://github.com/rebyteai-template/rebyte-skills --skill sec-edgar-skill

安装后在 Claude Code 中输入/sec-edgar-skill确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

.gitignore
README.md
requirements.txt
reference/
form-types.md
objects.md
workflows.md

详细介绍

SEC EDGAR 技能 - 文件分析

前置条件

重要:在进行任何 EdgarTools 操作之前,务必运行此设置:

from edgar import set_identity
set_identity("Your Name [email protected]")  # SEC requires identification

这是 SEC 法律要求。未进行设置,操作将会失败。


安装

必须安装 EdgarTools:

pip install edgartools

Token 效率策略

始终优先使用 .to_context() —— 它提供的摘要可减少 56%–89% 的 Token 消耗:

对象repr() Token 数.to_context() Token 数节省比例
Company~750~7590%
Filing~125~5060%
XBRL~2,500~27589%
Statement~1,250~40068%

**规则:**先调用 .to_context() 了解可用内容,再深入查看。


访问文件的三种方式

1. 已发布文件 - 跨公司批量分析
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"])
2. 最新文件 - 实时监控
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")
3. 公司文件 - 单一实体分析
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()

财务数据访问

方法 1:Entity Facts API(快速、多期间)

适用于比较各期间的趋势:

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)
方法 2:文件 XBRL(详细、单一期间)

适用于全面分析单份文件:

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

常见工作流

工作流 1:比较不同公司的收入
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)
工作流 2:分析最新的 10-K
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.
工作流 3:追踪内部人士交易
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())
工作流 4:监控各行业近期提交的文件
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
工作流 5:多年财务趋势
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)

在文件中搜索

重要区别:

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")

请勿混淆!


关键对象参考

Company
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
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(财务数据)
xbrl = filing.xbrl()
xbrl.to_context()     # Summary
xbrl.statements       # All financial statements
xbrl.facts            # Individual facts/metrics
Statement(财务报表)
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...
应当:使用结构化 XBRL 数据
# 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

表格类型速查

表格描述用途
10-K年度报告全年财务数据、业务描述
10-Q季度报告季度财务数据
8-K当前报告重大事件(并购、管理层变动)
DEF 14A委托书高管薪酬、董事会信息
4内部人士交易内部人士的股票交易
13F机构持仓对冲基金持有哪些资产
S-1IPO 注册文件IPO 前提交的文件
424B招股说明书债券/股票发行

错误处理

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")

性能提示

  1. 检索前先筛选:使用表格类型和日期筛选条件
  2. 趋势分析使用 Entity Facts API:比解析多份文件更快
  3. 批量操作:通过循环处理多家公司
  4. 缓存结果:存储经常访问的数据

参考文档

详细文档请参阅:

也可以使用内置文档:

from edgar import Company
company = Company("AAPL")
company.docs.search("how to get revenue")

评论

支持 Markdown