sec-edgar-api 0.2.1 → 0.2.3
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/build/services/ReportBuilder/FactFiscalCalculator.d.ts +51 -0
- package/build/services/ReportBuilder/FactFiscalCalculator.js +232 -0
- package/build/services/ReportBuilder/FactPeriodResolver.d.ts +48 -0
- package/build/services/ReportBuilder/FactPeriodResolver.js +190 -0
- package/build/services/ReportBuilder/FactRecordBuilder.d.ts +10 -0
- package/build/services/ReportBuilder/FactRecordBuilder.js +71 -0
- package/build/services/ReportBuilder/FactSplitAdjuster.d.ts +46 -0
- package/build/services/ReportBuilder/FactSplitAdjuster.js +203 -0
- package/build/services/ReportBuilder/ReportBuilder.d.ts +40 -0
- package/build/services/ReportBuilder/ReportBuilder.js +186 -0
- package/build/services/ReportBuilder/ReportRawResolvable.d.ts +17 -0
- package/build/services/ReportBuilder/ReportRawResolvable.js +114 -0
- package/build/services/ReportBuilder/index.d.ts +2 -0
- package/build/services/ReportBuilder/index.js +4 -0
- package/build/services/ReportParser/PropertyResolver.d.ts +1 -0
- package/build/services/ReportParser/PropertyResolver.js +1 -0
- package/build/services/ReportParser/ReportParser.d.ts +4 -11
- package/build/services/ReportParser/ReportParser.js +15 -27
- package/build/services/ReportParser/ReportRawParser.d.ts +3 -32
- package/build/services/ReportParser/ReportRawParser.js +6 -146
- package/build/services/ReportParser/ReportWrapper.js +4 -5
- package/build/services/ReportParser/resolvers/index.d.ts +2 -0
- package/build/services/ReportParser/resolvers/index.js +2 -0
- package/build/services/ReportParser/resolvers/resolve-cash-flow-capex.js +4 -3
- package/build/services/ReportParser/resolvers/resolve-cash-flow-operating.js +1 -1
- package/build/services/ReportParser/resolvers/resolve-cash-flow-working-capital-non-cash.js +1 -1
- package/build/services/ReportParser/resolvers/resolve-expense-depreciation.js +1 -1
- package/build/services/ReportParser/resolvers/resolve-fiscal-year-cumulative-properties.js +30 -15
- package/build/services/ReportParser/resolvers/resolve-q4-fiscal-year-matching-properties.js +32 -4
- package/build/services/ReportParser/resolvers/resolve-split-ratio.d.ts +2 -0
- package/build/services/ReportParser/resolvers/resolve-split-ratio.js +37 -0
- package/build/services/SecEdgarApi/SecEdgarApi.d.ts +1 -2
- package/build/types/report-raw.type.d.ts +5 -6
- package/build/types/report-translated.type.d.ts +4 -2
- package/build/util/calculation-map-by-ns.d.ts +6 -0
- package/build/util/calculation-map-by-ns.js +9 -0
- package/build/util/key-translations.js +5 -2
- package/package.json +1 -1
- package/build/services/ReportParser/FactIterator.d.ts +0 -18
- package/build/services/ReportParser/FactIterator.js +0 -35
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
var key_translations_1 = require("../../util/key-translations");
|
|
4
|
+
var ReportRawResolvable_1 = require("../ReportBuilder/ReportRawResolvable");
|
|
4
5
|
var PropertyResolver_1 = require("./PropertyResolver");
|
|
5
6
|
var ReportRawParser_1 = require("./ReportRawParser");
|
|
6
7
|
var ReportWrapper_1 = require("./ReportWrapper");
|
|
@@ -23,9 +24,7 @@ var ReportParser = /** @class */ (function () {
|
|
|
23
24
|
*/
|
|
24
25
|
ReportParser.prototype.parseReports = function (companyFactListData, usePropertyResolver) {
|
|
25
26
|
if (usePropertyResolver === void 0) { usePropertyResolver = true; }
|
|
26
|
-
var reportsRaw = this.reportRawParser.parseReports(companyFactListData
|
|
27
|
-
reportsToInclude: ['ANNUAL', 'QUARTERLY'],
|
|
28
|
-
});
|
|
27
|
+
var reportsRaw = this.reportRawParser.parseReports(companyFactListData);
|
|
29
28
|
return this.parseReportsFromRaw(reportsRaw, usePropertyResolver);
|
|
30
29
|
};
|
|
31
30
|
/**
|
|
@@ -34,9 +33,7 @@ var ReportParser = /** @class */ (function () {
|
|
|
34
33
|
ReportParser.prototype.parseReportsFromRaw = function (reportsRaw, usePropertyResolver) {
|
|
35
34
|
if (usePropertyResolver === void 0) { usePropertyResolver = true; }
|
|
36
35
|
var reportByYearQuarter = new Map();
|
|
37
|
-
var reportsRawFiltered = reportsRaw
|
|
38
|
-
return reportRaw.reportType === 'ANNUAL' || reportRaw.reportType === 'QUARTERLY';
|
|
39
|
-
});
|
|
36
|
+
var reportsRawFiltered = reportsRaw;
|
|
40
37
|
this.translateReportsRaw(reportsRawFiltered, function (report, reportRaw) {
|
|
41
38
|
var fiscalPeriod = report.fiscalPeriod, fiscalYear = report.fiscalYear;
|
|
42
39
|
var keyReport = "".concat(fiscalYear, "_").concat(fiscalPeriod);
|
|
@@ -54,36 +51,25 @@ var ReportParser = /** @class */ (function () {
|
|
|
54
51
|
*
|
|
55
52
|
* @see https://www.sec.gov/edgar/sec-api-documentation
|
|
56
53
|
*/
|
|
57
|
-
ReportParser.prototype.parseReportsRaw = function (companyFactListData
|
|
58
|
-
return this.reportRawParser.parseReports(companyFactListData
|
|
54
|
+
ReportParser.prototype.parseReportsRaw = function (companyFactListData) {
|
|
55
|
+
return this.reportRawParser.parseReports(companyFactListData);
|
|
59
56
|
};
|
|
60
57
|
/**
|
|
61
58
|
* parseReportsRaw but removes meta data from the report
|
|
62
59
|
*/
|
|
63
|
-
ReportParser.prototype.parseReportsRawNoMeta = function (companyFactListData
|
|
64
|
-
var reportsRaw = this.parseReportsRaw(companyFactListData
|
|
60
|
+
ReportParser.prototype.parseReportsRawNoMeta = function (companyFactListData) {
|
|
61
|
+
var reportsRaw = this.parseReportsRaw(companyFactListData);
|
|
65
62
|
reportsRaw.forEach(function (reportRaw) {
|
|
66
63
|
var report = reportRaw;
|
|
67
64
|
delete report.dateFiled;
|
|
68
65
|
delete report.dateReport;
|
|
69
66
|
delete report.fiscalPeriod;
|
|
70
67
|
delete report.fiscalYear;
|
|
71
|
-
delete report.
|
|
72
|
-
delete report.
|
|
73
|
-
delete report.isTTM;
|
|
74
|
-
delete report.reportType;
|
|
75
|
-
delete report.taxonomy;
|
|
68
|
+
delete report.splitRatio;
|
|
69
|
+
delete report.splitDate;
|
|
76
70
|
});
|
|
77
71
|
return reportsRaw;
|
|
78
72
|
};
|
|
79
|
-
/**
|
|
80
|
-
* Avoids deep nesting logic while iteratating through company facts
|
|
81
|
-
*
|
|
82
|
-
* @param callback called on each company fact.
|
|
83
|
-
*/
|
|
84
|
-
ReportParser.prototype.iterateCompanyFacts = function (companyFactListData, callback) {
|
|
85
|
-
this.reportRawParser.iterateCompanyFacts(companyFactListData, callback);
|
|
86
|
-
};
|
|
87
73
|
/**
|
|
88
74
|
* Translate ReportRaw to ReportTranslated by default, but can be used to translate to any object using both the callback and keyTranslator
|
|
89
75
|
*
|
|
@@ -94,22 +80,24 @@ var ReportParser = /** @class */ (function () {
|
|
|
94
80
|
ReportParser.prototype.translateReportsRaw = function (reportsRaw, callback, keyTranslator) {
|
|
95
81
|
var keyTranslations = (keyTranslator !== null && keyTranslator !== void 0 ? keyTranslator : this.keyTranslator);
|
|
96
82
|
var reports = [];
|
|
97
|
-
reportsRaw.forEach(function (
|
|
83
|
+
reportsRaw.forEach(function (report) {
|
|
98
84
|
var reportNew = {};
|
|
85
|
+
var reportRaw = new ReportRawResolvable_1.default(report);
|
|
99
86
|
// iterate translation keys, ensuring same order and priority
|
|
100
87
|
for (var key in keyTranslations) {
|
|
101
88
|
var keysRaw = keyTranslations[key];
|
|
102
89
|
reportNew[key] = null;
|
|
103
90
|
for (var _i = 0, keysRaw_1 = keysRaw; _i < keysRaw_1.length; _i++) {
|
|
104
91
|
var keyRaw = keysRaw_1[_i];
|
|
105
|
-
|
|
92
|
+
var value = reportRaw.get(keyRaw);
|
|
93
|
+
if (value === undefined)
|
|
106
94
|
continue;
|
|
107
|
-
reportNew[key] =
|
|
95
|
+
reportNew[key] = value;
|
|
108
96
|
break;
|
|
109
97
|
}
|
|
110
98
|
}
|
|
111
99
|
var reportFiltered = callback
|
|
112
|
-
? callback(reportNew, reportRaw, keyTranslations)
|
|
100
|
+
? callback(reportNew, reportRaw.report, keyTranslations)
|
|
113
101
|
: reportNew;
|
|
114
102
|
reports.push(reportFiltered);
|
|
115
103
|
});
|
|
@@ -1,34 +1,5 @@
|
|
|
1
|
-
import { CompanyFactListData } from '../../types
|
|
2
|
-
import { ReportRaw, ReportType } from '../../types/report-raw.type';
|
|
3
|
-
import FactIterator, { IterateFactsCallbackData } from './FactIterator';
|
|
4
|
-
interface ReportRawParserArgs {
|
|
5
|
-
factIterator?: FactIterator;
|
|
6
|
-
}
|
|
7
|
-
export interface ParseReportsOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Instantaneous data may be filed later than the original filing date.
|
|
10
|
-
* It is flagged by "I" at the end of the frame property. defaults to true. see https://www.sec.gov/edgar/sec-api-documentation
|
|
11
|
-
* */
|
|
12
|
-
mergeInstantaneousData?: boolean;
|
|
13
|
-
reportsToInclude?: ReportType | ReportType[] | null;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @see https://www.sec.gov/edgar/sec-api-documentation
|
|
17
|
-
*/
|
|
1
|
+
import { CompanyFactListData } from '../../types';
|
|
18
2
|
export default class ReportRawParser {
|
|
19
|
-
private readonly
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Avoids deep nesting logic while iteratating through company facts
|
|
23
|
-
*
|
|
24
|
-
* @param callback called on each company fact.
|
|
25
|
-
*/
|
|
26
|
-
iterateCompanyFacts(companyFactListData: Pick<CompanyFactListData, 'facts'>, callback: (data: IterateFactsCallbackData) => void): void;
|
|
27
|
-
/**
|
|
28
|
-
* Returns raw reports in ascending order by report date. if date is the same, priority is filed date, frame, form
|
|
29
|
-
*/
|
|
30
|
-
parseReports(companyFactListData: Pick<CompanyFactListData, 'facts'>, options?: ParseReportsOptions): ReportRaw[];
|
|
31
|
-
private getReportType;
|
|
32
|
-
private getFiscalYear;
|
|
3
|
+
private readonly reportBuilder;
|
|
4
|
+
parseReports(companyFactListData: CompanyFactListData): import("../../types").ReportRaw[];
|
|
33
5
|
}
|
|
34
|
-
export {};
|
|
@@ -1,153 +1,13 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
var
|
|
15
|
-
/**
|
|
16
|
-
* @see https://www.sec.gov/edgar/sec-api-documentation
|
|
17
|
-
*/
|
|
3
|
+
var ReportBuilder_1 = require("../ReportBuilder");
|
|
18
4
|
var ReportRawParser = /** @class */ (function () {
|
|
19
|
-
function ReportRawParser(
|
|
20
|
-
|
|
21
|
-
this.factIterator = factIterator;
|
|
5
|
+
function ReportRawParser() {
|
|
6
|
+
this.reportBuilder = new ReportBuilder_1.default();
|
|
22
7
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
* @param callback called on each company fact.
|
|
27
|
-
*/
|
|
28
|
-
ReportRawParser.prototype.iterateCompanyFacts = function (companyFactListData, callback) {
|
|
29
|
-
this.factIterator.iterateCompanyFacts(companyFactListData, callback);
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Returns raw reports in ascending order by report date. if date is the same, priority is filed date, frame, form
|
|
33
|
-
*/
|
|
34
|
-
ReportRawParser.prototype.parseReports = function (companyFactListData, options) {
|
|
35
|
-
var _this = this;
|
|
36
|
-
var _a = options !== null && options !== void 0 ? options : {}, reportsToInclude = _a.reportsToInclude, mergeInstantaneousData = _a.mergeInstantaneousData;
|
|
37
|
-
// default to all report types
|
|
38
|
-
var reportsToIncludeSet = reportsToInclude
|
|
39
|
-
? new Set(Array.isArray(reportsToInclude) ? reportsToInclude : [reportsToInclude])
|
|
40
|
-
: null;
|
|
41
|
-
// for getting the earliest filed date for each report
|
|
42
|
-
var datesFiledByDateForm = new Map();
|
|
43
|
-
// for mapping individual properties to the report
|
|
44
|
-
var reportsByKey = new Map();
|
|
45
|
-
// fiscal period only provided for filed date, used to map to later assign for quarter end date
|
|
46
|
-
var monthsFiledByFiscalPeriod = new Map();
|
|
47
|
-
// iterate individual properties AKA "facts"
|
|
48
|
-
this.iterateCompanyFacts(companyFactListData, function (_a) {
|
|
49
|
-
var _b, _c, _d, _e, _f, _g, _h;
|
|
50
|
-
var factValue = _a.factValue, propertyName = _a.propertyName, taxonomy = _a.taxonomy;
|
|
51
|
-
var filed = factValue.filed, val = factValue.val, form = factValue.form, fp = factValue.fp, dateReport = factValue.end;
|
|
52
|
-
// get frame for keys and to merge instantaneous data
|
|
53
|
-
var isInstantaneousData = (_c = (_b = factValue.frame) === null || _b === void 0 ? void 0 : _b.endsWith('I')) !== null && _c !== void 0 ? _c : false;
|
|
54
|
-
var isMergableFrame = (mergeInstantaneousData !== null && mergeInstantaneousData !== void 0 ? mergeInstantaneousData : true) && isInstantaneousData;
|
|
55
|
-
var frame = isMergableFrame ? (_d = factValue.frame) === null || _d === void 0 ? void 0 : _d.substring(0, factValue.frame.length - 1) : factValue.frame;
|
|
56
|
-
// keys to map report and file dates
|
|
57
|
-
var keyDateForm = "".concat(dateReport, "_").concat(form);
|
|
58
|
-
var keyReport = "".concat(frame, "_").concat(keyDateForm);
|
|
59
|
-
// set earliest date filed
|
|
60
|
-
var dateFiledPrev = (_e = datesFiledByDateForm.get(keyDateForm)) !== null && _e !== void 0 ? _e : filed;
|
|
61
|
-
var dateFiled = filed < dateFiledPrev ? filed : dateFiledPrev;
|
|
62
|
-
datesFiledByDateForm.set(keyDateForm, dateFiled);
|
|
63
|
-
// if frame is undefined, the value is no longer the most recent
|
|
64
|
-
if (!frame)
|
|
65
|
-
return;
|
|
66
|
-
var isTTM = frame.substring(6, 8).length !== 2;
|
|
67
|
-
var reportType = _this.getReportType({ form: form, taxonomy: taxonomy, isTTM: isTTM });
|
|
68
|
-
var isReportToInclude = (_f = reportsToIncludeSet === null || reportsToIncludeSet === void 0 ? void 0 : reportsToIncludeSet.has(reportType)) !== null && _f !== void 0 ? _f : true;
|
|
69
|
-
if (!isReportToInclude)
|
|
70
|
-
return;
|
|
71
|
-
// set the month filed, will be used to get the fiscal period and year
|
|
72
|
-
if (reportType === 'QUARTERLY' || reportType === 'ANNUAL') {
|
|
73
|
-
var monthFiled = Number(filed.substring(5, 7));
|
|
74
|
-
monthsFiledByFiscalPeriod.set(fp, ((_g = monthsFiledByFiscalPeriod.get(fp)) !== null && _g !== void 0 ? _g : new Set()).add(monthFiled));
|
|
75
|
-
}
|
|
76
|
-
var report = (_h = reportsByKey.get(keyReport)) !== null && _h !== void 0 ? _h : {
|
|
77
|
-
dateReport: dateReport,
|
|
78
|
-
dateFiled: dateFiled,
|
|
79
|
-
form: form,
|
|
80
|
-
isTTM: isTTM,
|
|
81
|
-
frame: frame,
|
|
82
|
-
taxonomy: taxonomy,
|
|
83
|
-
reportType: reportType,
|
|
84
|
-
// these will be updated
|
|
85
|
-
fiscalPeriod: 'FY',
|
|
86
|
-
fiscalYear: 0,
|
|
87
|
-
};
|
|
88
|
-
reportsByKey.set(keyReport, report);
|
|
89
|
-
// update earliest date filed
|
|
90
|
-
report.dateFiled = dateFiled;
|
|
91
|
-
report[propertyName] = val;
|
|
92
|
-
});
|
|
93
|
-
// end date is typically the month before the filed date, so subtract 1, set to 12 if 0
|
|
94
|
-
var fiscalPeriodsByMonth = new Map();
|
|
95
|
-
monthsFiledByFiscalPeriod.forEach(function (monthsSet, fiscalPeriod) {
|
|
96
|
-
monthsSet.forEach(function (month) { return fiscalPeriodsByMonth.set(month - 1 || 12, fiscalPeriod); });
|
|
97
|
-
});
|
|
98
|
-
// set fiscal period and year, then merge by year_quarter, because some reports have end dates a couple days apart
|
|
99
|
-
var reportsByYearPeriod = new Map();
|
|
100
|
-
reportsByKey.forEach(function (report) {
|
|
101
|
-
var _a;
|
|
102
|
-
var dateReport = report.dateReport, reportType = report.reportType;
|
|
103
|
-
var monthReport = Number(dateReport.substring(5, 7));
|
|
104
|
-
var fiscalPeriod = (_a = fiscalPeriodsByMonth.get(monthReport)) !== null && _a !== void 0 ? _a : 'FY';
|
|
105
|
-
// Q4 is always FY, so needs to be changed to Q4 (comes from fp property in fact)
|
|
106
|
-
report.fiscalPeriod = reportType === 'QUARTERLY' && fiscalPeriod === 'FY' ? 'Q4' : fiscalPeriod;
|
|
107
|
-
report.fiscalYear = _this.getFiscalYear({ dateReport: dateReport, reportType: reportType, fiscalPeriod: report.fiscalPeriod });
|
|
108
|
-
var keyReport = "".concat(report.fiscalYear, "_").concat(report.fiscalPeriod);
|
|
109
|
-
var reportPrev = reportsByYearPeriod.get(keyReport);
|
|
110
|
-
// if a report was already assigned to this key, merge and use the latest dateReport
|
|
111
|
-
if (reportPrev) {
|
|
112
|
-
var dateReport_1 = report.dateReport > reportPrev.dateReport ? report.dateReport : reportPrev.dateReport;
|
|
113
|
-
reportPrev.dateReport = dateReport_1;
|
|
114
|
-
reportsByYearPeriod.set(keyReport, __assign(__assign({}, reportPrev), report));
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
reportsByYearPeriod.set(keyReport, report);
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
// return in ascending order by date report, date filed, frame, form
|
|
121
|
-
return Array.from(reportsByYearPeriod.values()).sort(function (a, b) {
|
|
122
|
-
var keyA = "".concat(a.fiscalYear, "_").concat(a.isTTM ? 'Q5' : a.fiscalPeriod, "_").concat(a.dateReport, "_").concat(a.dateFiled);
|
|
123
|
-
var keyB = "".concat(b.fiscalYear, "_").concat(b.isTTM ? 'Q5' : b.fiscalPeriod, "_").concat(b.dateReport, "_").concat(b.dateFiled);
|
|
124
|
-
return keyA > keyB ? 1 : -1;
|
|
125
|
-
});
|
|
126
|
-
};
|
|
127
|
-
ReportRawParser.prototype.getReportType = function (data) {
|
|
128
|
-
var form = data.form, taxonomy = data.taxonomy, isTTM = data.isTTM;
|
|
129
|
-
if (form === '8-K')
|
|
130
|
-
return '8K';
|
|
131
|
-
else if (taxonomy === 'dei')
|
|
132
|
-
return 'DOCUMENT_ENTITY_INFO';
|
|
133
|
-
else if (isTTM)
|
|
134
|
-
return 'ANNUAL';
|
|
135
|
-
return 'QUARTERLY';
|
|
136
|
-
};
|
|
137
|
-
ReportRawParser.prototype.getFiscalYear = function (data) {
|
|
138
|
-
var dateReport = data.dateReport, reportType = data.reportType, fiscalPeriod = data.fiscalPeriod;
|
|
139
|
-
var date = new Date("".concat(dateReport, "T00:00:00"));
|
|
140
|
-
var day = date.getDate();
|
|
141
|
-
var month = day < 14 ? date.getMonth() || 12 : date.getMonth() + 1;
|
|
142
|
-
var year = date.getFullYear();
|
|
143
|
-
var monthAddMap = {
|
|
144
|
-
Q1: 9,
|
|
145
|
-
Q2: 6,
|
|
146
|
-
Q3: 3,
|
|
147
|
-
Q4: 0,
|
|
148
|
-
FY: 0,
|
|
149
|
-
};
|
|
150
|
-
return month + monthAddMap[fiscalPeriod] > 12 && reportType === 'QUARTERLY' ? year + 1 : year;
|
|
8
|
+
ReportRawParser.prototype.parseReports = function (companyFactListData) {
|
|
9
|
+
var facts = this.reportBuilder.createFacts(companyFactListData).facts;
|
|
10
|
+
return this.reportBuilder.buildReports({ facts: facts });
|
|
151
11
|
};
|
|
152
12
|
return ReportRawParser;
|
|
153
13
|
}());
|
|
@@ -28,15 +28,14 @@ var ReportWrapper = /** @class */ (function (_super) {
|
|
|
28
28
|
_this.report = report;
|
|
29
29
|
_this.reportMap = reportMap !== null && reportMap !== void 0 ? reportMap : new Map();
|
|
30
30
|
_this.reportRaw = reportRaw !== null && reportRaw !== void 0 ? reportRaw : {
|
|
31
|
+
cik: report.cik,
|
|
32
|
+
url: report.url,
|
|
31
33
|
dateFiled: report.dateFiled,
|
|
32
34
|
dateReport: report.dateReport,
|
|
33
|
-
form: report.form,
|
|
34
|
-
isTTM: report.isTTM,
|
|
35
|
-
frame: '',
|
|
36
|
-
taxonomy: '',
|
|
37
|
-
reportType: report.isTTM ? 'ANNUAL' : 'QUARTERLY',
|
|
38
35
|
fiscalPeriod: (_a = report.fiscalPeriod) !== null && _a !== void 0 ? _a : '',
|
|
39
36
|
fiscalYear: report.fiscalYear,
|
|
37
|
+
splitRatio: null,
|
|
38
|
+
splitDate: null,
|
|
40
39
|
};
|
|
41
40
|
return _this;
|
|
42
41
|
}
|
|
@@ -12,6 +12,7 @@ import { resolveFiscalYearCumulativeProperties } from './resolve-fiscal-year-cum
|
|
|
12
12
|
import { resolveLiabilityCurrent } from './resolve-liability-current';
|
|
13
13
|
import { resolveQ4FiscalYearMatchingProperties } from './resolve-q4-fiscal-year-matching-properties';
|
|
14
14
|
import { resolveRevenueTotal } from './resolve-revenue-total';
|
|
15
|
+
import { resolveSplitRatio } from './resolve-split-ratio';
|
|
15
16
|
declare const resolvers: {
|
|
16
17
|
resolveAssetNonCurrentPPEGross: typeof resolveAssetNonCurrentPPEGross;
|
|
17
18
|
resolveExpenseDepreciation: typeof resolveExpenseDepreciation;
|
|
@@ -27,5 +28,6 @@ declare const resolvers: {
|
|
|
27
28
|
resolveLiabilityCurrent: typeof resolveLiabilityCurrent;
|
|
28
29
|
resolveQ4FiscalYearMatchingProperties: typeof resolveQ4FiscalYearMatchingProperties;
|
|
29
30
|
resolveCashFlowWorkingCapitalNonCash: typeof resolveCashFlowWorkingCapitalNonCash;
|
|
31
|
+
resolveSplitRatio: typeof resolveSplitRatio;
|
|
30
32
|
};
|
|
31
33
|
export default resolvers;
|
|
@@ -14,6 +14,7 @@ var resolve_fiscal_year_cumulative_properties_1 = require("./resolve-fiscal-year
|
|
|
14
14
|
var resolve_liability_current_1 = require("./resolve-liability-current");
|
|
15
15
|
var resolve_q4_fiscal_year_matching_properties_1 = require("./resolve-q4-fiscal-year-matching-properties");
|
|
16
16
|
var resolve_revenue_total_1 = require("./resolve-revenue-total");
|
|
17
|
+
var resolve_split_ratio_1 = require("./resolve-split-ratio");
|
|
17
18
|
var resolvers = {
|
|
18
19
|
resolveAssetNonCurrentPPEGross: resolve_asset_non_current_ppe_gross_1.resolveAssetNonCurrentPPEGross,
|
|
19
20
|
resolveExpenseDepreciation: resolve_expense_depreciation_1.resolveExpenseDepreciation,
|
|
@@ -29,5 +30,6 @@ var resolvers = {
|
|
|
29
30
|
resolveLiabilityCurrent: resolve_liability_current_1.resolveLiabilityCurrent,
|
|
30
31
|
resolveQ4FiscalYearMatchingProperties: resolve_q4_fiscal_year_matching_properties_1.resolveQ4FiscalYearMatchingProperties,
|
|
31
32
|
resolveCashFlowWorkingCapitalNonCash: resolve_cash_flow_working_capital_non_cash_1.resolveCashFlowWorkingCapitalNonCash,
|
|
33
|
+
resolveSplitRatio: resolve_split_ratio_1.resolveSplitRatio,
|
|
32
34
|
};
|
|
33
35
|
exports.default = resolvers;
|
|
@@ -7,9 +7,10 @@ var helpers_1 = require("./helpers");
|
|
|
7
7
|
*/
|
|
8
8
|
function resolveCashFlowCapex(report) {
|
|
9
9
|
var _a, _b, _c;
|
|
10
|
-
if (report.
|
|
10
|
+
if (report.cashFlowCapex !== null)
|
|
11
11
|
return;
|
|
12
|
-
var
|
|
12
|
+
var isFY = report.fiscalPeriod === 'FY';
|
|
13
|
+
var reportPrev = report.getReportOffset(-1, isFY ? 'ANNUAL' : 'QUARTERLY');
|
|
13
14
|
var _d = report.getReportsFiscalYearByPeriod(), FY = _d.FY, Q1 = _d.Q1, Q2 = _d.Q2, Q3 = _d.Q3, Q4 = _d.Q4;
|
|
14
15
|
if (FY === null) {
|
|
15
16
|
report.cashFlowCapex = (_a = reportPrev === null || reportPrev === void 0 ? void 0 : reportPrev.cashFlowCapex) !== null && _a !== void 0 ? _a : null;
|
|
@@ -17,7 +18,7 @@ function resolveCashFlowCapex(report) {
|
|
|
17
18
|
}
|
|
18
19
|
var sumQuarters = [Q1, Q2, Q3, Q4].reduce(function (sum, rep) { var _a; return sum + ((_a = rep === null || rep === void 0 ? void 0 : rep.cashFlowCapex) !== null && _a !== void 0 ? _a : 0); }, 0);
|
|
19
20
|
var reportsQuarterlyWithoutCapex = [Q1, Q2, Q3, Q4].filter(function (rep) { return rep && rep.cashFlowCapex === null; });
|
|
20
|
-
if (
|
|
21
|
+
if (isFY) {
|
|
21
22
|
if (reportsQuarterlyWithoutCapex.length === 0)
|
|
22
23
|
report.cashFlowCapex = sumQuarters;
|
|
23
24
|
return;
|
|
@@ -27,7 +27,7 @@ function resolveCashFlowOperating(report) {
|
|
|
27
27
|
}
|
|
28
28
|
exports.resolveCashFlowOperating = resolveCashFlowOperating;
|
|
29
29
|
function getCashFlowOperating(report) {
|
|
30
|
-
var reportPrev = report.getReportOffset(-1, report.
|
|
30
|
+
var reportPrev = report.getReportOffset(-1, report.fiscalPeriod === 'FY' ? 'ANNUAL' : 'QUARTERLY');
|
|
31
31
|
if (!reportPrev)
|
|
32
32
|
return null;
|
|
33
33
|
var _a = report, incomeNet = _a.incomeNet, expenseDepreciation = _a.expenseDepreciation, cashFlowWorkingCapitalNonCash = _a.cashFlowWorkingCapitalNonCash;
|
|
@@ -6,7 +6,7 @@ function resolveCashFlowWorkingCapitalNonCash(report) {
|
|
|
6
6
|
if (report.cashFlowWorkingCapitalNonCash !== null)
|
|
7
7
|
return;
|
|
8
8
|
// the previous report is used to calculate the change in working capital in resolveCashFlowOperating
|
|
9
|
-
var reportWrapperPrev = report.getReportOffset(-1, report.
|
|
9
|
+
var reportWrapperPrev = report.getReportOffset(-1, report.fiscalPeriod === 'FY' ? 'ANNUAL' : 'QUARTERLY');
|
|
10
10
|
var _a = report.getReportsFiscalYearByPeriod(), FY = _a.FY, Q1 = _a.Q1, Q2 = _a.Q2, Q3 = _a.Q3, Q4 = _a.Q4;
|
|
11
11
|
for (var _i = 0, _b = [FY, Q1, Q2, Q3, Q4, reportWrapperPrev]; _i < _b.length; _i++) {
|
|
12
12
|
var report_1 = _b[_i];
|
|
@@ -81,7 +81,7 @@ function getDepreciationPercentOfPPE(report) {
|
|
|
81
81
|
}
|
|
82
82
|
// if checking depreciation using an annual report, we need to get the sum of the quarters
|
|
83
83
|
var ppeDenominator = assetNonCurrentPPEGrossTTMOrPrev;
|
|
84
|
-
if (reportTTMOrPrev.
|
|
84
|
+
if (reportTTMOrPrev.fiscalPeriod === 'FY' && report.fiscalPeriod !== 'FY') {
|
|
85
85
|
var _e = reportTTMOrPrev.getReportsFiscalYearByPeriod(), Q1 = _e.Q1, Q2 = _e.Q2, Q3 = _e.Q3, Q4 = _e.Q4;
|
|
86
86
|
ppeDenominator = 0;
|
|
87
87
|
for (var _i = 0, _f = [Q1, Q2, Q3, Q4]; _i < _f.length; _i++) {
|
|
@@ -12,24 +12,38 @@ function resolveFiscalYearCumulativeProperties(report) {
|
|
|
12
12
|
matchProperty('assetNonCurrentPPEGross', Q4, FY);
|
|
13
13
|
matchProperty('assetNonCurrentPPENet', Q4, FY);
|
|
14
14
|
matchProperty('expenseDepreciationAccumulated', Q4, FY);
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'
|
|
20
|
-
'
|
|
21
|
-
'
|
|
22
|
-
'
|
|
23
|
-
'
|
|
24
|
-
'
|
|
25
|
-
'
|
|
26
|
-
'
|
|
27
|
-
'
|
|
15
|
+
var keysToInclude = new Set([
|
|
16
|
+
'cashFlowCapex',
|
|
17
|
+
'cashFlowDeferredTax',
|
|
18
|
+
'cashFlowDividendsPaid',
|
|
19
|
+
'cashFlowDividendsPaidPreferred',
|
|
20
|
+
'cashFlowFree',
|
|
21
|
+
'cashFlowOperating',
|
|
22
|
+
'cashFlowWorkingCapitalNonCash',
|
|
23
|
+
'assetNonCurrentIntangibleLessGoodwill',
|
|
24
|
+
'expenseDepreciation',
|
|
25
|
+
'expenseInterest',
|
|
26
|
+
'expenseNonCashOther',
|
|
27
|
+
'expenseOperating',
|
|
28
|
+
'expenseResearchDevelopment',
|
|
29
|
+
'expenseStockCompensation',
|
|
30
|
+
'expenseTax',
|
|
31
|
+
'expenseTotal',
|
|
32
|
+
'ebit',
|
|
33
|
+
'ebitda',
|
|
34
|
+
'eps',
|
|
35
|
+
'epsDiluted',
|
|
36
|
+
'incomeNet',
|
|
37
|
+
'incomeOperating',
|
|
38
|
+
'profitGross',
|
|
39
|
+
'revenueCost',
|
|
40
|
+
'revenueOperating',
|
|
41
|
+
'revenueTotal',
|
|
28
42
|
]);
|
|
29
43
|
var reportKeys = Object.keys(Q1);
|
|
30
44
|
var keysToResolve = reportKeys.filter(function (key) {
|
|
31
45
|
var reportsWithVal = [FY, Q1, Q2, Q3, Q4].filter(function (report) {
|
|
32
|
-
return typeof report[key] === 'number' &&
|
|
46
|
+
return typeof report[key] === 'number' && keysToInclude.has(key);
|
|
33
47
|
});
|
|
34
48
|
// we want to get the keys that are in 4 of the 5 reports
|
|
35
49
|
return reportsWithVal.length === 4;
|
|
@@ -48,7 +62,8 @@ function resolveFiscalYearCumulativeProperties(report) {
|
|
|
48
62
|
var rep = _c[_b];
|
|
49
63
|
if (rep && typeof rep[key] !== 'number') {
|
|
50
64
|
;
|
|
51
|
-
rep[key] =
|
|
65
|
+
rep[key] =
|
|
66
|
+
Math.round((valueFY - sumQuarters) * 10000) / 10000;
|
|
52
67
|
break;
|
|
53
68
|
}
|
|
54
69
|
}
|
|
@@ -8,10 +8,38 @@ function resolveQ4FiscalYearMatchingProperties(reportWrapper) {
|
|
|
8
8
|
var _a = reportWrapper.getReportsFiscalYearByPeriod(), FY = _a.FY, Q1 = _a.Q1, Q2 = _a.Q2, Q3 = _a.Q3, Q4 = _a.Q4;
|
|
9
9
|
if (!FY || !Q1 || !Q2 || !Q3 || !Q4)
|
|
10
10
|
return;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
var matchingProperties = [
|
|
12
|
+
'assetCurrent',
|
|
13
|
+
'assetCurrentAccountsReceivable',
|
|
14
|
+
'assetCurrentCashEquivalents',
|
|
15
|
+
'assetCurrentInventory',
|
|
16
|
+
'assetCurrentInvestments',
|
|
17
|
+
'assetNonCurrent',
|
|
18
|
+
'assetNonCurrentGoodwill',
|
|
19
|
+
'assetNonCurrentIntangibleLessGoodwill',
|
|
20
|
+
'assetNonCurrentInvestments',
|
|
21
|
+
'assetNonCurrentPPEGross',
|
|
22
|
+
'assetNonCurrentPPENet',
|
|
23
|
+
'assetTotal',
|
|
24
|
+
'liabilityCurrent',
|
|
25
|
+
'liabilityCurrentAccountsPayable',
|
|
26
|
+
'liabilityCurrentDebt',
|
|
27
|
+
'liabilityNonCurrent',
|
|
28
|
+
'liabilityNonCurrentDebt',
|
|
29
|
+
'liabilityTotal',
|
|
30
|
+
'equityRetainedEarnings',
|
|
31
|
+
'equityStockPreferred',
|
|
32
|
+
'equityTotal',
|
|
33
|
+
'dateFiled',
|
|
34
|
+
'dateReport',
|
|
35
|
+
'sharesOutstanding',
|
|
36
|
+
'sharesOutstandingDiluted',
|
|
37
|
+
'splitRatio',
|
|
38
|
+
];
|
|
39
|
+
for (var _i = 0, matchingProperties_1 = matchingProperties; _i < matchingProperties_1.length; _i++) {
|
|
40
|
+
var property = matchingProperties_1[_i];
|
|
41
|
+
matchProperty(property, Q4, FY);
|
|
42
|
+
}
|
|
15
43
|
}
|
|
16
44
|
exports.resolveQ4FiscalYearMatchingProperties = resolveQ4FiscalYearMatchingProperties;
|
|
17
45
|
function matchProperty(propertyName, reportA, reportB) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resolveSplitRatio = void 0;
|
|
4
|
+
function resolveSplitRatio(report) {
|
|
5
|
+
var _a = report.getReportsFiscalYearByPeriod(), Q1 = _a.Q1, Q2 = _a.Q2, Q3 = _a.Q3, Q4 = _a.Q4;
|
|
6
|
+
var splitReport = null;
|
|
7
|
+
// FY will have already been matched with Q4 from resolve-q4-fiscal-year-matching-properties.ts
|
|
8
|
+
var takenRatios = new Set();
|
|
9
|
+
for (var _i = 0, _b = [Q4, Q3, Q2, Q1]; _i < _b.length; _i++) {
|
|
10
|
+
var report_1 = _b[_i];
|
|
11
|
+
if (!(report_1 === null || report_1 === void 0 ? void 0 : report_1.splitRatio))
|
|
12
|
+
continue;
|
|
13
|
+
if (takenRatios.has(report_1.splitRatio)) {
|
|
14
|
+
report_1.splitRatio = null;
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
splitReport = report_1;
|
|
18
|
+
takenRatios.add(report_1.splitRatio);
|
|
19
|
+
}
|
|
20
|
+
if (!splitReport)
|
|
21
|
+
return;
|
|
22
|
+
var prevReports = [
|
|
23
|
+
splitReport.getReportOffset(-1, 'QUARTERLY'),
|
|
24
|
+
splitReport.getReportOffset(-2, 'QUARTERLY'),
|
|
25
|
+
splitReport.getReportOffset(-3, 'QUARTERLY'),
|
|
26
|
+
splitReport.getReportOffset(-4, 'QUARTERLY'),
|
|
27
|
+
splitReport.getReportOffset(-1, 'ANNUAL'),
|
|
28
|
+
];
|
|
29
|
+
prevReports.forEach(function (prevReport) {
|
|
30
|
+
if (prevReport === splitReport)
|
|
31
|
+
return;
|
|
32
|
+
if (prevReport && splitReport && prevReport.splitRatio === splitReport.splitRatio) {
|
|
33
|
+
prevReport.splitRatio = null;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
exports.resolveSplitRatio = resolveSplitRatio;
|
|
@@ -3,7 +3,6 @@ import { FilingListDetails, FilingListItemTranslated, SubmissionList } from '../
|
|
|
3
3
|
import { IClient } from '../Client';
|
|
4
4
|
import DocumentParser from '../DocumentParser';
|
|
5
5
|
import ReportParser from '../ReportParser';
|
|
6
|
-
import { ParseReportsOptions } from '../ReportParser/ReportRawParser';
|
|
7
6
|
import ReportWrapper from '../ReportParser/ReportWrapper';
|
|
8
7
|
import SubmissionRequestWrapper from './RequestWrapper';
|
|
9
8
|
import { IThrottler } from './Throttler';
|
|
@@ -139,7 +138,7 @@ export default class SecEdgarApi {
|
|
|
139
138
|
* Parses reports from company facts. Calculates missing properties and uses a single interface
|
|
140
139
|
* for all reports.
|
|
141
140
|
*/
|
|
142
|
-
getReportsRaw(params: GetSymbolParams
|
|
141
|
+
getReportsRaw(params: GetSymbolParams): Promise<ReportRaw[]>;
|
|
143
142
|
/**
|
|
144
143
|
* Gets a list of all tickers and CIKs from `https://www.sec.gov/files/company_tickers.json`
|
|
145
144
|
*
|
|
@@ -2,16 +2,15 @@
|
|
|
2
2
|
* Contains all keys matched from the report, along with the added keys dateEnd, dateFiled, fiscalPeriod, fiscalYear.
|
|
3
3
|
*/
|
|
4
4
|
export type ReportRaw = {
|
|
5
|
-
[key: string]: string | number | boolean;
|
|
5
|
+
[key: string]: string | number | boolean | null;
|
|
6
|
+
cik: number;
|
|
7
|
+
url: string | null;
|
|
6
8
|
dateReport: string;
|
|
7
9
|
dateFiled: string;
|
|
8
|
-
form: string;
|
|
9
|
-
isTTM: boolean;
|
|
10
|
-
frame: string;
|
|
11
|
-
taxonomy: string;
|
|
12
|
-
reportType: ReportType;
|
|
13
10
|
fiscalPeriod: FiscalPeriod;
|
|
14
11
|
fiscalYear: number;
|
|
12
|
+
splitRatio: number | null;
|
|
13
|
+
splitDate: string | null;
|
|
15
14
|
};
|
|
16
15
|
/**
|
|
17
16
|
* QUARTERLY = 10-Q and 10-K forms for the quarter | ANNUAL = 10-K forms for the year |
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { FiscalPeriod } from './report-raw.type';
|
|
2
2
|
export interface ReportTranslated {
|
|
3
|
+
cik: number;
|
|
4
|
+
url: string | null;
|
|
3
5
|
dateReport: string;
|
|
4
6
|
dateFiled: string;
|
|
5
7
|
fiscalPeriod: FiscalPeriod;
|
|
6
8
|
fiscalYear: number;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
splitDate: string | null;
|
|
10
|
+
splitRatio: number | null;
|
|
9
11
|
assetTotal: number | null;
|
|
10
12
|
assetCurrent: number | null;
|
|
11
13
|
assetCurrentCashEquivalents: number | null;
|