sec-edgar-api 0.5.10 → 0.5.12

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.
@@ -36,8 +36,8 @@ function isWithinDays(params) {
36
36
  return daysDiff < days;
37
37
  }
38
38
  function buildReportsFromFacts(params) {
39
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
40
- var filing = params.filing, facts = params.facts, fiscalPeriod = params.fiscalPeriod, fiscalYear = params.fiscalYear, pathSeparator = params.pathSeparator, cikProp = params.cik;
39
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
40
+ var filing = params.filing, facts = params.facts, fiscalPeriod = params.fiscalPeriod, fiscalYear = params.fiscalYear, pathSeparator = params.pathSeparator, cikProp = params.cik, fiscalYearEnd = params.fiscalYearEnd;
41
41
  var urlParts = (_a = filing === null || filing === void 0 ? void 0 : filing.url.split('/')) !== null && _a !== void 0 ? _a : [];
42
42
  var cik = cikProp !== null && cikProp !== void 0 ? cikProp : urlParts[(_b = urlParts.indexOf('data')) !== null && _b !== void 0 ? _b : -1];
43
43
  var reportFactValues = {
@@ -63,37 +63,36 @@ function buildReportsFromFacts(params) {
63
63
  var roundPlacesByName = new Map();
64
64
  var scaleByName = new Map();
65
65
  var isFocusFactByDateKey = new Map();
66
- var dateYearEnd = new Date(reportFocus.dateReport);
67
- var offsetByFiscalPeriod = { Q1: 9, Q2: 6, Q3: 3, Q4: 0, FY: 0 };
68
- dateYearEnd.setMonth(dateYearEnd.getMonth() + ((_h = offsetByFiscalPeriod[reportFocus.fiscalPeriod]) !== null && _h !== void 0 ? _h : 0));
66
+ var fiscalYearEndMonth = Number(fiscalYearEnd.substring(0, 2));
67
+ var fiscalYearEndDay = Number(fiscalYearEnd.substring(2));
69
68
  var fiscalCalculator = new FactFiscalCalculator_1.default({
70
69
  filings: filing ? [filing] : undefined,
71
70
  facts: facts,
72
- fiscalYearEnd: { day: dateYearEnd.getDate(), month: dateYearEnd.getMonth() + 1 },
71
+ fiscalYearEnd: { day: fiscalYearEndDay, month: fiscalYearEndMonth },
73
72
  });
74
73
  var fiscalsByDateKey = new Map();
75
74
  for (var _i = 0, facts_1 = facts; _i < facts_1.length; _i++) {
76
75
  var fact = facts_1[_i];
77
76
  var dateKey = fact.start ? "".concat(fact.start, "_").concat(fact.end) : fact.end;
78
77
  if (!fiscalsByDateKey.has(dateKey)) {
79
- var _x = fiscalCalculator.getFiscalYearQuarter({ dateStr: fact.end }), quarter = _x.quarter, year = _x.year;
78
+ var _w = fiscalCalculator.getFiscalYearQuarter({ dateStr: fact.end }), quarter = _w.quarter, year = _w.year;
80
79
  var period = FactPeriodResolver_1.default.getPeriod({ end: fact.end, start: fact.start });
81
80
  var fiscalPeriod_1 = (period === 12 && quarter === 4 ? 'FY' : "Q".concat(quarter));
82
81
  fiscalsByDateKey.set(dateKey, { fiscalYear: year, fiscalPeriod: fiscalPeriod_1 });
83
82
  }
84
83
  var isSplitFact = fact === splitFact;
85
- var isFocusFact = (_j = isFocusFactByDateKey.get(dateKey)) !== null && _j !== void 0 ? _j : (isWithinDays({ dateA: fact.end, dateB: reportFocus.dateReport, days: 45 }) || isSplitFact);
86
- (_k = reportByDateRange[dateKey]) !== null && _k !== void 0 ? _k : (reportByDateRange[dateKey] = {
84
+ var isFocusFact = (_h = isFocusFactByDateKey.get(dateKey)) !== null && _h !== void 0 ? _h : (isWithinDays({ dateA: fact.end, dateB: reportFocus.dateReport, days: 45 }) || isSplitFact);
85
+ (_j = reportByDateRange[dateKey]) !== null && _j !== void 0 ? _j : (reportByDateRange[dateKey] = {
87
86
  cik: reportFocus.cik,
88
87
  url: '',
89
- splitDate: (_l = splitFact === null || splitFact === void 0 ? void 0 : splitFact.end) !== null && _l !== void 0 ? _l : null,
88
+ splitDate: (_k = splitFact === null || splitFact === void 0 ? void 0 : splitFact.end) !== null && _k !== void 0 ? _k : null,
90
89
  splitRatio: (splitFact === null || splitFact === void 0 ? void 0 : splitFact.value) ? Number(splitFact.value) : null,
91
90
  dateFiled: reportFocus.dateFiled,
92
91
  dateReport: fact.end,
93
- fiscalPeriod: (_m = fiscalsByDateKey.get(dateKey)) === null || _m === void 0 ? void 0 : _m.fiscalPeriod,
94
- startDate: (_o = fact.start) !== null && _o !== void 0 ? _o : '',
92
+ fiscalPeriod: (_l = fiscalsByDateKey.get(dateKey)) === null || _l === void 0 ? void 0 : _l.fiscalPeriod,
93
+ startDate: (_m = fact.start) !== null && _m !== void 0 ? _m : '',
95
94
  endDate: fact.end,
96
- fiscalYear: (_p = fiscalsByDateKey.get(dateKey)) === null || _p === void 0 ? void 0 : _p.fiscalYear,
95
+ fiscalYear: (_o = fiscalsByDateKey.get(dateKey)) === null || _o === void 0 ? void 0 : _o.fiscalYear,
97
96
  period: FactPeriodResolver_1.default.getPeriod({ start: fact.start, end: fact.end }),
98
97
  isCurrentPeriod: isFocusFact,
99
98
  });
@@ -104,11 +103,11 @@ function buildReportsFromFacts(params) {
104
103
  isFocusFactByDateKey.set(dateKey, isFocusFact);
105
104
  }
106
105
  var el = fact;
107
- var scale = Number((_q = el.scale) !== null && _q !== void 0 ? _q : 0) || 0;
108
- var decimals = Number((_r = el.decimals) !== null && _r !== void 0 ? _r : 0) || 0;
106
+ var scale = Number((_p = el.scale) !== null && _p !== void 0 ? _p : 0) || 0;
107
+ var decimals = Number((_q = el.decimals) !== null && _q !== void 0 ? _q : 0) || 0;
109
108
  var suffix = fact.name.includes(pathSeparator)
110
109
  ? null
111
- : (_s = fact === null || fact === void 0 ? void 0 : fact.segments) === null || _s === void 0 ? void 0 : _s.map(function (_a) {
110
+ : (_r = fact === null || fact === void 0 ? void 0 : fact.segments) === null || _r === void 0 ? void 0 : _r.map(function (_a) {
112
111
  var dimension = _a.dimension, value = _a.value;
113
112
  return "".concat(dimension).concat(pathSeparator).concat(value);
114
113
  }).join(pathSeparator);
@@ -122,8 +121,8 @@ function buildReportsFromFacts(params) {
122
121
  var prevRounding = roundPlacesByName.get(prevFactKey);
123
122
  var prevScale = scaleByName.get(prevFactKey);
124
123
  var prevFact_1 = factByName.get(prevFactKey);
125
- var prevUnit = (_u = (_t = prevFact_1 === null || prevFact_1 === void 0 ? void 0 : prevFact_1.unit) === null || _t === void 0 ? void 0 : _t.split('_').pop()) === null || _u === void 0 ? void 0 : _u.toLowerCase();
126
- var unit = (_w = (_v = fact.unit) === null || _v === void 0 ? void 0 : _v.split('_').pop()) === null || _w === void 0 ? void 0 : _w.toLowerCase();
124
+ var prevUnit = (_t = (_s = prevFact_1 === null || prevFact_1 === void 0 ? void 0 : prevFact_1.unit) === null || _s === void 0 ? void 0 : _s.split('_').pop()) === null || _t === void 0 ? void 0 : _t.toLowerCase();
125
+ var unit = (_v = (_u = fact.unit) === null || _u === void 0 ? void 0 : _u.split('_').pop()) === null || _v === void 0 ? void 0 : _v.toLowerCase();
127
126
  var shouldSkip = [
128
127
  (prevUnit === null || prevUnit === void 0 ? void 0 : prevUnit.length) === 3 && (unit === null || unit === void 0 ? void 0 : unit.length) === 3 && prevUnit !== unit && prevUnit === 'usd',
129
128
  (prevRounding !== null && prevRounding !== void 0 ? prevRounding : 0) < roundPlaces,
@@ -212,6 +211,7 @@ function parseXbrl(params) {
212
211
  fiscalPeriod: (_k = factsForBuilder.find(function (f) { return f.name === 'dei:DocumentFiscalPeriodFocus'; })) === null || _k === void 0 ? void 0 : _k.value,
213
212
  fiscalYear: Number((_m = (_l = factsForBuilder.find(function (f) { return f.name === 'dei:DocumentFiscalYearFocus'; })) === null || _l === void 0 ? void 0 : _l.value) !== null && _m !== void 0 ? _m : 0),
214
213
  cik: response.header.cik,
214
+ fiscalYearEnd: response.header.fiscalYearEnd,
215
215
  filing: {
216
216
  acceptanceDateTime: response.header.acceptanceDatetime,
217
217
  accessionNumber: accessionNumber,
@@ -231,6 +231,8 @@ function parseXbrl(params) {
231
231
  urlPrimaryDocument: '',
232
232
  },
233
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) });
234
+ // Some concepts have members, but do not have a sum. add the sum to the report.
235
+ var periodReports = Object.values(reportByDateRange);
236
+ return __assign(__assign({}, response), { fiscalYear: fiscalYear, fiscalPeriod: fiscalPeriod, facts: factsFiltered, report: factsFiltered.length > 0 ? reportFocus : null, xml: xml, periodReports: periodReports });
235
237
  }
236
238
  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.12",
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)",