sec-edgar-api 0.5.10 → 0.5.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -150,11 +150,11 @@ function buildReportsFromFacts(params) {
150
150
  return { reportFocus: reportFocus, reportByDateRange: reportByDateRange, factsFiltered: Array.from(factByName.values()) };
151
151
  }
152
152
  function parseXbrl(params) {
153
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
153
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
154
154
  var parser = new XBRLParser_1.default();
155
- var xml = params.xml, _o = params.includeReport, includeReport = _o === void 0 ? true : _o, options = __rest(params, ["xml", "includeReport"]);
155
+ var xml = params.xml, _p = params.includeReport, includeReport = _p === void 0 ? true : _p, options = __rest(params, ["xml", "includeReport"]);
156
156
  var response = parser.parse(xml, options);
157
- var _p = (_b = (_a = response.instance) === null || _a === void 0 ? void 0 : _a.xbrl) !== null && _b !== void 0 ? _b : {}, _q = _p.contexts, contexts = _q === void 0 ? [] : _q, _r = _p.factElements, factElements = _r === void 0 ? [] : _r;
157
+ var _q = (_b = (_a = response.instance) === null || _a === void 0 ? void 0 : _a.xbrl) !== null && _b !== void 0 ? _b : {}, _r = _q.contexts, contexts = _r === void 0 ? [] : _r, _s = _q.factElements, factElements = _s === void 0 ? [] : _s;
158
158
  var contextById = new Map();
159
159
  contexts.forEach(function (context) { return contextById.set(context.id, context); });
160
160
  var cik = response.header.cik;
@@ -201,12 +201,12 @@ function parseXbrl(params) {
201
201
  if (!reportDate) {
202
202
  throw new Error("Report date not found. Unable to determine fiscal year and period. accn: ".concat(accessionNumber));
203
203
  }
204
- var _s = fiscalCalculator.getFiscalYearQuarter({ dateStr: reportDate !== null && reportDate !== void 0 ? reportDate : '' }), quarter = _s.quarter, year = _s.year;
204
+ var _t = fiscalCalculator.getFiscalYearQuarter({ dateStr: reportDate !== null && reportDate !== void 0 ? reportDate : '' }), quarter = _t.quarter, year = _t.year;
205
205
  fiscalYear = year;
206
206
  fiscalPeriod = (quarter === 4 ? 'FY' : "Q".concat(quarter));
207
207
  }
208
208
  var factsForBuilder = includeReport ? facts : [];
209
- var _t = buildReportsFromFacts({
209
+ var _u = buildReportsFromFacts({
210
210
  facts: factsForBuilder,
211
211
  pathSeparator: '>',
212
212
  fiscalPeriod: (_k = factsForBuilder.find(function (f) { return f.name === 'dei:DocumentFiscalPeriodFocus'; })) === null || _k === void 0 ? void 0 : _k.value,
@@ -230,7 +230,29 @@ function parseXbrl(params) {
230
230
  url: "https://www.sec.gov/Archives/edgar/data/".concat(cik, "/").concat(accessionNumberNoHyphens, "/").concat(accessionNumber, ".txt"),
231
231
  urlPrimaryDocument: '',
232
232
  },
233
- }), factsFiltered = _t.factsFiltered, reportFocus = _t.reportFocus, reportByDateRange = _t.reportByDateRange;
234
- return __assign(__assign({}, response), { fiscalYear: fiscalYear, fiscalPeriod: fiscalPeriod, facts: factsFiltered, report: factsFiltered.length > 0 ? reportFocus : null, xml: xml, periodReports: Object.values(reportByDateRange) });
233
+ }), factsFiltered = _u.factsFiltered, reportFocus = _u.reportFocus, reportByDateRange = _u.reportByDateRange;
234
+ // Some concepts have members, but do not have a sum. add the sum to the report.
235
+ var periodReports = Object.values(reportByDateRange);
236
+ for (var _v = 0, periodReports_1 = periodReports; _v < periodReports_1.length; _v++) {
237
+ var report = periodReports_1[_v];
238
+ for (var key in report) {
239
+ if (!key.includes('>'))
240
+ continue;
241
+ var parts = key.split('>');
242
+ var concept = parts.shift();
243
+ var center = parts.slice(0, -1).join('>');
244
+ if (!concept || report[concept] !== undefined)
245
+ continue;
246
+ var sum = 0;
247
+ for (var k in report) {
248
+ var prefix = "".concat(concept, ">").concat(center, ">");
249
+ if (k.startsWith(prefix) && !((_o = k.split(prefix).pop()) === null || _o === void 0 ? void 0 : _o.includes('>'))) {
250
+ sum += Number(typeof report[k] === 'number' ? report[k] : 0);
251
+ }
252
+ }
253
+ report[concept] = sum;
254
+ }
255
+ }
256
+ return __assign(__assign({}, response), { fiscalYear: fiscalYear, fiscalPeriod: fiscalPeriod, facts: factsFiltered, report: factsFiltered.length > 0 ? reportFocus : null, xml: xml, periodReports: periodReports });
235
257
  }
