sec-edgar-api 0.3.0 → 0.3.2

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.
@@ -13,5 +13,17 @@ export default class DocumentParser {
13
13
  parseForm13g(params: XMLParams): import("../../types").Form13GData;
14
14
  parseForm10k(params: XMLParams): import("../../types").Form10KData;
15
15
  parseFormDef14a(params: XMLParams): import("../../types").FormDef14aData;
16
+ parseCurrentFilingsDaily(params: XMLParams): {
17
+ date: string;
18
+ matchCount: number;
19
+ totalCount: number;
20
+ entries: {
21
+ accessionNumber: string;
22
+ form: string;
23
+ companyCik: number;
24
+ companyName: string;
25
+ filedDate: string;
26
+ }[];
27
+ };
16
28
  }
17
29
  export {};
@@ -20,6 +20,9 @@ var DocumentParser = /** @class */ (function () {
20
20
  DocumentParser.prototype.parseFormDef14a = function (params) {
21
21
  return this.parsersByName.parseFormDef14a(params, this.parser);
22
22
  };
23
+ DocumentParser.prototype.parseCurrentFilingsDaily = function (params) {
24
+ return this.parsersByName.parseCurrentFilingsDaily(params);
25
+ };
23
26
  return DocumentParser;
24
27
  }());
25
28
  exports.default = DocumentParser;
@@ -2,10 +2,12 @@ import { parseForm4 } from './parse-form-4';
2
2
  import { parseForm13g } from './parse-form-13g';
3
3
  import { parseForm10k } from './parse-form-10k';
4
4
  import { parseFormDef14a } from './parse-form-def14a';
5
+ import { parseCurrentFilingsDaily } from './parse-current-filings-daily';
5
6
  declare const parsers: {
6
7
  parseForm4: typeof parseForm4;
7
8
  parseForm13g: typeof parseForm13g;
8
9
  parseForm10k: typeof parseForm10k;
9
10
  parseFormDef14a: typeof parseFormDef14a;
11
+ parseCurrentFilingsDaily: typeof parseCurrentFilingsDaily;
10
12
  };
11
13
  export default parsers;
@@ -4,10 +4,12 @@ var parse_form_4_1 = require("./parse-form-4");
4
4
  var parse_form_13g_1 = require("./parse-form-13g");
5
5
  var parse_form_10k_1 = require("./parse-form-10k");
6
6
  var parse_form_def14a_1 = require("./parse-form-def14a");
7
+ var parse_current_filings_daily_1 = require("./parse-current-filings-daily");
7
8
  var parsers = {
8
9
  parseForm4: parse_form_4_1.parseForm4,
9
10
  parseForm13g: parse_form_13g_1.parseForm13g,
10
11
  parseForm10k: parse_form_10k_1.parseForm10k,
11
12
  parseFormDef14a: parse_form_def14a_1.parseFormDef14a,
13
+ parseCurrentFilingsDaily: parse_current_filings_daily_1.parseCurrentFilingsDaily,
12
14
  };
13
15
  exports.default = parsers;
