sec-data
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSEC Data — Financial Statements from SEC EDGAR
SEC数据 — 来自SEC EDGAR的财务报表
Acceso a datos financieros estructurados de la SEC EDGAR mediante la librería + la API JSON de XBRL facts de la SEC.
secfiObtiene income statements, balance sheets, cash flow statements en formato JSON/CSV estructurado directamente de los filings XBRL.
Soporta US-GAAP (empresas US) e IFRS (empresas extranjeras) con mapping automático de conceptos.
通过库 + SEC的XBRL事实JSON API,获取SEC EDGAR的结构化财务数据。
secfi可直接从XBRL filings中获取结构化JSON/CSV格式的利润表(income statements)、资产负债表(balance sheets)、现金流量表(cash flow statements)。
支持US-GAAP(美国企业)和IFRS(外国企业),并自动映射相关概念。
Dependencia
依赖
bash
pip install secfiRequiere y (vienen con secfi).
pandasrequestsbash
pip install secfi需要和(随secfi一同安装)。
pandasrequestsCómo funciona
工作原理
La SEC expone datos financieros estructurados via dos endpoints JSON:
| Endpoint | Descripción |
|---|---|
| Company Facts | |
| Company Concept | |
El flujo típico:
- → obtiene el CIK del ticker
secfi.getCiks() - Fetch → obtiene todos los datos financieros estructurados
companyfacts/CIK{cik}.json - El script mapea automáticamente conceptos US-GAAP ↔ IFRS según la taxonomía
SEC通过两个JSON端点提供结构化财务数据:
| 端点 | 描述 |
|---|---|
| Company Facts | |
| Company Concept | |
典型流程:
- → 获取股票代码对应的CIK
secfi.getCiks() - 获取→ 获取所有结构化财务数据
companyfacts/CIK{cik}.json - 脚本根据分类法自动映射US-GAAP ↔ IFRS概念
Taxonomías soportadas
支持的分类法
| Taxonomía | Empresas | Formularios | Ejemplos |
|---|---|---|---|
| Empresas US | 10-K, 10-Q | AAPL, MSFT, NVDA |
| Empresas extranjeras (Foreign Private Issuers) | 20-F, 6-K | GGAL, BABA, SAP, SPOT |
El script detecta automáticamente la taxonomía y resuelve los conceptos usando un mapping US-GAAP ↔ IFRS.
| 分类法 | 适用企业 | 表单 | 示例 |
|---|---|---|---|
| 美国企业 | 10-K、10-Q | AAPL、MSFT、NVDA |
| 外国私人发行商(Foreign Private Issuers) | 20-F、6-K | GGAL、BABA、SAP、SPOT |
脚本会自动检测分类法,并使用US-GAAP ↔ IFRS映射表解析概念。
Autenticación
身份验证
python
HEADERS = {"User-Agent": "osojuanferpity@xmail.com"}La SEC bloquea requests sin User-Agent válido (403 Forbidden). Usar el mismo email que usa internamente.
secfipython
HEADERS = {"User-Agent": "osojuanferpity@xmail.com"}SEC会拦截无有效User-Agent的请求(返回403 Forbidden)。请使用与内部相同的邮箱。
secfiScript principal: fetch_financials.py
fetch_financials.py主脚本:fetch_financials.py
fetch_financials.pybash
undefinedbash
undefinedAAPL (US-GAAP) — todo
AAPL(US-GAAP)—— 获取全部数据
python scripts/fetch_financials.py --ticker AAPL --all
python scripts/fetch_financials.py --ticker AAPL --all
GGAL (IFRS) — todo
GGAL(IFRS)—— 获取全部数据
python scripts/fetch_financials.py --ticker GGAL --all
python scripts/fetch_financials.py --ticker GGAL --all
Solo income statement
仅获取利润表
python scripts/fetch_financials.py --ticker MSFT --income
python scripts/fetch_financials.py --ticker MSFT --income
Solo balance + cash flow
仅获取资产负债表 + 现金流量表
python scripts/fetch_financials.py --ticker NVDA --balance --cashflow
python scripts/fetch_financials.py --ticker NVDA --balance --cashflow
Todos los conceptos disponibles (no solo core)
获取所有可用概念(不限于核心概念)
python scripts/fetch_financials.py --ticker AAPL --all --all-concepts
python scripts/fetch_financials.py --ticker AAPL --all --all-concepts
Output personalizado
自定义输出路径
python scripts/fetch_financials.py --ticker AAPL --all --output data/aapl
python scripts/fetch_financials.py --ticker AAPL --all --output data/aapl
Solo anual (default)
仅获取年度数据(默认)
python scripts/fetch_financials.py --ticker AAPL --all
python scripts/fetch_financials.py --ticker AAPL --all
Incluir trimestral también
同时包含季度数据
python scripts/fetch_financials.py --ticker AAPL --all --quarterly
undefinedpython scripts/fetch_financials.py --ticker AAPL --all --quarterly
undefinedFlags disponibles
可用参数
| Flag | Descripción |
|---|---|
| Ticker a consultar (requerido) |
| Fetch de income + balance + cashflow |
| Solo income statement |
| Solo balance sheet |
| Solo cash flow statement |
| Todos los conceptos disponibles en la taxonomía (default: solo core) |
| Solo datos anuales (default) |
| Incluir datos trimestrales |
| Prefijo de archivos de salida |
| Sin salida detallada |
| 参数 | 描述 |
|---|---|
| 要查询的股票代码(必填) |
| 获取利润表 + 资产负债表 + 现金流量表 |
| 仅获取利润表 |
| 仅获取资产负债表 |
| 仅获取现金流量表 |
| 获取分类法中所有可用概念(默认:仅核心概念) |
| 仅获取年度数据(默认) |
| 包含季度数据 |
| 输出文件前缀 |
| 不显示详细输出 |
Output generado
生成的输出文件
{ticker}_financials.json → JSON completo con todos los conceptos
{ticker}_financials.csv → CSV tabular aplanado (concepto x entry)
{ticker}_financials_income_annual.csv → Matriz concepto x año (income)
{ticker}_financials_balance_annual.csv → Matriz concepto x año (balance)
{ticker}_financials_cashflow_annual.csv → Matriz concepto x año (cash flow){ticker}_financials.json → 包含所有概念的完整JSON数据
{ticker}_financials.csv → 扁平化表格CSV(概念×条目)
{ticker}_financials_income_annual.csv → 利润表概念×年度矩阵
{ticker}_financials_balance_annual.csv → 资产负债表概念×年度矩阵
{ticker}_financials_cashflow_annual.csv → 现金流量表概念×年度矩阵Mapping IFRS automático
IFRS自动映射
El script incluye un diccionario con 33+ conceptos US-GAAP mapeados a sus equivalentes IFRS. Por ejemplo:
IFRS_MAP| US-GAAP | IFRS (ifrs-full) |
|---|---|
| |
| |
| |
| |
| |
脚本包含字典,其中33+个US-GAAP概念已映射到对应的IFRS概念。例如:
IFRS_MAP| US-GAAP | IFRS (ifrs-full) |
|---|---|
| |
| |
| |
| |
| |
Free Cash Flow (FCF)
自由现金流(FCF)
El script calcula automáticamente el FCF:
FCF = Operating CF - CAPEXTanto para US-GAAP como IFRS.
脚本会自动计算FCF:
FCF = 经营现金流 - 资本支出适用于US-GAAP和IFRS。
Testeado con
测试案例
AAPL (US-GAAP) — 55 conceptos extraídos ✅
AAPL(US-GAAP)—— 提取55个概念 ✅
>> Company facts: 4053 KB
>> Income: 13 conceptos x 17 años
>> Balance: 24 conceptos x 17 años
>> Cash flow: 18 conceptos x 17 años
>> FCF 2025: $98.7B>> 企业数据:4053 KB
>> 利润表:13个概念×17年
>> 资产负债表:24个概念×17年
>> 现金流量表:18个概念×17年
>> 2025年FCF:987亿美元GGAL (IFRS) — 40 conceptos extraídos ✅
GGAL(IFRS)—— 提取40个概念 ✅
>> Company facts: 724 KB
>> Revenue: $7.72B (2024) · Net Income: $1.76B (2024)
>> Balance: Assets $35.3B · Equity $6.58B
>> Cash flow: Operating $3.80B · FCF $3.57B>> 企业数据:724 KB
>> 营收:77.2亿美元(2024年)· 净利润:17.6亿美元(2024年)
>> 资产负债表:资产353亿美元 · 权益65.8亿美元
>> 现金流量表:经营现金流38亿美元 · FCF35.7亿美元Rate Limits
请求速率限制
| Límite | Comportamiento |
|---|---|
| ~10 req/s | Límite SEC |
| Sin API key | Público, requiere User-Agent con email |
| Datos históricos | No cambian — cachear respuestas |
| 限制 | 表现 |
|---|---|
| ~10次/秒 | SEC限制 |
| 无需API密钥 | 公开访问,需带含邮箱的User-Agent |
| 历史数据 | 不会变更 — 建议缓存响应 |
Errores comunes
常见错误
| Error | Causa | Solución |
|---|---|---|
| User-Agent inválido | Usar |
| CIK incorrecto | Verificar con |
| No está en SEC | Solo empresas que reportan a SEC |
| Usa IFRS | El script lo resuelve automáticamente |
| 错误 | 原因 | 解决方案 |
|---|---|---|
| User-Agent无效 | 使用 |
| CIK错误 | 使用 |
| 未在SEC备案 | 仅支持向SEC提交报告的企业 |
| 使用IFRS | 脚本会自动处理 |
Estructura del skill
Skill结构
skills/sec-data/
├── SKILL.md # Este archivo
├── references/
│ └── FINANCIALS_REFERENCE.md # Referencia completa: todos los conceptos + mapping IFRS
└── scripts/
└── fetch_financials.py # Script principal con mapping IFRS automáticoskills/sec-data/
├── SKILL.md # 本文档
├── references/
│ └── FINANCIALS_REFERENCE.md # 完整参考:所有概念 + IFRS映射表
└── scripts/
└── fetch_financials.py # 带IFRS自动映射的主脚本