sec-edgar-api 0.0.5 → 0.0.7
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 +9 -45
- package/build/index.d.ts +2 -7
- package/build/index.js +16 -8
- package/build/services/DocumentParser/DocumentParser.d.ts +16 -0
- package/build/services/DocumentParser/DocumentParser.js +22 -0
- package/build/services/DocumentParser/XMLNode/ColNode.d.ts +18 -0
- package/build/services/DocumentParser/XMLNode/ColNode.js +74 -0
- package/build/services/DocumentParser/XMLNode/DocumentNode.d.ts +3 -0
- package/build/services/DocumentParser/XMLNode/DocumentNode.js +27 -0
- package/build/services/DocumentParser/XMLNode/HRNode.d.ts +3 -0
- package/build/services/DocumentParser/XMLNode/HRNode.js +27 -0
- package/build/services/DocumentParser/XMLNode/NonTableNode.d.ts +3 -0
- package/build/services/DocumentParser/XMLNode/NonTableNode.js +27 -0
- package/build/services/DocumentParser/XMLNode/RowNode.d.ts +30 -0
- package/build/services/DocumentParser/XMLNode/RowNode.js +177 -0
- package/build/services/DocumentParser/XMLNode/TableNode.d.ts +20 -0
- package/build/services/DocumentParser/XMLNode/TableNode.js +132 -0
- package/build/services/DocumentParser/XMLNode/XMLNode.d.ts +37 -0
- package/build/services/DocumentParser/XMLNode/XMLNode.js +154 -0
- package/build/services/DocumentParser/XMLParser.d.ts +40 -0
- package/build/services/DocumentParser/XMLParser.js +306 -0
- package/build/services/DocumentParser/index.d.ts +2 -0
- package/build/services/DocumentParser/index.js +4 -0
- package/build/services/DocumentParser/parsers/index.d.ts +9 -0
- package/build/services/DocumentParser/parsers/index.js +11 -0
- package/build/services/DocumentParser/parsers/parse-form-10k.d.ts +3 -0
- package/build/services/DocumentParser/parsers/parse-form-10k.js +78 -0
- package/build/services/DocumentParser/parsers/parse-form-13g.d.ts +8 -0
- package/build/services/DocumentParser/parsers/parse-form-13g.js +88 -0
- package/build/services/DocumentParser/parsers/parse-form-4.d.ts +8 -0
- package/build/services/DocumentParser/parsers/parse-form-4.js +220 -0
- package/build/services/ReportParser/ReportParser.d.ts +2 -2
- package/build/services/ReportParser/ReportParser.js +8 -4
- package/build/services/SecEdgarApi/RequestWrapper.d.ts +37 -0
- package/build/services/SecEdgarApi/RequestWrapper.js +147 -0
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +156 -22
- package/build/services/SecEdgarApi/SecEdgarApi.js +314 -32
- package/build/types/common.type.d.ts +12 -0
- package/build/types/common.type.js +2 -0
- package/build/types/index.d.ts +2 -0
- package/build/types/index.js +2 -0
- package/build/types/parsed-filings.type.d.ts +66 -0
- package/build/types/parsed-filings.type.js +2 -0
- package/build/types/submission.type.d.ts +19 -1
- package/package.json +1 -5
- package/build/.DS_Store +0 -0
- package/build/downloader.d.ts +0 -6
- package/build/downloader.js +0 -9
- package/build/services/FactFileReader/FactFileReader.d.ts +0 -30
- package/build/services/FactFileReader/FactFileReader.js +0 -36
- package/build/services/FactFileReader/index.d.ts +0 -2
- package/build/services/FactFileReader/index.js +0 -4
- package/build/services/FactsDownloader/Downloader.d.ts +0 -26
- package/build/services/FactsDownloader/Downloader.js +0 -102
- package/build/services/FactsDownloader/FactsDownloader.d.ts +0 -37
- package/build/services/FactsDownloader/FactsDownloader.js +0 -131
- package/build/services/FactsDownloader/Unzipper.d.ts +0 -40
- package/build/services/FactsDownloader/Unzipper.js +0 -40
- package/build/services/FactsDownloader/index.d.ts +0 -2
- package/build/services/FactsDownloader/index.js +0 -4
- package/build/services/SecEdgarApi/Client.d.ts +0 -44
- package/build/services/SecEdgarApi/Client.js +0 -104
- package/build/services/SecEdgarApi/Downloader.d.ts +0 -26
- package/build/services/SecEdgarApi/Downloader.js +0 -102
- package/build/services/SecEdgarApi/FactsDownloader.d.ts +0 -30
- package/build/services/SecEdgarApi/FactsDownloader.js +0 -124
- package/build/services/SecEdgarApi/SecConnector.d.ts +0 -47
- package/build/services/SecEdgarApi/SecConnector.js +0 -143
- package/build/services/SecEdgarApi/Unzipper.d.ts +0 -40
- package/build/services/SecEdgarApi/Unzipper.js +0 -40
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { parseForm4 } from './parse-form-4';
|
|
2
|
+
import { parseForm13g } from './parse-form-13g';
|
|
3
|
+
import { parseForm10k } from './parse-form-10k';
|
|
4
|
+
declare const parsers: {
|
|
5
|
+
parseForm4: typeof parseForm4;
|
|
6
|
+
parseForm13g: typeof parseForm13g;
|
|
7
|
+
parseForm10k: typeof parseForm10k;
|
|
8
|
+
};
|
|
9
|
+
export default parsers;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var parse_form_4_1 = require("./parse-form-4");
|
|
4
|
+
var parse_form_13g_1 = require("./parse-form-13g");
|
|
5
|
+
var parse_form_10k_1 = require("./parse-form-10k");
|
|
6
|
+
var parsers = {
|
|
7
|
+
parseForm4: parse_form_4_1.parseForm4,
|
|
8
|
+
parseForm13g: parse_form_13g_1.parseForm13g,
|
|
9
|
+
parseForm10k: parse_form_10k_1.parseForm10k,
|
|
10
|
+
};
|
|
11
|
+
exports.default = parsers;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.parseForm10k = void 0;
|
|
13
|
+
var HRNode_1 = require("../XMLNode/HRNode");
|
|
14
|
+
var NonTableNode_1 = require("../XMLNode/NonTableNode");
|
|
15
|
+
var TableNode_1 = require("../XMLNode/TableNode");
|
|
16
|
+
var XMLParser_1 = require("../XMLParser");
|
|
17
|
+
function parseForm10k(params, xmlParser) {
|
|
18
|
+
var _a, _b, _c, _d;
|
|
19
|
+
if (xmlParser === void 0) { xmlParser = new XMLParser_1.default(); }
|
|
20
|
+
var xml = params.xml;
|
|
21
|
+
var doc = xmlParser.getDocumentNode({ xml: xml });
|
|
22
|
+
var nodes = doc.getChildren();
|
|
23
|
+
var tables = nodes.filter(function (child) { return child instanceof TableNode_1.TableNode; });
|
|
24
|
+
var curSectionIndex = 0;
|
|
25
|
+
var sectionIndexByTable = new Map();
|
|
26
|
+
var tableDataArr = [];
|
|
27
|
+
// map the section index of each table. new section starts for each <hr> tag.
|
|
28
|
+
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
29
|
+
var node = nodes_1[_i];
|
|
30
|
+
if (node instanceof TableNode_1.TableNode) {
|
|
31
|
+
sectionIndexByTable.set(node, curSectionIndex);
|
|
32
|
+
}
|
|
33
|
+
else if (node instanceof HRNode_1.HRNode) {
|
|
34
|
+
curSectionIndex++;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
var _loop_1 = function (table) {
|
|
38
|
+
table.mergeHeader();
|
|
39
|
+
table.removeEmptyTopRows();
|
|
40
|
+
var siblingsPrev = table.getSiblings({ dir: 'previous', stopAtType: NonTableNode_1.NonTableNode, includeStopAtType: true });
|
|
41
|
+
var siblingsNext = table.getSiblings({ dir: 'next', stopAtType: NonTableNode_1.NonTableNode, includeStopAtType: true });
|
|
42
|
+
// set the title based on the bold text in the previous siblings
|
|
43
|
+
var title = siblingsPrev.map(function (s) { return s.extractBold(); }).join(' | ');
|
|
44
|
+
var textBefore = siblingsPrev.map(function (s) { return s.getText(); }).join('\n');
|
|
45
|
+
var textAfter = siblingsNext.map(function (s) { return s.getText(); }).join('\n');
|
|
46
|
+
var header = table.getHeaderRow();
|
|
47
|
+
var headerTable = header === null || header === void 0 ? void 0 : header.toTable();
|
|
48
|
+
var topRow = table.getChildren()[0];
|
|
49
|
+
var topRowTable = !header ? topRow === null || topRow === void 0 ? void 0 : topRow.toTable() : null;
|
|
50
|
+
var prevTable = tableDataArr[tableDataArr.length - 1];
|
|
51
|
+
var isSameTableSize = prevTable ? ((_a = prevTable === null || prevTable === void 0 ? void 0 : prevTable.rows[0]) === null || _a === void 0 ? void 0 : _a.length) === ((_b = topRowTable === null || topRowTable === void 0 ? void 0 : topRowTable[0]) === null || _b === void 0 ? void 0 : _b.length) : false;
|
|
52
|
+
var isSameSection = prevTable ? prevTable.sectionIndex === sectionIndexByTable.get(table) : false;
|
|
53
|
+
var isSharedHeader = !!topRowTable && table.getTitle() === '' && isSameTableSize && isSameSection;
|
|
54
|
+
// some tables will be in the same section directly below another table and expected to have the same header.
|
|
55
|
+
if (isSharedHeader) {
|
|
56
|
+
topRowTable.unshift(__spreadArray([], prevTable.rows[0], true));
|
|
57
|
+
table.setTitle(prevTable.title);
|
|
58
|
+
}
|
|
59
|
+
var rows = (_c = headerTable !== null && headerTable !== void 0 ? headerTable : topRowTable) !== null && _c !== void 0 ? _c : [];
|
|
60
|
+
if (rows.length === 0)
|
|
61
|
+
return "continue";
|
|
62
|
+
tableDataArr.push({
|
|
63
|
+
title: title.trim(),
|
|
64
|
+
sectionIndex: (_d = sectionIndexByTable.get(table)) !== null && _d !== void 0 ? _d : -1,
|
|
65
|
+
hasHeader: Boolean(header) || isSharedHeader,
|
|
66
|
+
textBefore: textBefore,
|
|
67
|
+
textAfter: textAfter,
|
|
68
|
+
rows: rows.filter(function (r) { return r.length === rows[0].length; }),
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
// create table arrays
|
|
72
|
+
for (var _e = 0, tables_1 = tables; _e < tables_1.length; _e++) {
|
|
73
|
+
var table = tables_1[_e];
|
|
74
|
+
_loop_1(table);
|
|
75
|
+
}
|
|
76
|
+
return tableDataArr;
|
|
77
|
+
}
|
|
78
|
+
exports.parseForm10k = parseForm10k;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Holder, XMLParams } from '../../../types';
|
|
2
|
+
import XMLParser from '../XMLParser';
|
|
3
|
+
/**
|
|
4
|
+
* Form SC 13G - Holders
|
|
5
|
+
*
|
|
6
|
+
* example at https://www.sec.gov/Archives/edgar/data/320193/000119312523038262/d382361dsc13ga.htm
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseForm13g(params: XMLParams, xmlParser?: XMLParser): Holder[];
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseForm13g = void 0;
|
|
4
|
+
var XMLParser_1 = require("../XMLParser");
|
|
5
|
+
/**
|
|
6
|
+
* Form SC 13G - Holders
|
|
7
|
+
*
|
|
8
|
+
* example at https://www.sec.gov/Archives/edgar/data/320193/000119312523038262/d382361dsc13ga.htm
|
|
9
|
+
*/
|
|
10
|
+
function parseForm13g(params, xmlParser) {
|
|
11
|
+
var _a, _b, _c, _d;
|
|
12
|
+
if (xmlParser === void 0) { xmlParser = new XMLParser_1.default(); }
|
|
13
|
+
var xml = params.xml;
|
|
14
|
+
var textMap = xmlParser.getTableTextMap({ xml: xml });
|
|
15
|
+
var holders = [];
|
|
16
|
+
var getKey = function (text) {
|
|
17
|
+
var keyMap = {
|
|
18
|
+
'name of reporting': 'name',
|
|
19
|
+
'names of reporting': 'name',
|
|
20
|
+
'citizenship or place': 'origin',
|
|
21
|
+
'sole voting power': 'votingPowerSole',
|
|
22
|
+
'shared voting power': 'votingPowerShared',
|
|
23
|
+
'sole dispositive power': 'dispositivePowerSole',
|
|
24
|
+
'shared dispositive power': 'dispositivePowerShared',
|
|
25
|
+
'aggregate amount beneficially owned': 'shares',
|
|
26
|
+
'percent of class': 'percentOfClass',
|
|
27
|
+
'type of reporting person': 'typeOfReportingPerson',
|
|
28
|
+
};
|
|
29
|
+
var textLower = text.toLowerCase();
|
|
30
|
+
for (var key in keyMap) {
|
|
31
|
+
if (textLower.includes(key))
|
|
32
|
+
return keyMap[key];
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
var _loop_1 = function (text) {
|
|
37
|
+
var colName = getKey(text);
|
|
38
|
+
var isNewHolder = colName === 'name';
|
|
39
|
+
if (isNewHolder) {
|
|
40
|
+
if (((_a = holders[holders.length - 1]) === null || _a === void 0 ? void 0 : _a.name) === '') {
|
|
41
|
+
holders.pop();
|
|
42
|
+
}
|
|
43
|
+
holders.push({
|
|
44
|
+
name: '',
|
|
45
|
+
origin: '',
|
|
46
|
+
shares: 0,
|
|
47
|
+
percentOfClass: '',
|
|
48
|
+
votingPowerSole: null,
|
|
49
|
+
votingPowerShared: null,
|
|
50
|
+
dispositivePowerSole: null,
|
|
51
|
+
dispositivePowerShared: null,
|
|
52
|
+
typeOfReportingPerson: null,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
var holder = holders[holders.length - 1];
|
|
56
|
+
// continue if no colName or if the value is already set
|
|
57
|
+
if (colName === null || ![0, '', null].includes(holder[colName]))
|
|
58
|
+
return "continue";
|
|
59
|
+
var textParts = text.split(' ').filter(function (t) { return t.trim() !== ''; });
|
|
60
|
+
var colNameIndex = textParts.findIndex(function (t) { return getKey(t) === colName; });
|
|
61
|
+
var value = (_c = (_b = textParts[colNameIndex + 1]) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : '';
|
|
62
|
+
switch (colName) {
|
|
63
|
+
case 'shares':
|
|
64
|
+
holder.shares = Number(value.replace(/[^0-9]/g, '')) || 0;
|
|
65
|
+
break;
|
|
66
|
+
case 'typeOfReportingPerson':
|
|
67
|
+
holder[colName] = value === '' ? null : value;
|
|
68
|
+
break;
|
|
69
|
+
case 'votingPowerSole':
|
|
70
|
+
case 'votingPowerShared':
|
|
71
|
+
case 'dispositivePowerSole':
|
|
72
|
+
case 'dispositivePowerShared':
|
|
73
|
+
holder[colName] = value.toLowerCase() === 'none' ? null : value;
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
holder[colName] = value;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
for (var _i = 0, _e = Array.from(textMap.values()); _i < _e.length; _i++) {
|
|
80
|
+
var text = _e[_i];
|
|
81
|
+
_loop_1(text);
|
|
82
|
+
}
|
|
83
|
+
if (((_d = holders[holders.length - 1]) === null || _d === void 0 ? void 0 : _d.name) === '') {
|
|
84
|
+
holders.pop();
|
|
85
|
+
}
|
|
86
|
+
return holders;
|
|
87
|
+
}
|
|
88
|
+
exports.parseForm13g = parseForm13g;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { InsiderTransaction, XMLParams } from '../../../types';
|
|
2
|
+
import XMLParser from '../XMLParser';
|
|
3
|
+
/**
|
|
4
|
+
* Form 4 - Insider Transactions
|
|
5
|
+
*
|
|
6
|
+
* example at https://www.sec.gov/Archives/edgar/data/320193/000032019323000079/xslF345X05/wk-form4_1691533817.xml
|
|
7
|
+
*/
|
|
8
|
+
export declare function parseForm4(params: XMLParams, xmlParser?: XMLParser): InsiderTransaction[];
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseForm4 = void 0;
|
|
4
|
+
var XMLParser_1 = require("../XMLParser");
|
|
5
|
+
/**
|
|
6
|
+
* Form 4 - Insider Transactions
|
|
7
|
+
*
|
|
8
|
+
* example at https://www.sec.gov/Archives/edgar/data/320193/000032019323000079/xslF345X05/wk-form4_1691533817.xml
|
|
9
|
+
*/
|
|
10
|
+
function parseForm4(params, xmlParser) {
|
|
11
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
12
|
+
if (xmlParser === void 0) { xmlParser = new XMLParser_1.default(); }
|
|
13
|
+
var xml = params.xml;
|
|
14
|
+
var textMap = xmlParser.getTableTextMap({ xml: xml, parentPath: 'html.body' });
|
|
15
|
+
var getTextBetween = function (text, before, after) {
|
|
16
|
+
var indexBefore = text.indexOf(before);
|
|
17
|
+
var indexAfter = after ? text.indexOf(after, indexBefore) : text.length;
|
|
18
|
+
return text.substring(indexBefore + before.length, indexAfter).trim();
|
|
19
|
+
};
|
|
20
|
+
var relationText = (_a = textMap.get('2.1.3')) !== null && _a !== void 0 ? _a : '';
|
|
21
|
+
var filerNameText = (_b = textMap.get('2.1.1')) !== null && _b !== void 0 ? _b : '';
|
|
22
|
+
var filterNameText = getTextBetween(filerNameText, '1. Name and Address of Reporting Person*', '(Last)');
|
|
23
|
+
var isDirector = relationText.substring(0, relationText.indexOf('Director')).includes('X');
|
|
24
|
+
var isOwner10 = getTextBetween(relationText, 'Director', '10% Owner').includes('X');
|
|
25
|
+
var isOfficer = getTextBetween(relationText, '10% Owner', 'Officer (give title below)').includes('X');
|
|
26
|
+
var isOther = getTextBetween(relationText, 'Officer (give title below)', 'Other (specify below)').includes('X');
|
|
27
|
+
var position = getTextBetween(relationText, 'Other (specify below)');
|
|
28
|
+
var filerPositionTypes = [];
|
|
29
|
+
if (isDirector)
|
|
30
|
+
filerPositionTypes.push('Director');
|
|
31
|
+
if (isOwner10)
|
|
32
|
+
filerPositionTypes.push('10% Owner');
|
|
33
|
+
if (isOfficer)
|
|
34
|
+
filerPositionTypes.push('Officer');
|
|
35
|
+
if (isOther)
|
|
36
|
+
filerPositionTypes.push('Other');
|
|
37
|
+
var codeTranslations = {
|
|
38
|
+
P: 'Purchase',
|
|
39
|
+
S: 'Sale',
|
|
40
|
+
V: 'Voluntary Reporting',
|
|
41
|
+
A: 'Grant',
|
|
42
|
+
D: 'Sale to Issuer',
|
|
43
|
+
F: 'Payment of Exercise Price',
|
|
44
|
+
I: 'Discretionary Transaction',
|
|
45
|
+
M: 'Conversion of Derivative Exempt',
|
|
46
|
+
C: 'Conversion of Derivative',
|
|
47
|
+
E: 'Expiration of Short Derivative Position',
|
|
48
|
+
H: 'Expiration of Long Derivative Position',
|
|
49
|
+
O: 'Exercise of out-of-the-money Derivative',
|
|
50
|
+
X: 'Exercise of in-the-money Derivative',
|
|
51
|
+
G: 'Gift',
|
|
52
|
+
L: 'Small Acquisition',
|
|
53
|
+
W: 'Acquisition or Disposition By Will or Laws',
|
|
54
|
+
Z: 'Voting Trust Deposit or Withdrawal',
|
|
55
|
+
J: 'Other Acquisition or Disposition',
|
|
56
|
+
K: 'Equity Swap',
|
|
57
|
+
U: 'Disposition Change in Control',
|
|
58
|
+
};
|
|
59
|
+
var toDate = function (str) {
|
|
60
|
+
if (str === '')
|
|
61
|
+
return '';
|
|
62
|
+
var _a = str.split('/'), month = _a[0], day = _a[1], year = _a[2];
|
|
63
|
+
return [month, day, year].some(function (x) { return x === undefined; }) ? '' : "".concat(year, "-").concat(month, "-").concat(day);
|
|
64
|
+
};
|
|
65
|
+
var createTransaction = function () { return ({
|
|
66
|
+
filerName: filterNameText,
|
|
67
|
+
filerPosition: position,
|
|
68
|
+
filerPositionTypes: filerPositionTypes,
|
|
69
|
+
category: 'Non-Derivative',
|
|
70
|
+
securityType: '',
|
|
71
|
+
securityTypeUnderlying: null,
|
|
72
|
+
date: '',
|
|
73
|
+
dateExecuted: null,
|
|
74
|
+
dateExpiration: null,
|
|
75
|
+
dateExercisable: null,
|
|
76
|
+
transactionType: null,
|
|
77
|
+
transactionCode: null,
|
|
78
|
+
transactionDescription: null,
|
|
79
|
+
price: null,
|
|
80
|
+
priceExcercised: null,
|
|
81
|
+
shares: null,
|
|
82
|
+
sharesUnderlying: null,
|
|
83
|
+
sharesEnding: null,
|
|
84
|
+
ownership: '',
|
|
85
|
+
explainationByKey: {},
|
|
86
|
+
}); };
|
|
87
|
+
var getColText = function (colKey) {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
var text = (_a = textMap.get(colKey)) === null || _a === void 0 ? void 0 : _a.replace(/\(\d+\)|\$/g, '');
|
|
90
|
+
return (_b = text === null || text === void 0 ? void 0 : text.trim()) !== null && _b !== void 0 ? _b : '';
|
|
91
|
+
};
|
|
92
|
+
var headingNonDerivative = [
|
|
93
|
+
'securityType',
|
|
94
|
+
'date',
|
|
95
|
+
'dateExecuted',
|
|
96
|
+
'transactionCode',
|
|
97
|
+
'',
|
|
98
|
+
'shares',
|
|
99
|
+
'transactionType',
|
|
100
|
+
'price',
|
|
101
|
+
'sharesEnding',
|
|
102
|
+
'ownership',
|
|
103
|
+
];
|
|
104
|
+
var headingDerivative = [
|
|
105
|
+
'securityType',
|
|
106
|
+
'priceExcercised',
|
|
107
|
+
'date',
|
|
108
|
+
'dateExecuted',
|
|
109
|
+
'transactionCode',
|
|
110
|
+
'',
|
|
111
|
+
'shares',
|
|
112
|
+
'shares',
|
|
113
|
+
'dateExercisable',
|
|
114
|
+
'dateExpiration',
|
|
115
|
+
'securityTypeUnderlying',
|
|
116
|
+
'sharesUnderlying',
|
|
117
|
+
'price',
|
|
118
|
+
'sharesEnding',
|
|
119
|
+
'ownership',
|
|
120
|
+
];
|
|
121
|
+
var maxIterations = 10000;
|
|
122
|
+
var transactions = [];
|
|
123
|
+
transactionsNonDerivative: for (var row = 4; row < maxIterations; row++) {
|
|
124
|
+
var transaction = createTransaction();
|
|
125
|
+
transaction.category = 'Non-Derivative';
|
|
126
|
+
// get all non-derivative transactions
|
|
127
|
+
for (var col = 1; col < 11; col++) {
|
|
128
|
+
var colName = ((_c = headingNonDerivative[col - 1]) !== null && _c !== void 0 ? _c : '');
|
|
129
|
+
var colKey = "3.".concat(row, ".").concat(col);
|
|
130
|
+
var text = getColText(colKey);
|
|
131
|
+
var explanationNum = (_f = (_e = ((_d = textMap.get(colKey)) !== null && _d !== void 0 ? _d : '').match(/(?<=\()\d+(?=\))/g)) === null || _e === void 0 ? void 0 : _e[0]) !== null && _f !== void 0 ? _f : null;
|
|
132
|
+
var explanationText = explanationNum ? (_g = textMap.get("5.".concat(Number(explanationNum) + 1, ".1"))) !== null && _g !== void 0 ? _g : '' : null;
|
|
133
|
+
if (colName === '')
|
|
134
|
+
continue;
|
|
135
|
+
if (explanationText !== null)
|
|
136
|
+
transaction.explainationByKey[colName] = explanationText.trim();
|
|
137
|
+
if (!textMap.has(colKey))
|
|
138
|
+
break transactionsNonDerivative;
|
|
139
|
+
switch (colName) {
|
|
140
|
+
case 'transactionType':
|
|
141
|
+
transaction.transactionType = text === 'A' ? 'Acquire' : 'Dispose';
|
|
142
|
+
continue;
|
|
143
|
+
case 'transactionCode':
|
|
144
|
+
transaction.transactionDescription = (_h = codeTranslations[text]) !== null && _h !== void 0 ? _h : '';
|
|
145
|
+
transaction.transactionCode = text;
|
|
146
|
+
continue;
|
|
147
|
+
case 'date':
|
|
148
|
+
transaction.date = toDate(text);
|
|
149
|
+
continue;
|
|
150
|
+
case 'dateExecuted':
|
|
151
|
+
case 'dateExercisable':
|
|
152
|
+
case 'dateExpiration':
|
|
153
|
+
transaction[colName] = toDate(text) || null;
|
|
154
|
+
continue;
|
|
155
|
+
case 'price':
|
|
156
|
+
case 'shares':
|
|
157
|
+
case 'sharesEnding':
|
|
158
|
+
var valueNum = Number(text.replace(/,/g, ''));
|
|
159
|
+
transaction[colName] = text === '' || isNaN(valueNum) ? null : valueNum;
|
|
160
|
+
continue;
|
|
161
|
+
default:
|
|
162
|
+
transaction[colName] = text;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
transactions.push(transaction);
|
|
166
|
+
}
|
|
167
|
+
transactionsDerivative: for (var row = 4; row < maxIterations; row++) {
|
|
168
|
+
var transaction = createTransaction();
|
|
169
|
+
transaction.category = 'Derivative';
|
|
170
|
+
var textSharesAcquired = getColText("4.".concat(row, ".6"));
|
|
171
|
+
var textSharesDisposed = getColText("4.".concat(row, ".7"));
|
|
172
|
+
var sharesAcquired = Number(textSharesAcquired);
|
|
173
|
+
var sharesDisposed = Number(textSharesDisposed);
|
|
174
|
+
if (textSharesAcquired !== '' || textSharesDisposed !== '') {
|
|
175
|
+
transaction.transactionType = sharesAcquired - sharesDisposed > 0 ? 'Acquire' : 'Dispose';
|
|
176
|
+
}
|
|
177
|
+
for (var col = 1; col < 16; col++) {
|
|
178
|
+
var colName = ((_j = headingDerivative[col - 1]) !== null && _j !== void 0 ? _j : '');
|
|
179
|
+
var colKey = "4.".concat(row, ".").concat(col);
|
|
180
|
+
var text = ((_k = textMap.get(colKey)) !== null && _k !== void 0 ? _k : '').replace(/\(\d+\)|\$/g, '').trim();
|
|
181
|
+
var explanationNum = (_o = (_m = ((_l = textMap.get(colKey)) !== null && _l !== void 0 ? _l : '').match(/(?<=\()\d+(?=\))/g)) === null || _m === void 0 ? void 0 : _m[0]) !== null && _o !== void 0 ? _o : null;
|
|
182
|
+
var explanationText = explanationNum ? (_p = textMap.get("5.".concat(Number(explanationNum) + 1, ".1"))) !== null && _p !== void 0 ? _p : '' : null;
|
|
183
|
+
if (colName === '')
|
|
184
|
+
continue;
|
|
185
|
+
if (explanationText !== null)
|
|
186
|
+
transaction.explainationByKey[colName] = explanationText.trim();
|
|
187
|
+
if (!textMap.has(colKey))
|
|
188
|
+
break transactionsDerivative;
|
|
189
|
+
switch (colName) {
|
|
190
|
+
case 'transactionType':
|
|
191
|
+
transaction.transactionType = text === 'A' ? 'Acquire' : 'Dispose';
|
|
192
|
+
continue;
|
|
193
|
+
case 'transactionCode':
|
|
194
|
+
transaction.transactionDescription = (_q = codeTranslations[text]) !== null && _q !== void 0 ? _q : '';
|
|
195
|
+
transaction.transactionCode = text;
|
|
196
|
+
continue;
|
|
197
|
+
case 'dateExecuted':
|
|
198
|
+
case 'dateExercisable':
|
|
199
|
+
case 'dateExpiration':
|
|
200
|
+
transaction[colName] = toDate(text) || null;
|
|
201
|
+
continue;
|
|
202
|
+
case 'price':
|
|
203
|
+
case 'shares':
|
|
204
|
+
case 'sharesUnderlying':
|
|
205
|
+
case 'priceExcercised':
|
|
206
|
+
case 'sharesEnding':
|
|
207
|
+
if (colName === 'shares' && transaction.shares !== null)
|
|
208
|
+
continue;
|
|
209
|
+
var valueNum = Number(text.replace(/,/g, ''));
|
|
210
|
+
transaction[colName] = text === '' || isNaN(valueNum) ? null : valueNum;
|
|
211
|
+
continue;
|
|
212
|
+
default:
|
|
213
|
+
transaction[colName] = text;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
transactions.push(transaction);
|
|
217
|
+
}
|
|
218
|
+
return transactions;
|
|
219
|
+
}
|
|
220
|
+
exports.parseForm4 = parseForm4;
|
|
@@ -24,11 +24,11 @@ export default class ReportParser {
|
|
|
24
24
|
*
|
|
25
25
|
* @param companyFactListData This is the json file contents of CIK[number].json file from the SEC website. You can find these using their API or by downloading the companyfacts.zip file: https://www.sec.gov/edgar/sec-api-documentation
|
|
26
26
|
*/
|
|
27
|
-
parseReports(companyFactListData: Pick<CompanyFactListData, 'facts'
|
|
27
|
+
parseReports(companyFactListData: Pick<CompanyFactListData, 'facts'>, usePropertyResolver?: boolean): ReportWrapper[];
|
|
28
28
|
/**
|
|
29
29
|
* Same as parseReports but accepts ReportRaw[] instead of CompanyFactListData
|
|
30
30
|
*/
|
|
31
|
-
parseReportsFromRaw(reportsRaw: ReportRaw[]): ReportWrapper[];
|
|
31
|
+
parseReportsFromRaw(reportsRaw: ReportRaw[], usePropertyResolver?: boolean): ReportWrapper[];
|
|
32
32
|
/**
|
|
33
33
|
* Note that this includes all reports by default, not just annual and quarterly. use options.reportsToInclude to filter
|
|
34
34
|
*
|
|
@@ -21,16 +21,18 @@ var ReportParser = /** @class */ (function () {
|
|
|
21
21
|
*
|
|
22
22
|
* @param companyFactListData This is the json file contents of CIK[number].json file from the SEC website. You can find these using their API or by downloading the companyfacts.zip file: https://www.sec.gov/edgar/sec-api-documentation
|
|
23
23
|
*/
|
|
24
|
-
ReportParser.prototype.parseReports = function (companyFactListData) {
|
|
24
|
+
ReportParser.prototype.parseReports = function (companyFactListData, usePropertyResolver) {
|
|
25
|
+
if (usePropertyResolver === void 0) { usePropertyResolver = true; }
|
|
25
26
|
var reportsRaw = this.reportRawParser.parseReports(companyFactListData, {
|
|
26
27
|
reportsToInclude: ['ANNUAL', 'QUARTERLY'],
|
|
27
28
|
});
|
|
28
|
-
return this.parseReportsFromRaw(reportsRaw);
|
|
29
|
+
return this.parseReportsFromRaw(reportsRaw, usePropertyResolver);
|
|
29
30
|
};
|
|
30
31
|
/**
|
|
31
32
|
* Same as parseReports but accepts ReportRaw[] instead of CompanyFactListData
|
|
32
33
|
*/
|
|
33
|
-
ReportParser.prototype.parseReportsFromRaw = function (reportsRaw) {
|
|
34
|
+
ReportParser.prototype.parseReportsFromRaw = function (reportsRaw, usePropertyResolver) {
|
|
35
|
+
if (usePropertyResolver === void 0) { usePropertyResolver = true; }
|
|
34
36
|
var reportByYearQuarter = new Map();
|
|
35
37
|
var reportsRawFiltered = reportsRaw.filter(function (reportRaw) {
|
|
36
38
|
return reportRaw.reportType === 'ANNUAL' || reportRaw.reportType === 'QUARTERLY';
|
|
@@ -42,7 +44,9 @@ var ReportParser = /** @class */ (function () {
|
|
|
42
44
|
return report;
|
|
43
45
|
});
|
|
44
46
|
var reportWrappers = Array.from(reportByYearQuarter.values());
|
|
45
|
-
|
|
47
|
+
if (usePropertyResolver) {
|
|
48
|
+
this.propertyResolver.resolveAll(reportWrappers);
|
|
49
|
+
}
|
|
46
50
|
return reportWrappers;
|
|
47
51
|
};
|
|
48
52
|
/**
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { FilingListItemTranslated } from '../../types/submission.type';
|
|
2
|
+
export interface SubmissionRequestWrapperOptions {
|
|
3
|
+
maxRequests?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface SendRequestParams {
|
|
6
|
+
url: string;
|
|
7
|
+
}
|
|
8
|
+
interface SubmissionRequestWrapperArgs<T> {
|
|
9
|
+
submissions: FilingListItemTranslated[];
|
|
10
|
+
options?: SubmissionRequestWrapperOptions;
|
|
11
|
+
sendRequest: (params: SendRequestParams) => Promise<T>;
|
|
12
|
+
}
|
|
13
|
+
interface SubmissionRequestWrapperResult<T> {
|
|
14
|
+
result: T | null;
|
|
15
|
+
error: string | null;
|
|
16
|
+
submission: FilingListItemTranslated;
|
|
17
|
+
}
|
|
18
|
+
export default class SubmissionRequestWrapper<T> {
|
|
19
|
+
private results;
|
|
20
|
+
private readonly options;
|
|
21
|
+
private readonly submissions;
|
|
22
|
+
private readonly errors;
|
|
23
|
+
private readonly sendRequest;
|
|
24
|
+
private requestCount;
|
|
25
|
+
private isDone;
|
|
26
|
+
constructor(args: SubmissionRequestWrapperArgs<T>);
|
|
27
|
+
setOptions(options: SubmissionRequestWrapperOptions): void;
|
|
28
|
+
requestNext(): Promise<SubmissionRequestWrapperResult<T>>;
|
|
29
|
+
skip(count?: number): void;
|
|
30
|
+
requestAll(): Promise<SubmissionRequestWrapperResult<T>[]>;
|
|
31
|
+
clearResults(): void;
|
|
32
|
+
getResults(): SubmissionRequestWrapperResult<T>[];
|
|
33
|
+
getErrors(): string[];
|
|
34
|
+
getSize(): number;
|
|
35
|
+
getSubmissions(): FilingListItemTranslated[];
|
|
36
|
+
}
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
var SubmissionRequestWrapper = /** @class */ (function () {
|
|
40
|
+
function SubmissionRequestWrapper(args) {
|
|
41
|
+
var submissions = args.submissions, _a = args.options, options = _a === void 0 ? {} : _a, sendRequest = args.sendRequest;
|
|
42
|
+
this.options = options;
|
|
43
|
+
this.submissions = submissions;
|
|
44
|
+
this.results = [];
|
|
45
|
+
this.errors = [];
|
|
46
|
+
this.sendRequest = sendRequest;
|
|
47
|
+
this.requestCount = 0;
|
|
48
|
+
this.isDone = (options === null || options === void 0 ? void 0 : options.maxRequests) === 0;
|
|
49
|
+
}
|
|
50
|
+
SubmissionRequestWrapper.prototype.setOptions = function (options) {
|
|
51
|
+
for (var key in options) {
|
|
52
|
+
this.options[key] =
|
|
53
|
+
options[key];
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
SubmissionRequestWrapper.prototype.requestNext = function () {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
var _a, maxRequests, submission, isComplete, url, result, data, e_1, error;
|
|
59
|
+
return __generator(this, function (_b) {
|
|
60
|
+
switch (_b.label) {
|
|
61
|
+
case 0:
|
|
62
|
+
_a = this.options.maxRequests, maxRequests = _a === void 0 ? Infinity : _a;
|
|
63
|
+
submission = this.submissions[this.requestCount];
|
|
64
|
+
isComplete = this.requestCount >= maxRequests || this.isDone;
|
|
65
|
+
if (isComplete || !submission) {
|
|
66
|
+
return [2 /*return*/, {
|
|
67
|
+
submission: submission,
|
|
68
|
+
error: isComplete ? 'max requests reached' : 'no submission found',
|
|
69
|
+
result: null,
|
|
70
|
+
}];
|
|
71
|
+
}
|
|
72
|
+
url = submission.url;
|
|
73
|
+
this.requestCount++;
|
|
74
|
+
if (this.requestCount >= this.submissions.length || this.requestCount >= maxRequests) {
|
|
75
|
+
this.isDone = true;
|
|
76
|
+
}
|
|
77
|
+
_b.label = 1;
|
|
78
|
+
case 1:
|
|
79
|
+
_b.trys.push([1, 3, , 4]);
|
|
80
|
+
return [4 /*yield*/, this.sendRequest({ url: url })];
|
|
81
|
+
case 2:
|
|
82
|
+
result = _b.sent();
|
|
83
|
+
data = {
|
|
84
|
+
submission: submission,
|
|
85
|
+
error: null,
|
|
86
|
+
result: result,
|
|
87
|
+
};
|
|
88
|
+
this.results.push(data);
|
|
89
|
+
return [2 /*return*/, data];
|
|
90
|
+
case 3:
|
|
91
|
+
e_1 = _b.sent();
|
|
92
|
+
error = e_1;
|
|
93
|
+
this.errors.push(error.message);
|
|
94
|
+
return [2 /*return*/, {
|
|
95
|
+
submission: submission,
|
|
96
|
+
error: error.message,
|
|
97
|
+
result: null,
|
|
98
|
+
}];
|
|
99
|
+
case 4: return [2 /*return*/];
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
SubmissionRequestWrapper.prototype.skip = function (count) {
|
|
105
|
+
if (count === void 0) { count = 1; }
|
|
106
|
+
this.requestCount += count;
|
|
107
|
+
};
|
|
108
|
+
SubmissionRequestWrapper.prototype.requestAll = function () {
|
|
109
|
+
var _a;
|
|
110
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
111
|
+
var promises, maxRequests, i, results;
|
|
112
|
+
var _this = this;
|
|
113
|
+
return __generator(this, function (_b) {
|
|
114
|
+
switch (_b.label) {
|
|
115
|
+
case 0:
|
|
116
|
+
promises = [];
|
|
117
|
+
maxRequests = (_a = this.options.maxRequests) !== null && _a !== void 0 ? _a : this.submissions.length;
|
|
118
|
+
for (i = 0; i < maxRequests; i++) {
|
|
119
|
+
promises.push(this.requestNext());
|
|
120
|
+
}
|
|
121
|
+
return [4 /*yield*/, Promise.all(promises)];
|
|
122
|
+
case 1:
|
|
123
|
+
results = _b.sent();
|
|
124
|
+
results.forEach(function (result) { return _this.results.push(result); });
|
|
125
|
+
return [2 /*return*/, results];
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
SubmissionRequestWrapper.prototype.clearResults = function () {
|
|
131
|
+
this.results = [];
|
|
132
|
+
};
|
|
133
|
+
SubmissionRequestWrapper.prototype.getResults = function () {
|
|
134
|
+
return this.results;
|
|
135
|
+
};
|
|
136
|
+
SubmissionRequestWrapper.prototype.getErrors = function () {
|
|
137
|
+
return this.errors;
|
|
138
|
+
};
|
|
139
|
+
SubmissionRequestWrapper.prototype.getSize = function () {
|
|
140
|
+
return this.submissions.length;
|
|
141
|
+
};
|
|
142
|
+
SubmissionRequestWrapper.prototype.getSubmissions = function () {
|
|
143
|
+
return this.submissions;
|
|
144
|
+
};
|
|
145
|
+
return SubmissionRequestWrapper;
|
|
146
|
+
}());
|
|
147
|
+
exports.default = SubmissionRequestWrapper;
|