sec-edgar-api 0.5.5 → 0.5.6
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.
|
@@ -15,12 +15,13 @@ export default class FactFiscalCalculator {
|
|
|
15
15
|
private readonly endDateByYear;
|
|
16
16
|
private readonly fiscalsByEndDate;
|
|
17
17
|
private readonly datesByFiscals;
|
|
18
|
+
private readonly startDateCountMap;
|
|
18
19
|
private readonly endDateCountMap;
|
|
19
20
|
private readonly filedDateCountByEndDate;
|
|
20
21
|
private didResolve;
|
|
21
22
|
private readonly fiscalYearEnd;
|
|
22
23
|
constructor(params?: {
|
|
23
|
-
facts?: Pick<FactItem, 'end' | 'filed'>[];
|
|
24
|
+
facts?: Pick<FactItem, 'end' | 'filed' | 'start'>[];
|
|
24
25
|
filings?: Pick<FilingListItemTranslated, 'form' | 'reportDate' | 'filingDate' | 'accessionNumber'>[];
|
|
25
26
|
fiscalYearEnd?: {
|
|
26
27
|
month: number;
|
|
@@ -31,6 +32,7 @@ export default class FactFiscalCalculator {
|
|
|
31
32
|
add(fact: {
|
|
32
33
|
end: string;
|
|
33
34
|
filed: string;
|
|
35
|
+
start?: string;
|
|
34
36
|
}): void;
|
|
35
37
|
private getDaysBefore;
|
|
36
38
|
setReportDates(params: SetReportDatesParams): void;
|
|
@@ -44,6 +46,10 @@ export default class FactFiscalCalculator {
|
|
|
44
46
|
filed: string;
|
|
45
47
|
end: string;
|
|
46
48
|
} | null;
|
|
49
|
+
/**
|
|
50
|
+
* Assumes year end from start dates if not provided
|
|
51
|
+
*/
|
|
52
|
+
private ensureEndDateByYear;
|
|
47
53
|
getFiscalYearQuarter(params: {
|
|
48
54
|
dateStr: string;
|
|
49
55
|
endDateByYear?: Map<number, Date>;
|
|
@@ -12,6 +12,7 @@ var FactFiscalCalculator = /** @class */ (function () {
|
|
|
12
12
|
this.fiscalsByEndDate = new Map();
|
|
13
13
|
this.datesByFiscals = new Map();
|
|
14
14
|
/// these get cleared after resolve
|
|
15
|
+
this.startDateCountMap = new Map();
|
|
15
16
|
this.endDateCountMap = new Map();
|
|
16
17
|
this.filedDateCountByEndDate = new Map();
|
|
17
18
|
this.didResolve = false;
|
|
@@ -49,8 +50,8 @@ var FactFiscalCalculator = /** @class */ (function () {
|
|
|
49
50
|
});
|
|
50
51
|
};
|
|
51
52
|
FactFiscalCalculator.prototype.add = function (fact) {
|
|
52
|
-
var _a, _b, _c;
|
|
53
|
-
var end = fact.end, filed = fact.filed;
|
|
53
|
+
var _a, _b, _c, _d;
|
|
54
|
+
var end = fact.end, filed = fact.filed, start = fact.start;
|
|
54
55
|
if (this.didResolve) {
|
|
55
56
|
throw new Error('Cannot add fact after resolving');
|
|
56
57
|
}
|
|
@@ -58,10 +59,13 @@ var FactFiscalCalculator = /** @class */ (function () {
|
|
|
58
59
|
this.addAnnualReportDate(fact.end);
|
|
59
60
|
}
|
|
60
61
|
this.endDateCountMap.set(end, ((_a = this.endDateCountMap.get(end)) !== null && _a !== void 0 ? _a : 0) + 1);
|
|
62
|
+
if (start) {
|
|
63
|
+
this.startDateCountMap.set(start, ((_b = this.startDateCountMap.get(start)) !== null && _b !== void 0 ? _b : 0) + 1);
|
|
64
|
+
}
|
|
61
65
|
// don't record filed dates for restated facts
|
|
62
66
|
if (this.getDaysBefore(filed, end) < 60) {
|
|
63
|
-
var bucket = (
|
|
64
|
-
bucket.set(filed, ((
|
|
67
|
+
var bucket = (_c = this.filedDateCountByEndDate.get(end)) !== null && _c !== void 0 ? _c : this.filedDateCountByEndDate.set(end, new Map()).get(end);
|
|
68
|
+
bucket.set(filed, ((_d = bucket.get(filed)) !== null && _d !== void 0 ? _d : 0) + 1);
|
|
65
69
|
}
|
|
66
70
|
};
|
|
67
71
|
FactFiscalCalculator.prototype.getDaysBefore = function (dateStrAfter, dateStrBefore) {
|
|
@@ -192,6 +196,7 @@ var FactFiscalCalculator = /** @class */ (function () {
|
|
|
192
196
|
dates.end = ensureNoWeekends("".concat(yearEnd, "-").concat(datesFound.endMonthDay));
|
|
193
197
|
}
|
|
194
198
|
});
|
|
199
|
+
this.ensureEndDateByYear();
|
|
195
200
|
this.endDateCountMap.clear();
|
|
196
201
|
this.filedDateCountByEndDate.clear();
|
|
197
202
|
this.didResolve = true;
|
|
@@ -203,8 +208,26 @@ var FactFiscalCalculator = /** @class */ (function () {
|
|
|
203
208
|
this.didResolve = true;
|
|
204
209
|
return (_a = this.datesByFiscals.get("".concat(params.year, "_").concat(params.quarter))) !== null && _a !== void 0 ? _a : null;
|
|
205
210
|
};
|
|
211
|
+
/**
|
|
212
|
+
* Assumes year end from start dates if not provided
|
|
213
|
+
*/
|
|
214
|
+
FactFiscalCalculator.prototype.ensureEndDateByYear = function () {
|
|
215
|
+
if (this.endDateByYear.size > 0 || this.fiscalYearEnd || this.startDateCountMap.size === 0)
|
|
216
|
+
return;
|
|
217
|
+
var maxStartDateCount = 0;
|
|
218
|
+
var maxStartDate = '';
|
|
219
|
+
this.startDateCountMap.forEach(function (count, date) {
|
|
220
|
+
if (count > maxStartDateCount) {
|
|
221
|
+
maxStartDateCount = count;
|
|
222
|
+
maxStartDate = date;
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
this.endDateByYear.set(Number(maxStartDate.split('-', 1)[0]) - 1, new Date(maxStartDate));
|
|
226
|
+
this.startDateCountMap.clear();
|
|
227
|
+
};
|
|
206
228
|
FactFiscalCalculator.prototype.getFiscalYearQuarter = function (params) {
|
|
207
229
|
var dateStr = params.dateStr, _a = params.endDateByYear, endDateByYear = _a === void 0 ? this.endDateByYear : _a, _b = params.fiscalYearEnd, fiscalYearEnd = _b === void 0 ? this.fiscalYearEnd : _b;
|
|
230
|
+
this.ensureEndDateByYear();
|
|
208
231
|
if (this.fiscalsByEndDate.has(dateStr)) {
|
|
209
232
|
return this.fiscalsByEndDate.get(dateStr);
|
|
210
233
|
}
|
package/package.json
CHANGED