236
258
  exports.parseXbrl = parseXbrl;
@@ -48,7 +48,7 @@ var ReportRawBuilder = /** @class */ (function () {
48
48
  }
49
49
  var reportsCik = Number(facts[0].cik);
50
50
  var fiscalCalculator = new FactFiscalCalculator_1.default({
51
- filings: filings === null || filings === void 0 ? void 0 : filings.filter(function (f) { return constants_1.FORMS_EARNINGS.includes(f.form); }),
51
+ filings: filings === null || filings === void 0 ? void 0 : filings.filter(function (f) { return constants_1.FORMS_EARNINGS.includes(f.form) && Boolean(f.reportDate); }),
52
52
  facts: facts,
53
53
  fiscalYearEnd: fiscalYearEnd,
54
54
  });
@@ -292,6 +292,8 @@ export default class SecEdgarApi {
292
292
  /**
293
293
  * Gets list of filings for a day up to 5 days ago.
294
294
  *
295
+ * NOTE: This has not been updated since 2014 and has had issues with not returning data.
296
+ *
295
297
  * @see https://www.sec.gov/edgar/searchedgar/currentevents
296
298
  */
297
299
  getCurrentFilingsDaily(params?: {
@@ -310,8 +312,16 @@ export default class SecEdgarApi {
310
312
  filedDate: string;
311
313
  }[];
312
314
  }>;
315
+ /**
316
+ * Lists all types of current filings including non XBRL. If fetching earnings reports,
317
+ * use getCurrentFilingsXbrl instead.
318
+ *
319
+ * @see https://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent
320
+ */
313
321
  getCurrentFilings(params?: GetCurrentFilingsParams): Promise<import("../../types").CurrentFilingsList>;
314
322
  /**
323
+ * Fetches XBRL filings using the RSS feeds provided by the SEC.
324
+ *
315
325
  * @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
316
326
  */
317
327
  getCurrentFilingsXbrl(params?: {
@@ -334,6 +344,8 @@ export default class SecEdgarApi {
334
344
  * Search for companies from by name, sic code, or state.
335
345
  *
336
346
  * example at https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&owner=exclude&&start=0&count=100&hidefilings=0&company=Apple&match=contains
347
+ *
348
+ * TODO: Switch this to use output=atom in the url
337
349
  */
338
350
  searchCompanies(params: SearchCompaniesParams): Promise<{
339
351
  items: import("../../types").CompanySearchResult[];
@@ -588,6 +588,8 @@ var SecEdgarApi = /** @class */ (function () {
588
588
  /**
589
589
  * Gets list of filings for a day up to 5 days ago.
590
590
  *
591
+ * NOTE: This has not been updated since 2014 and has had issues with not returning data.
592
+ *
591
593
  * @see https://www.sec.gov/edgar/searchedgar/currentevents
592
594
  */
593
595
  SecEdgarApi.prototype.getCurrentFilingsDaily = function (params) {
@@ -620,6 +622,12 @@ var SecEdgarApi = /** @class */ (function () {
620
622
  });
621
623
  });
622
624
  };
625
+ /**
626
+ * Lists all types of current filings including non XBRL. If fetching earnings reports,
627
+ * use getCurrentFilingsXbrl instead.
628
+ *
629
+ * @see https://www.sec.gov/cgi-bin/browse-edgar?action=getcurrent
630
+ */
623
631
  SecEdgarApi.prototype.getCurrentFilings = function (params) {
624
632
  var _a;
625
633
  return __awaiter(this, void 0, void 0, function () {
@@ -648,6 +656,8 @@ var SecEdgarApi = /** @class */ (function () {
648
656
  });
649
657
  };
650
658
  /**
659
+ * Fetches XBRL filings using the RSS feeds provided by the SEC.
660
+ *
651
661
  * @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
652
662
  */
653
663
  SecEdgarApi.prototype.getCurrentFilingsXbrl = function (params) {
@@ -703,6 +713,8 @@ var SecEdgarApi = /** @class */ (function () {
703
713
  * Search for companies from by name, sic code, or state.
704
714
  *
705
715
  * example at https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&owner=exclude&&start=0&count=100&hidefilings=0&company=Apple&match=contains
716
+ *
717
+ * TODO: Switch this to use output=atom in the url
706
718
  */
707
719
  SecEdgarApi.prototype.searchCompanies = function (params) {
708
720
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sec-edgar-api",
3
- "version": "0.5.10",
3
+ "version": "0.5.11",
4
4
  "description": "Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.",
5
5
  "main": "build/index.js",
6
6
  "author": "Andrew Evers (https://github.com/andyevers)",