用于访问美国证券交易委员会(SEC)EDGAR数据库的C# .NET库,支持现代异步/等待模式和依赖注入。
"Moedim" 是一个希伯来词,意为“节日”或“约定时间”。 “约定时间”指的是在利未记第23章中提到的HaShem的节日。 节日是“信号和标志”,帮助我们了解HaShem的心意。
如果您考虑聘请我,请发送电子邮件。
如果您喜欢或正在使用这个项目来学习或启动您的解决方案,请给它一个星。谢谢!
dotnet add package Moedim.Edgar
通过Model Context Protocol (MCP)集成AI助手,安装配套的MCP服务器包:
# 通过dnx安装(推荐)
dnx Moedim.Edgar.Mcp --version 1.0.0 --yes
MCP服务器提供:
详见src/Moedim.Edgar.Mcp/README.md的完整文档。
using Moedim.Edgar.Extensions;
services.AddSecEdgar(options =>
{
options.AppName = "YourCompany";
options.AppVersion = "1.0.0";
options.Email = "your@email.com";
options.RequestDelay = TimeSpan.FromMilliseconds(100);
options.MaxRetryCount = 3;
});
using Moedim.Edgar.Models;
public class FinancialDataService
{
private readonly ICompanyFactsService _companyFactsService;
private readonly ICompanyConceptService _companyConceptService;
public FinancialDataService(
ICompanyFactsService companyFactsService,
ICompanyConceptService companyConceptService)
{
_companyFactsService = companyFactsService;
_companyConceptService = companyConceptService;
}
public async Task<CompanyFactsQuery> GetCompanyFactsAsync(int cik)
{
return await _companyFactsService.QueryAsync(cik);
}
public async Task<CompanyConceptQuery> GetRevenueDataAsync(int cik)
{
return await _companyConceptService.QueryAsync(cik, "Revenues");
}
}
// 获取公司的所有事实(例如,苹果公司 - CIK:320193)
var facts = await companyFactsService.QueryAsync(320193);
// 访问公司信息
Console.WriteLine($"公司: {facts.EntityName}");
Console.WriteLine($"CIK: {facts.Cik}");
// 遍历事实
foreach (var fact in facts.Facts)
{
Console.WriteLine($"概念: {fact.Label}");
Console.WriteLine($"值: {fact.Value}");
}
// 获取特定财务概念(例如,收入)
var revenues = await companyConceptService.QueryAsync(320193, "Revenues");
// 访问数据点
foreach (var dataPoint in revenues.DataPoints)
{
Console.WriteLine($"期间: {dataPoint.FiscalPeriod}");
Console.WriteLine($"值: {dataPoint.Value:C}");
Console.WriteLine($"提交日期: {dataPoint.Filed:d}");
}
// 将完整文件作为干净的Markdown获取
var markdown = await filingDetailsService.GetFilingDocumentAsync(
accessionNumber: "0000320193-23-000077",
tickerOrCik: "AAPL",
format: "markdown"
);
// 或者获取为HTML
var html = await filingDetailsService.GetFilingDocumentAsync(
accessionNumber: "0000320193-23-000077",
format: "html"
);
// 首先,预览可用的部分
var previewRequest = new FilingSectionsRequest { PreviewOnly = true };
var preview = await filingDetailsService.GetFilingSectionsAsync(
accessionNumber: "0000320193-23-000077",
request: previewRequest
);
// 显示可用部分
foreach (var section in preview.Preview)
{
Console.WriteLine($"{section.AnchorTargetId}: {section.Label}");
}
// 然后,获取特定部分
var sectionsRequest = new FilingSectionsRequest
{
PreviewOnly = false,
AnchorIds = new[] { "item_1a_risk_factors", "item_7_managements_discussion_analysis" },
Merge = true, // 合并部分为单个内容
Format = "markdown"
};
var result = await filingDetailsService.GetFilingSectionsAsync(
accessionNumber: "0000320193-23-000077",
request: sectionsRequest
);
Console.WriteLine(result.MergedContent); // 选择部分的干净Markdown
services.AddSecEdgar(options =>
{
// 必需:SEC需要识别
options.AppName = "YourCompany";
options.AppVersion = "1.0.0";
options.Email = "your@email.com";
// 可选:请求之间的延迟(默认:250毫秒)
options.RequestDelay = TimeSpan.FromMilliseconds(100);
// 可选:达到速率限制后的延迟(默认:2秒)
options.TimeoutDelay = TimeSpan.FromSeconds(1);
// 可选:最大重试次数(默认:10)
options.MaxRetryCount = 3;
// 可选:覆盖重试行为(显示默认值)
options.RetryCountOverride = 5; // 包括初始调用在内的总尝试次数
options.RetryDelay = TimeSpan.FromSeconds(1); // 当没有返回Retry-After头时的回退
options.UseExponentialBackoff = true; // 每次重试后乘以延迟
options.RetryBackoffMultiplier = 1.5; // 指数策略的增长因子
});
Services/ - SEC EDGAR客户端和服务实现Models/ - 数据模型和查询类型Extensions/ - 依赖注入扩展Tools/ - MCP工具实现(17种工具)Prompts/ - 引导分析工作流(6种提示)IFilingDetailsService现在支持以Markdown或HTML格式下载完整的文件文档:
Task<string?> GetFilingDocumentAsync(
string accessionNumber,
string? tickerOrCik = null,
string? format = null,
CancellationToken cancellationToken = default);
使用两步工作流程从文件中提取特定部分:
步骤1:预览部分
Task<FilingSectionsResult?> GetFilingSectionsAsync(
string accessionNumber,
FilingSectionsRequest request,
string? tickerOrCik = null,
CancellationToken cancellationToken = default);
当request.PreviewOnly = true时,返回部分ID和标题而无完整内容。
步骤2:获取完整部分
当request.PreviewOnly = false且指定request.AnchorIds时,返回所选部分的完整内容。
FilingSectionsRequest属性:
PreviewOnly - 返回仅部分元数据AnchorIds - 要检索的部分ID列表Format - "markdown"(默认)或"html"Merge - 将所有部分合并为单个内容块内置缓存减少API调用并提高性能:
.edgar_cache欢迎贡献!请随意提交Pull Request。
本项目采用MIT许可证 - 详情见LICENSE文件。
使用以下技术构建:
查看CHANGELOG.md了解版本历史和发布说明。