@@ -0,0 +1,13 @@
1
+ import { XMLParams } from '../../../types';
2
+ export declare function parseCurrentFilingsDaily(params: XMLParams): {
3
+ date: string;
4
+ matchCount: number;
5
+ totalCount: number;
6
+ entries: {
7
+ accessionNumber: string;
8
+ form: string;
9
+ companyCik: number;
10
+ companyName: string;
11
+ filedDate: string;
12
+ }[];
13
+ };
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseCurrentFilingsDaily = void 0;
4
+ function parseCurrentFilingsDaily(params) {
5
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6
+ var xml = params.xml;
7
+ var csv = (_a = xml.split('<hr>')[1]) !== null && _a !== void 0 ? _a : '';
8
+ var lines = csv.split('\n').slice(0, -1);
9
+ var _k = (_b = xml.match(/<strong>.{1,20}?<\/strong>/g)) !== null && _b !== void 0 ? _b : [], _l = _k[0], matchHtml = _l === void 0 ? '' : _l, _m = _k[1], totalHtml = _m === void 0 ? '' : _m;
10
+ var date = (_e = (_d = (_c = xml.split('of matches for')) === null || _c === void 0 ? void 0 : _c[1].split('is', 1)) === null || _d === void 0 ? void 0 : _d[0]) === null || _e === void 0 ? void 0 : _e.trim();
11
+ var matchCount = Number((_g = (_f = matchHtml.split('>')[1]) === null || _f === void 0 ? void 0 : _f.split('<')[0]) === null || _g === void 0 ? void 0 : _g.trim()) || 0;
12
+ var totalCount = Number((_j = (_h = totalHtml.split('>')[1]) === null || _h === void 0 ? void 0 : _h.split('<')[0]) === null || _j === void 0 ? void 0 : _j.trim()) || 0;
13
+ var entries = lines.map(function (line) {
14
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
15
+ var parts = line.split('<a ');
16
+ var partDate = (_a = parts[0]) !== null && _a !== void 0 ? _a : '';
17
+ var partNameCik = (_b = parts[parts.length - 1]) !== null && _b !== void 0 ? _b : '';
18
+ var partAccessionForm = (_f = (_e = (_d = ((_c = parts[1]) !== null && _c !== void 0 ? _c : '').split('/Archives/edgar/data/')[1]) === null || _d === void 0 ? void 0 : _d.split('/')) === null || _e === void 0 ? void 0 : _e[1]) !== null && _f !== void 0 ? _f : '';
19
+ var partNameCikParts = partNameCik.split('</a>');
20
+ var _q = partAccessionForm === null || partAccessionForm === void 0 ? void 0 : partAccessionForm.split('>'), accession = _q[0], formUnfiltered = _q[1];
21
+ var accessionNumber = ((_g = accession === null || accession === void 0 ? void 0 : accession.substring(0, accession.lastIndexOf('-'))) !== null && _g !== void 0 ? _g : '').trim();
22
+ var form = ((_h = formUnfiltered === null || formUnfiltered === void 0 ? void 0 : formUnfiltered.replace(/</g, '')) !== null && _h !== void 0 ? _h : '').trim();
23
+ var companyCik = Number((_l = (_k = (_j = partNameCikParts[0]) === null || _j === void 0 ? void 0 : _j.split('>')[1]) === null || _k === void 0 ? void 0 : _k.trim()) !== null && _l !== void 0 ? _l : '');
24
+ var companyName = (_o = (_m = partNameCikParts[1]) === null || _m === void 0 ? void 0 : _m.trim()) !== null && _o !== void 0 ? _o : '';
25
+ var filedDate = (_p = partDate.trim()) !== null && _p !== void 0 ? _p : '';
26
+ var _r = filedDate.split('-'), month = _r[0], day = _r[1], year = _r[2];
27
+ return {
28
+ accessionNumber: accessionNumber,
29
+ form: form,
30
+ companyCik: companyCik,
31
+ companyName: companyName,
32
+ filedDate: "".concat(year, "-").concat(month, "-").concat(day),
33
+ };
34
+ });
35
+ return { date: date, matchCount: matchCount, totalCount: totalCount, entries: entries };
36
+ }
37
+ exports.parseCurrentFilingsDaily = parseCurrentFilingsDaily;
@@ -20,7 +20,10 @@ export default class ReportParser {
20
20
  /**
21
21
  * Same as parseReports but accepts ReportRaw[] instead of CompanyFactListData
22
22
  */
23
- parseReportsFromRaw(reportsRaw: ReportRaw[], usePropertyResolver?: boolean): ReportWrapper[];
23
+ parseReportsFromRaw(params: {
24
+ reportsRaw: ReportRaw[];
25
+ usePropertyResolver?: boolean;
26
+ }): ReportWrapper[];
24
27
  /**
25
28
  * Parse raw reports
26
29
  *
@@ -17,8 +17,8 @@ var ReportParser = /** @class */ (function () {
17
17
  /**
18
18
  * Same as parseReports but accepts ReportRaw[] instead of CompanyFactListData
19
19
  */
20
- ReportParser.prototype.parseReportsFromRaw = function (reportsRaw, usePropertyResolver) {
21
- if (usePropertyResolver === void 0) { usePropertyResolver = true; }
20
+ ReportParser.prototype.parseReportsFromRaw = function (params) {
21
+ var reportsRaw = params.reportsRaw, _a = params.usePropertyResolver, usePropertyResolver = _a === void 0 ? true : _a;
22
22
  var reportByYearQuarter = new Map();
23
23
  var reportsRawFiltered = reportsRaw;
24
24
  this.translateReportsRaw(reportsRawFiltered, function (report, reportRaw) {
@@ -35,7 +35,8 @@ var FactPeriodResolver = /** @class */ (function () {
35
35
  */
36
36
  FactPeriodResolver.isAverageShares = function (params) {
37
37
  var propertyName = params.propertyName;
38
- return propertyName.includes('WeightedAverage') && propertyName.includes('SharesOutstanding');
38
+ return (propertyName.includes('Average') &&
39
+ (propertyName.includes('SharesOutstanding') || propertyName.includes('SharesIssued')));
39
40
  };
40
41
  FactPeriodResolver.prototype.isAverageShares = function (params) {
41
42
  return FactPeriodResolver.isAverageShares(params);
@@ -1,4 +1,4 @@
1
- import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
1
+ import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, DailyFilingFormType, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
2
2
  import { FilingListDetails, FilingListItemTranslated, SubmissionList } from '../../types/submission.type';
3
3
  import { IClient } from '../Client';
4
4
  import DocumentParser from '../DocumentParser';
@@ -57,11 +57,6 @@ export interface GetDocumentXMLParams {
57
57
  accessionNumber: string;
58
58
  primaryDocument: string;
59
59
  }
60
- export interface GetSubmissionsParams {
61
- /** symbol or cik */
62
- symbol: string;
63
- includeTranslated?: boolean;
64
- }
65
60
  /**
66
61
  * Gets reports from companies filed with the SEC
67
62
  *
@@ -93,7 +88,10 @@ export default class SecEdgarApi {
93
88
  *
94
89
  * endpoint: `/submissions/CIK${cik}.json`
95
90
  */
96
- getSubmissions(params: GetSubmissionsParams): Promise<SubmissionList>;
91
+ getSubmissions(params: GetSymbolParams): Promise<{
92
+ submissionList: SubmissionList;
93
+ filings: FilingListItemTranslated[];
94
+ }>;
97
95
  /**
98
96
  * The company-concept API returns all the XBRL disclosures from a single company (CIK)
99
97
  * and concept (a taxonomy and tag) into a single JSON file, with a separate array
@@ -143,8 +141,7 @@ export default class SecEdgarApi {
143
141
  */
144
142
  getReports<T extends GetReportsParams>(params: T): Promise<T['withWrapper'] extends true ? ReportWrapper[] : ReportTranslated[]>;
145
143
  /**
146
- * Parses reports from company facts. Calculates missing properties and uses a single interface
147
- * for all reports.
144
+ * Parses reports from company facts.
148
145
  */
149
146
  getReportsRaw(params: GetReportsRawParams): Promise<ReportRaw[]>;
150
147
  /**
@@ -166,7 +163,7 @@ export default class SecEdgarApi {
166
163
  */
167
164
  getMutualFundList(): Promise<FieldDataResponse<'cik' | 'seriesId' | 'classId' | 'symbol'>>;
168
165
  /**
169
- * Gets a raw xml document string. the parameters are found in the submission list response. (response.filings.recent or response.filings.recentTranslated)
166
+ * Gets a raw xml document string. the parameters are found in the submission list response.
170
167
  *
171
168
  * Some form types can be parsed using the DocumentParser such as form 4 (insider transactions) and form 13g (institutional holders)
172
169
  *
@@ -234,5 +231,25 @@ export default class SecEdgarApi {
234
231
  * ```
235
232
  */
236
233
  createRequestProxyStatement(params: CreateRequestWrapperParams): SubmissionRequestWrapper<FormDef14aData>;
234
+ /**
235
+ * Gets list of latest filings.
236
+ *
237
+ * @see https://www.sec.gov/edgar/searchedgar/currentevents
238
+ */
239
+ getCurrentFilingsDaily(params?: {
240
+ formType?: DailyFilingFormType;
241
+ lookbackDays?: number;
242
+ }): Promise<{
243
+ date: string;
244
+ matchCount: number;
245
+ totalCount: number;
246
+ entries: {
247
+ accessionNumber: string;
248
+ form: string;
249
+ companyCik: number;
250
+ companyName: string;
251
+ filedDate: string;
252
+ }[];
253
+ }>;
237
254
  }
238
255
  export {};
@@ -168,21 +168,19 @@ var SecEdgarApi = /** @class */ (function () {
168
168
  * endpoint: `/submissions/CIK${cik}.json`
169
169
  */
170
170
  SecEdgarApi.prototype.getSubmissions = function (params) {
171
+ var _a;
171
172
  return __awaiter(this, void 0, void 0, function () {
172
- var symbol, includeTranslated, cik, submissions;
173
- return __generator(this, function (_a) {
174
- switch (_a.label) {
173
+ var symbol, cik, submissionList;
174
+ return __generator(this, function (_b) {
175
+ switch (_b.label) {
175
176
  case 0:
176
- symbol = params.symbol, includeTranslated = params.includeTranslated;
177
+ symbol = params.symbol;
177
178
  cik = this.getCikString(symbol);
178
179
  return [4 /*yield*/, this.request("".concat(this.baseUrlEdgar, "/submissions/CIK").concat(cik, ".json"))];
179
180
  case 1:
180
- submissions = _a.sent();
181
- submissions.cik = Number(submissions.cik);
182
- if (!includeTranslated)
183
- return [2 /*return*/, submissions];
184
- submissions.filings.recentTranslated = this.mapFilingListDetails(cik, submissions.filings.recent);
185
- return [2 /*return*/, submissions];
181
+ submissionList = _b.sent();
182
+ submissionList.cik = Number(submissionList.cik);
183
+ return [2 /*return*/, { submissionList: submissionList, filings: this.mapFilingListDetails(cik, (_a = submissionList === null || submissionList === void 0 ? void 0 : submissionList.filings) === null || _a === void 0 ? void 0 : _a.recent) }];
186
184
  }
187
185
  });
188
186
  });
@@ -270,15 +268,14 @@ var SecEdgarApi = /** @class */ (function () {
270
268
  return [4 /*yield*/, this.getReportsRaw(__assign(__assign({}, params), { includeNamePrefix: false }))];
271
269
  case 1:
272
270
  reportsRaw = _c.sent();
273
- reports = this.reportParser.parseReportsFromRaw(reportsRaw, usePropertyResolver);
271
+ reports = this.reportParser.parseReportsFromRaw({ reportsRaw: reportsRaw, usePropertyResolver: usePropertyResolver });
274
272
  return [2 /*return*/, withWrapper ? reports : reports.map(function (report) { return report.getReport(); })];
275
273
  }
276
274
  });
277
275
  });
278
276
  };
279
277
  /**
280
- * Parses reports from company facts. Calculates missing properties and uses a single interface
281
- * for all reports.
278
+ * Parses reports from company facts.
282
279
  */
283
280
  SecEdgarApi.prototype.getReportsRaw = function (params) {
284
281
  return __awaiter(this, void 0, void 0, function () {
@@ -343,7 +340,7 @@ var SecEdgarApi = /** @class */ (function () {
343
340
  });
344
341
  };
345
342
  /**
346
- * Gets a raw xml document string. the parameters are found in the submission list response. (response.filings.recent or response.filings.recentTranslated)
343
+ * Gets a raw xml document string. the parameters are found in the submission list response.
347
344
  *
348
345
  * Some form types can be parsed using the DocumentParser such as form 4 (insider transactions) and form 13g (institutional holders)
349
346
  *
@@ -496,6 +493,41 @@ var SecEdgarApi = /** @class */ (function () {
496
493
  }); };
497
494
  return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
498
495
  };
496
+ /**
497
+ * Gets list of latest filings.
498
+ *
499
+ * @see https://www.sec.gov/edgar/searchedgar/currentevents
500
+ */
501
+ SecEdgarApi.prototype.getCurrentFilingsDaily = function (params) {
502
+ var _a;
503
+ return __awaiter(this, void 0, void 0, function () {
504
+ var _b, _c, formType, _d, lookbackDays, indexByFormType, indexFormType, url, xml;
505
+ return __generator(this, function (_e) {
506
+ switch (_e.label) {
507
+ case 0:
508
+ _b = params !== null && params !== void 0 ? params : {}, _c = _b.formType, formType = _c === void 0 ? 'ALL' : _c, _d = _b.lookbackDays, lookbackDays = _d === void 0 ? 0 : _d;
509
+ if (lookbackDays > 5) {
510
+ throw new Error("lookbackDays must be <= 5. Received ".concat(lookbackDays));
511
+ }
512
+ indexByFormType = {
513
+ '10-K': 0,
514
+ '10-Q': 1,
515
+ '14': 2,
516
+ '485': 3,
517
+ '8-K': 4,
518
+ 'S-8': 5,
519
+ ALL: 6,
520
+ };
521
+ indexFormType = (_a = indexByFormType[formType]) !== null && _a !== void 0 ? _a : 0;
522
+ url = "".concat(this.baseUrlSec, "/cgi-bin/current?q1=").concat(lookbackDays, "&q2=").concat(indexFormType);
523
+ return [4 /*yield*/, this.request(url, true)];
524
+ case 1:
525
+ xml = (_e.sent());
526
+ return [2 /*return*/, this.documentParser.parseCurrentFilingsDaily({ xml: xml })];
527
+ }
528
+ });
529
+ });
530
+ };
499
531
  return SecEdgarApi;
500
532
  }());
501
533
  exports.default = SecEdgarApi;
@@ -93,4 +93,5 @@ export interface FormDef14aData {
93
93
  executiveCompensation: ExecutiveCompensation[];
94
94
  holders: Holder[];
95
95
  }
96
+ export type DailyFilingFormType = '10-K' | '10-Q' | '8-K' | '14' | '485' | 'S-8' | 'ALL';
96
97
  export {};
@@ -57,7 +57,6 @@ export interface FilingListItemTranslated {
57
57
  interface FilingList {
58
58
  recent: FilingListDetails;
59
59
  files: FileData[];
60
- recentTranslated?: FilingListItemTranslated[];
61
60
  }
62
61
  export interface SubmissionList {
63
62
  cik: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sec-edgar-api",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
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)",