sec-edgar-api 0.2.2 → 0.2.4
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.
- package/README.md +5 -3
- package/build/services/DocumentParser/XMLParser.d.ts +5 -20
- package/build/services/DocumentParser/XMLParser.js +118 -122
- package/build/services/DocumentParser/parsers/index.d.ts +3 -5
- package/build/services/DocumentParser/parsers/index.js +3 -5
- package/build/services/DocumentParser/parsers/parse-form-13g.js +2 -2
- package/build/services/DocumentParser/parsers/parse-form-4.d.ts +1 -6
- package/build/services/DocumentParser/parsers/parse-form-4.js +204 -134
- package/build/services/DocumentParser/parsers/parse-form-def14a.d.ts +2 -1
- package/build/services/DocumentParser/parsers/parse-form-def14a.js +106 -157
- package/build/services/ReportBuilder/FactFiscalCalculator.d.ts +4 -0
- package/build/services/ReportBuilder/FactFiscalCalculator.js +4 -0
- package/build/services/ReportBuilder/FactPeriodResolver.d.ts +6 -2
- package/build/services/ReportBuilder/FactPeriodResolver.js +6 -1
- package/build/services/ReportBuilder/FactRecordBuilder.d.ts +4 -1
- package/build/services/ReportBuilder/FactRecordBuilder.js +26 -4
- package/build/services/ReportBuilder/FactSplitAdjuster.d.ts +12 -1
- package/build/services/ReportBuilder/FactSplitAdjuster.js +41 -19
- package/build/services/ReportBuilder/ReportBuilder.d.ts +3 -0
- package/build/services/ReportBuilder/ReportBuilder.js +33 -13
- package/build/services/ReportParser/ReportParser.d.ts +3 -3
- package/build/services/ReportParser/ReportParser.js +7 -4
- package/build/services/ReportParser/ReportRawParser.d.ts +3 -9
- package/build/services/ReportParser/ReportRawParser.js +5 -33
- package/build/services/ReportParser/ReportWrapper.js +2 -0
- package/build/services/ReportParser/resolvers/resolve-fiscal-year-cumulative-properties.js +2 -1
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +45 -84
- package/build/services/SecEdgarApi/SecEdgarApi.js +108 -246
- package/build/types/index.d.ts +2 -2
- package/build/types/index.js +2 -2
- package/build/types/parsed-filings.type.d.ts +5 -144
- package/build/types/report-raw.type.d.ts +3 -1
- package/build/types/report-translated.type.d.ts +4 -1
- package/build/types/submission.type.d.ts +2 -3
- package/build/util/key-translations.js +5 -1
- package/package.json +2 -5
- package/build/services/DocumentParser/HtmlTableExtractor.d.ts +0 -41
- package/build/services/DocumentParser/HtmlTableExtractor.js +0 -408
- package/build/services/DocumentParser/parsers/parse-current-filings.d.ts +0 -3
- package/build/services/DocumentParser/parsers/parse-current-filings.js +0 -98
- package/build/services/DocumentParser/parsers/parse-form-13f.d.ts +0 -6
- package/build/services/DocumentParser/parsers/parse-form-13f.js +0 -91
- package/build/services/ReportParser/FactItem.d.ts +0 -66
- package/build/services/ReportParser/FactItem.js +0 -50
- package/build/services/ReportParser/FactItemFactory.d.ts +0 -22
- package/build/services/ReportParser/FactItemFactory.js +0 -150
- package/build/services/ReportParser/FactIterator.d.ts +0 -18
- package/build/services/ReportParser/FactIterator.js +0 -35
- package/build/services/ReportParser/FactSplitMap.d.ts +0 -16
- package/build/services/ReportParser/FactSplitMap.js +0 -101
- package/build/types/current-filings-xml.type.d.ts +0 -74
- package/build/types/current-filings-xml.type.js +0 -6
- package/build/types/current-filings.type.d.ts +0 -44
- package/build/types/current-filings.type.js +0 -2
- package/build/types/form-13f-xml.type.d.ts +0 -105
- package/build/types/form-13f-xml.type.js +0 -2
- package/build/types/form-4-xml.type.d.ts +0 -132
- package/build/types/form-4-xml.type.js +0 -2
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -49,8 +38,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
49
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
39
|
var cik_by_symbol_1 = require("../../util/cik-by-symbol");
|
|
51
40
|
var Client_1 = require("../Client");
|
|
52
|
-
var
|
|
41
|
+
var DocumentParser_1 = require("../DocumentParser");
|
|
53
42
|
var ReportParser_1 = require("../ReportParser");
|
|
43
|
+
var RequestWrapper_1 = require("./RequestWrapper");
|
|
54
44
|
var Throttler_1 = require("./Throttler");
|
|
55
45
|
/**
|
|
56
46
|
* Gets reports from companies filed with the SEC
|
|
@@ -64,14 +54,14 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
64
54
|
throttler: new Throttler_1.default(),
|
|
65
55
|
cikBySymbol: cik_by_symbol_1.default,
|
|
66
56
|
reportParser: new ReportParser_1.default(),
|
|
67
|
-
|
|
57
|
+
documentParser: new DocumentParser_1.default(),
|
|
68
58
|
}; }
|
|
69
|
-
var client = args.client, throttler = args.throttler, cikBySymbol = args.cikBySymbol, reportParser = args.reportParser,
|
|
59
|
+
var client = args.client, throttler = args.throttler, cikBySymbol = args.cikBySymbol, reportParser = args.reportParser, documentParser = args.documentParser;
|
|
70
60
|
this.client = client;
|
|
71
61
|
this.throttler = throttler;
|
|
72
62
|
this.cikBySymbol = cikBySymbol;
|
|
73
63
|
this.reportParser = reportParser;
|
|
74
|
-
this.
|
|
64
|
+
this.documentParser = documentParser;
|
|
75
65
|
this.baseUrlEdgar = 'https://data.sec.gov';
|
|
76
66
|
this.baseUrlSec = 'https://www.sec.gov';
|
|
77
67
|
}
|
|
@@ -130,77 +120,19 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
130
120
|
}
|
|
131
121
|
for (var _i = 0, filings_1 = filings; _i < filings_1.length; _i++) {
|
|
132
122
|
var filing = filings_1[_i];
|
|
133
|
-
var
|
|
123
|
+
var accessionStr = filing.accessionNumber.replace(/-/g, '');
|
|
134
124
|
var primaryDocument = filing.primaryDocument;
|
|
135
|
-
|
|
136
|
-
filing.url = "".concat(urlPrefix, "/").concat(primaryDocument);
|
|
137
|
-
filing.urlXml = "".concat(urlPrefix, "/").concat(filing.accessionNumber, ".txt");
|
|
125
|
+
filing.url = "https://www.sec.gov/Archives/edgar/data/".concat(Number(cik), "/").concat(accessionStr, "/").concat(primaryDocument);
|
|
138
126
|
}
|
|
139
127
|
return filings;
|
|
140
128
|
};
|
|
141
|
-
SecEdgarApi.prototype.
|
|
142
|
-
var
|
|
143
|
-
var
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
FY: fiscalYearEndMonth,
|
|
149
|
-
};
|
|
150
|
-
var monthNum = monthByFiscalPeriod[fiscalPeriod] === 0 ? 12 : monthByFiscalPeriod[fiscalPeriod];
|
|
151
|
-
var monthStr = monthNum.toString().padStart(2, '0');
|
|
152
|
-
var isNextYear = monthByFiscalPeriod[fiscalPeriod] > fiscalYearEndMonth + 2;
|
|
153
|
-
var fiscalYear = isNextYear ? year + 1 : year;
|
|
154
|
-
var dateSearch = new Date("".concat(fiscalYear, "-").concat(monthStr, "-28"));
|
|
155
|
-
var submissionsFiltered = submissions.filter(function (sub) {
|
|
156
|
-
var subDate = new Date(sub.reportDate);
|
|
157
|
-
var isWithin60DaysAfter = subDate.getTime() - dateSearch.getTime() < 1000 * 60 * 60 * 24 * 60;
|
|
158
|
-
var isWIthin30DaysBefore = dateSearch.getTime() - subDate.getTime() < 86400000 * 30;
|
|
159
|
-
return isWithin60DaysAfter && isWIthin30DaysBefore;
|
|
160
|
-
});
|
|
161
|
-
submissionsFiltered.sort(function (a, b) { return new Date(a.filingDate).getTime() - new Date(b.filingDate).getTime(); });
|
|
162
|
-
return submissionsFiltered;
|
|
163
|
-
};
|
|
164
|
-
SecEdgarApi.prototype.extractSubmissionsWithXml = function (data) {
|
|
165
|
-
var _a, _b;
|
|
166
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var symbol, subs, documentXml, getSubmissionUrl, xml, url, submissions, submissionList, _c, recent, recentTranslated, providedSubmissions, _d, _e;
|
|
168
|
-
return __generator(this, function (_f) {
|
|
169
|
-
switch (_f.label) {
|
|
170
|
-
case 0:
|
|
171
|
-
symbol = data.symbol, subs = data.submissions, documentXml = data.documentXml, getSubmissionUrl = data.getSubmissionUrl;
|
|
172
|
-
xml = documentXml !== null && documentXml !== void 0 ? documentXml : null;
|
|
173
|
-
url = null;
|
|
174
|
-
submissions = [];
|
|
175
|
-
submissionList = subs !== null && subs !== void 0 ? subs : null;
|
|
176
|
-
if (!!xml) return [3 /*break*/, 7];
|
|
177
|
-
_c = (_a = subs === null || subs === void 0 ? void 0 : subs.filings) !== null && _a !== void 0 ? _a : {}, recent = _c.recent, recentTranslated = _c.recentTranslated;
|
|
178
|
-
providedSubmissions = recentTranslated !== null && recentTranslated !== void 0 ? recentTranslated : (recent ? this.mapFilingListDetails(symbol, recent) : null);
|
|
179
|
-
if (!(subs !== null && subs !== void 0)) return [3 /*break*/, 1];
|
|
180
|
-
_d = subs;
|
|
181
|
-
return [3 /*break*/, 3];
|
|
182
|
-
case 1: return [4 /*yield*/, this.getSubmissions({ symbol: symbol })];
|
|
183
|
-
case 2:
|
|
184
|
-
_d = (_f.sent());
|
|
185
|
-
_f.label = 3;
|
|
186
|
-
case 3:
|
|
187
|
-
submissionList = _d;
|
|
188
|
-
submissions = (_b = providedSubmissions !== null && providedSubmissions !== void 0 ? providedSubmissions : submissionList.filings.recentTranslated) !== null && _b !== void 0 ? _b : [];
|
|
189
|
-
url = getSubmissionUrl(submissions, submissionList);
|
|
190
|
-
if (!url) return [3 /*break*/, 5];
|
|
191
|
-
return [4 /*yield*/, this.getDocumentXMLByUrl({ url: url })];
|
|
192
|
-
case 4:
|
|
193
|
-
_e = _f.sent();
|
|
194
|
-
return [3 /*break*/, 6];
|
|
195
|
-
case 5:
|
|
196
|
-
_e = null;
|
|
197
|
-
_f.label = 6;
|
|
198
|
-
case 6:
|
|
199
|
-
xml = _e;
|
|
200
|
-
_f.label = 7;
|
|
201
|
-
case 7: return [2 /*return*/, { xml: xml, url: url, submissions: submissions, submissionList: submissionList }];
|
|
202
|
-
}
|
|
203
|
-
});
|
|
129
|
+
SecEdgarApi.prototype.getCreateRequestSubmissions = function (params, forms) {
|
|
130
|
+
var symbol = params.symbol, filings = params.filings, _a = params.cutoffDate, cutoffDate = _a === void 0 ? new Date('1970-01-01') : _a;
|
|
131
|
+
var cik = this.getCikString(symbol);
|
|
132
|
+
var filingsArr = Array.isArray(filings) ? filings : this.mapFilingListDetails(cik, filings);
|
|
133
|
+
return filingsArr.filter(function (_a) {
|
|
134
|
+
var form = _a.form, filingDate = _a.filingDate;
|
|
135
|
+
return forms.includes(form) && new Date(filingDate).getTime() > cutoffDate.getTime();
|
|
204
136
|
});
|
|
205
137
|
};
|
|
206
138
|
/**
|
|
@@ -226,16 +158,18 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
226
158
|
*/
|
|
227
159
|
SecEdgarApi.prototype.getSubmissions = function (params) {
|
|
228
160
|
return __awaiter(this, void 0, void 0, function () {
|
|
229
|
-
var symbol, cik, submissions;
|
|
161
|
+
var symbol, includeTranslated, cik, submissions;
|
|
230
162
|
return __generator(this, function (_a) {
|
|
231
163
|
switch (_a.label) {
|
|
232
164
|
case 0:
|
|
233
|
-
symbol = params.symbol;
|
|
165
|
+
symbol = params.symbol, includeTranslated = params.includeTranslated;
|
|
234
166
|
cik = this.getCikString(symbol);
|
|
235
167
|
return [4 /*yield*/, this.request("".concat(this.baseUrlEdgar, "/submissions/CIK").concat(cik, ".json"))];
|
|
236
168
|
case 1:
|
|
237
169
|
submissions = _a.sent();
|
|
238
170
|
submissions.cik = Number(submissions.cik);
|
|
171
|
+
if (!includeTranslated)
|
|
172
|
+
return [2 /*return*/, submissions];
|
|
239
173
|
submissions.filings.recentTranslated = this.mapFilingListDetails(cik, submissions.filings.recent);
|
|
240
174
|
return [2 /*return*/, submissions];
|
|
241
175
|
}
|
|
@@ -391,8 +325,7 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
391
325
|
});
|
|
392
326
|
};
|
|
393
327
|
/**
|
|
394
|
-
* Gets a raw xml document string. the parameters are found in the submission list response.
|
|
395
|
-
* (response.filings.recent or response.filings.recentTranslated)
|
|
328
|
+
* Gets a raw xml document string. the parameters are found in the submission list response. (response.filings.recent or response.filings.recentTranslated)
|
|
396
329
|
*
|
|
397
330
|
* Some form types can be parsed using the DocumentParser such as form 4 (insider transactions) and form 13g (institutional holders)
|
|
398
331
|
*
|
|
@@ -402,12 +335,11 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
402
335
|
*/
|
|
403
336
|
SecEdgarApi.prototype.getDocumentXML = function (params) {
|
|
404
337
|
return __awaiter(this, void 0, void 0, function () {
|
|
405
|
-
var accessionNumber, primaryDocument, symbol, cik
|
|
338
|
+
var accessionNumber, primaryDocument, symbol, cik;
|
|
406
339
|
return __generator(this, function (_a) {
|
|
407
340
|
accessionNumber = params.accessionNumber, primaryDocument = params.primaryDocument, symbol = params.symbol;
|
|
408
341
|
cik = this.cikBySymbol[symbol];
|
|
409
|
-
|
|
410
|
-
return [2 /*return*/, this.request("".concat(this.baseUrlSec, "/Archives/edgar/data/").concat(cik, "/").concat(accessionNumber.replace(/-/g, ''), "/").concat(document), true)];
|
|
342
|
+
return [2 /*return*/, this.request("".concat(this.baseUrlSec, "/Archives/edgar/data/").concat(cik, "/").concat(accessionNumber.replace(/-/g, ''), "/").concat(primaryDocument), true)];
|
|
411
343
|
});
|
|
412
344
|
});
|
|
413
345
|
};
|
|
@@ -428,193 +360,123 @@ var SecEdgarApi = /** @class */ (function () {
|
|
|
428
360
|
});
|
|
429
361
|
};
|
|
430
362
|
/**
|
|
431
|
-
* Used for getting
|
|
432
|
-
*
|
|
433
|
-
* Forms: 13F, 13F/A, 13F-HR, 13F-HR/A
|
|
363
|
+
* Used for getting insider transactions. extracts insider transaction urls from submission list response, and parses the xml doc.
|
|
434
364
|
*
|
|
435
|
-
*
|
|
365
|
+
* ```ts
|
|
366
|
+
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
367
|
+
* const requestWrapper = secEdgarApi.createRequestInsiderTransactions({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
436
368
|
*
|
|
437
|
-
*
|
|
438
|
-
*
|
|
439
|
-
*
|
|
369
|
+
* const transactions1 = (await requestWrapper.requestNext()).result.transactions // array of transactions from most recent doc
|
|
370
|
+
* const transactions2 = (await requestWrapper.requestNext()).result.transactions // array of transactions from second most recent doc
|
|
371
|
+
* ```
|
|
440
372
|
*/
|
|
441
|
-
SecEdgarApi.prototype.
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
373
|
+
SecEdgarApi.prototype.createRequestInsiderTransactions = function (params) {
|
|
374
|
+
var _this = this;
|
|
375
|
+
var submissions = this.getCreateRequestSubmissions(params, ['4', '4/A', '5', '5/A']);
|
|
376
|
+
var options = { maxRequests: params.maxRequests };
|
|
377
|
+
var sendRequest = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
378
|
+
var _a, _b;
|
|
379
|
+
var _c;
|
|
380
|
+
return __generator(this, function (_d) {
|
|
381
|
+
switch (_d.label) {
|
|
447
382
|
case 0:
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
return [4 /*yield*/, this.extractSubmissionsWithXml(__assign(__assign({}, params), { getSubmissionUrl: function (subs, submissionList) {
|
|
453
|
-
var _a;
|
|
454
|
-
var submissions = subs.filter(function (sub) { return sub === null || sub === void 0 ? void 0 : sub.form.startsWith('13F'); });
|
|
455
|
-
var submission = submissions[Number(lookback)];
|
|
456
|
-
if (fiscalPeriod && fiscalYear) {
|
|
457
|
-
var submissionsInPeriod = _this.filterSubmissionsInFiscalPeriodAsc({
|
|
458
|
-
fiscalYearEndMonth: Number(submissionList.fiscalYearEnd.substring(0, 2)),
|
|
459
|
-
fiscalPeriod: fiscalPeriod,
|
|
460
|
-
fiscalYear: fiscalYear,
|
|
461
|
-
submissions: submissions,
|
|
462
|
-
});
|
|
463
|
-
submission = submissionsInPeriod[0];
|
|
464
|
-
}
|
|
465
|
-
return (_a = submission === null || submission === void 0 ? void 0 : submission.urlXml) !== null && _a !== void 0 ? _a : null;
|
|
466
|
-
} }))];
|
|
467
|
-
case 1:
|
|
468
|
-
_a = _b.sent(), submissions = _a.submissions, url = _a.url, xml = _a.xml;
|
|
469
|
-
holdingsForm = xml ? this.parsers.parseForm13f({ xml: xml }) : null;
|
|
470
|
-
return [2 /*return*/, { url: url, holdingsForm: holdingsForm, submissions: submissions }];
|
|
383
|
+
_b = (_a = this.documentParser).parseForm4;
|
|
384
|
+
_c = {};
|
|
385
|
+
return [4 /*yield*/, this.getDocumentXMLByUrl(params)];
|
|
386
|
+
case 1: return [2 /*return*/, _b.apply(_a, [(_c.xml = _d.sent(), _c)])];
|
|
471
387
|
}
|
|
472
388
|
});
|
|
473
|
-
});
|
|
389
|
+
}); };
|
|
390
|
+
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
474
391
|
};
|
|
475
392
|
/**
|
|
476
|
-
*
|
|
477
|
-
* If multiple submissions are found within the fiscal period, uses the first submission.
|
|
478
|
-
*
|
|
479
|
-
* Forms: SC 13G, SC 13G/A
|
|
393
|
+
* Used for getting institutional holders. extracts holders urls from submission list response, and parses the xml doc.
|
|
480
394
|
*
|
|
481
|
-
*
|
|
395
|
+
* ```ts
|
|
396
|
+
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
397
|
+
* const requestWrapper = secEdgarApi.createRequestInstitutionalHolders({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
482
398
|
*
|
|
483
|
-
*
|
|
399
|
+
* const holders1 = (await requestWrapper.requestNext()).result.holders // array of holders from most recent doc
|
|
400
|
+
* const holders2 = (await requestWrapper.requestNext()).result.holders // array of holders from second most recent doc
|
|
401
|
+
* ```
|
|
484
402
|
*/
|
|
485
|
-
SecEdgarApi.prototype.
|
|
486
|
-
var
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
403
|
+
SecEdgarApi.prototype.createRequestInstitutionalHolders = function (params) {
|
|
404
|
+
var _this = this;
|
|
405
|
+
var submissions = this.getCreateRequestSubmissions(params, ['SC 13G', 'SC 13G/A']);
|
|
406
|
+
var options = { maxRequests: params.maxRequests };
|
|
407
|
+
var sendRequest = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
408
|
+
var _a, _b;
|
|
409
|
+
var _c;
|
|
410
|
+
return __generator(this, function (_d) {
|
|
411
|
+
switch (_d.label) {
|
|
492
412
|
case 0:
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
return [4 /*yield*/, this.extractSubmissionsWithXml(__assign(__assign({}, params), { getSubmissionUrl: function (subs, submissionList) {
|
|
498
|
-
var _a;
|
|
499
|
-
var submissions = subs.filter(function (sub) { var _a; return ['SC 13G', 'SC 13G/A'].includes(sub.form) && !((_a = sub.url) === null || _a === void 0 ? void 0 : _a.endsWith('.txt')); });
|
|
500
|
-
var submission = submissions[Number(lookback)];
|
|
501
|
-
if (fiscalPeriod && fiscalYear) {
|
|
502
|
-
var submissionsInPeriod = _this.filterSubmissionsInFiscalPeriodAsc({
|
|
503
|
-
fiscalYearEndMonth: Number(submissionList.fiscalYearEnd.substring(0, 2)),
|
|
504
|
-
fiscalPeriod: fiscalPeriod,
|
|
505
|
-
fiscalYear: fiscalYear,
|
|
506
|
-
submissions: submissions,
|
|
507
|
-
});
|
|
508
|
-
submission = submissionsInPeriod[0];
|
|
509
|
-
}
|
|
510
|
-
return (_a = submission === null || submission === void 0 ? void 0 : submission.url) !== null && _a !== void 0 ? _a : null;
|
|
511
|
-
} }))];
|
|
512
|
-
case 1:
|
|
513
|
-
_b = _c.sent(), submissions = _b.submissions, url = _b.url, xml = _b.xml;
|
|
514
|
-
response = xml ? this.parsers.parseForm13g({ xml: xml }) : null;
|
|
515
|
-
return [2 /*return*/, { url: url, institutionalHolders: (_a = response === null || response === void 0 ? void 0 : response.institutionalHolders) !== null && _a !== void 0 ? _a : [], submissions: submissions }];
|
|
413
|
+
_b = (_a = this.documentParser).parseForm13g;
|
|
414
|
+
_c = {};
|
|
415
|
+
return [4 /*yield*/, this.getDocumentXMLByUrl(params)];
|
|
416
|
+
case 1: return [2 /*return*/, _b.apply(_a, [(_c.xml = _d.sent(), _c)])];
|
|
516
417
|
}
|
|
517
418
|
});
|
|
518
|
-
});
|
|
419
|
+
}); };
|
|
420
|
+
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
519
421
|
};
|
|
520
422
|
/**
|
|
521
|
-
*
|
|
522
|
-
*
|
|
523
|
-
* Forms: DEF 14A
|
|
423
|
+
* Used for getting earnings report tables from submission files.
|
|
524
424
|
*
|
|
525
|
-
*
|
|
425
|
+
* ```ts
|
|
426
|
+
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
427
|
+
* const requestWrapper = secEdgarApi.createRequesEarningsReports({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
526
428
|
*
|
|
527
|
-
*
|
|
429
|
+
* const tables1 = (await requestWrapper.requestNext()).result.tables // array of tables from most recent doc
|
|
430
|
+
* const tables2 = (await requestWrapper.requestNext()).result.tables // array of tables from second most recent doc
|
|
431
|
+
* ```
|
|
528
432
|
*/
|
|
529
|
-
SecEdgarApi.prototype.
|
|
530
|
-
var
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
433
|
+
SecEdgarApi.prototype.createRequestEarningsReports = function (params) {
|
|
434
|
+
var _this = this;
|
|
435
|
+
var submissions = this.getCreateRequestSubmissions(params, ['10-Q', '10-Q/A', '10-K', '10-K/A']);
|
|
436
|
+
var options = { maxRequests: params.maxRequests };
|
|
437
|
+
var sendRequest = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
438
|
+
var _a, _b;
|
|
439
|
+
var _c;
|
|
440
|
+
return __generator(this, function (_d) {
|
|
441
|
+
switch (_d.label) {
|
|
536
442
|
case 0:
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
return [4 /*yield*/, this.extractSubmissionsWithXml(__assign(__assign({}, params), { getSubmissionUrl: function (subs, submissionList) {
|
|
542
|
-
var _a;
|
|
543
|
-
var submissions = subs.filter(function (sub) { var _a; return sub.form === 'DEF 14A' && !((_a = sub.url) === null || _a === void 0 ? void 0 : _a.endsWith('.txt')); });
|
|
544
|
-
// console.log('subs', submissions)
|
|
545
|
-
var submission = submissions[Number(lookback) || 0];
|
|
546
|
-
if (fiscalYear) {
|
|
547
|
-
var submissionsInPeriod = _this.filterSubmissionsInFiscalPeriodAsc({
|
|
548
|
-
fiscalYearEndMonth: Number(submissionList.fiscalYearEnd.substring(0, 2)),
|
|
549
|
-
fiscalPeriod: 'Q4',
|
|
550
|
-
fiscalYear: fiscalYear,
|
|
551
|
-
submissions: submissions,
|
|
552
|
-
});
|
|
553
|
-
submission = submissionsInPeriod[0];
|
|
554
|
-
}
|
|
555
|
-
return (_a = submission === null || submission === void 0 ? void 0 : submission.url) !== null && _a !== void 0 ? _a : null;
|
|
556
|
-
} }))];
|
|
557
|
-
case 1:
|
|
558
|
-
_b = _c.sent(), submissions = _b.submissions, url = _b.url, xml = _b.xml;
|
|
559
|
-
response = xml ? this.parsers.parseFormDef14a({ xml: xml }) : null;
|
|
560
|
-
return [2 /*return*/, { url: url, executiveCompensation: (_a = response === null || response === void 0 ? void 0 : response.executiveCompensation) !== null && _a !== void 0 ? _a : [], submissions: submissions }];
|
|
443
|
+
_b = (_a = this.documentParser).parseForm10k;
|
|
444
|
+
_c = {};
|
|
445
|
+
return [4 /*yield*/, this.getDocumentXMLByUrl(params)];
|
|
446
|
+
case 1: return [2 /*return*/, _b.apply(_a, [(_c.xml = _d.sent(), _c)])];
|
|
561
447
|
}
|
|
562
448
|
});
|
|
563
|
-
});
|
|
449
|
+
}); };
|
|
450
|
+
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
564
451
|
};
|
|
565
452
|
/**
|
|
566
|
-
*
|
|
453
|
+
* Proxy statement includes list of holders, executiveCompensation, and other tables. returns FormDef14aData
|
|
567
454
|
*
|
|
568
|
-
*
|
|
455
|
+
* ```ts
|
|
456
|
+
* const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
|
|
457
|
+
* const requestWrapper = secEdgarApi.createRequesProxyStatement({ symbol: 'AAPL', filings: submissions.filings.recent })
|
|
569
458
|
*
|
|
570
|
-
*
|
|
571
|
-
*
|
|
572
|
-
* WARNING: XML and HTML docs can be formatted differently and is prone to innacuracies.
|
|
459
|
+
* const { holders, executiveCompensation } = (await requestWrapper.requestNext()).result
|
|
460
|
+
* ```
|
|
573
461
|
*/
|
|
574
|
-
SecEdgarApi.prototype.
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
462
|
+
SecEdgarApi.prototype.createRequestProxyStatement = function (params) {
|
|
463
|
+
var _this = this;
|
|
464
|
+
var submissions = this.getCreateRequestSubmissions(params, ['DEF 14A']);
|
|
465
|
+
var options = { maxRequests: params.maxRequests };
|
|
466
|
+
var sendRequest = function (params) { return __awaiter(_this, void 0, void 0, function () {
|
|
467
|
+
var _a, _b;
|
|
468
|
+
var _c;
|
|
469
|
+
return __generator(this, function (_d) {
|
|
470
|
+
switch (_d.label) {
|
|
579
471
|
case 0:
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
return (_b = (_a = submissions[lookback]) === null || _a === void 0 ? void 0 : _a.urlXml) !== null && _b !== void 0 ? _b : null;
|
|
585
|
-
} }))];
|
|
586
|
-
case 1:
|
|
587
|
-
_a = _b.sent(), submissions = _a.submissions, url = _a.url, xml = _a.xml;
|
|
588
|
-
insiderTransaction = xml ? this.parsers.parseForm4({ xml: xml }) : null;
|
|
589
|
-
return [2 /*return*/, { url: url, insiderTransaction: insiderTransaction, submissions: submissions }];
|
|
590
|
-
}
|
|
591
|
-
});
|
|
592
|
-
});
|
|
593
|
-
};
|
|
594
|
-
/**
|
|
595
|
-
* @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
|
|
596
|
-
*/
|
|
597
|
-
SecEdgarApi.prototype.getCurrentFilings = function (params) {
|
|
598
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
599
|
-
var _a, taxonomy, urlByTaxonomy, url, xml;
|
|
600
|
-
return __generator(this, function (_b) {
|
|
601
|
-
switch (_b.label) {
|
|
602
|
-
case 0:
|
|
603
|
-
_a = (params !== null && params !== void 0 ? params : {}).taxonomy, taxonomy = _a === void 0 ? 'allXbrl' : _a;
|
|
604
|
-
urlByTaxonomy = {
|
|
605
|
-
usGaap: 'https://www.sec.gov/Archives/edgar/usgaap.rss.xml',
|
|
606
|
-
mutualFund: 'https://www.sec.gov/Archives/edgar/xbrl-rr.rss.xml',
|
|
607
|
-
inlineXbrl: 'https://www.sec.gov/Archives/edgar/xbrl-inline.rss.xml',
|
|
608
|
-
allXbrl: 'https://www.sec.gov/Archives/edgar/xbrlrss.all.xml',
|
|
609
|
-
};
|
|
610
|
-
url = urlByTaxonomy[taxonomy] || urlByTaxonomy.allXbrl;
|
|
611
|
-
return [4 /*yield*/, this.request(url, true)];
|
|
612
|
-
case 1:
|
|
613
|
-
xml = _b.sent();
|
|
614
|
-
return [2 /*return*/, xml ? this.parsers.parseCurrentFilings({ xml: xml }) : null];
|
|
472
|
+
_b = (_a = this.documentParser).parseFormDef14a;
|
|
473
|
+
_c = {};
|
|
474
|
+
return [4 /*yield*/, this.getDocumentXMLByUrl(params)];
|
|
475
|
+
case 1: return [2 /*return*/, _b.apply(_a, [(_c.xml = _d.sent(), _c)])];
|
|
615
476
|
}
|
|
616
477
|
});
|
|
617
|
-
});
|
|
478
|
+
}); };
|
|
479
|
+
return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
|
|
618
480
|
};
|
|
619
481
|
return SecEdgarApi;
|
|
620
482
|
}());
|
package/build/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './common.type';
|
|
2
1
|
export * from './company-facts.type';
|
|
3
|
-
export * from './parsed-filings.type';
|
|
4
2
|
export * from './report-raw.type';
|
|
5
3
|
export * from './report-translated.type';
|
|
6
4
|
export * from './submission.type';
|
|
5
|
+
export * from './parsed-filings.type';
|
|
6
|
+
export * from './common.type';
|
package/build/types/index.js
CHANGED
|
@@ -14,9 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./common.type"), exports);
|
|
18
17
|
__exportStar(require("./company-facts.type"), exports);
|
|
19
|
-
__exportStar(require("./parsed-filings.type"), exports);
|
|
20
18
|
__exportStar(require("./report-raw.type"), exports);
|
|
21
19
|
__exportStar(require("./report-translated.type"), exports);
|
|
22
20
|
__exportStar(require("./submission.type"), exports);
|
|
21
|
+
__exportStar(require("./parsed-filings.type"), exports);
|
|
22
|
+
__exportStar(require("./common.type"), exports);
|