sec-edgar-api 0.2.4 → 0.3.1

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.
Files changed (42) hide show
  1. package/README.md +1 -0
  2. package/build/services/DocumentParser/DocumentParser.d.ts +12 -0
  3. package/build/services/DocumentParser/DocumentParser.js +3 -0
  4. package/build/services/DocumentParser/parsers/index.d.ts +2 -0
  5. package/build/services/DocumentParser/parsers/index.js +2 -0
  6. package/build/services/DocumentParser/parsers/parse-current-filings-daily.d.ts +13 -0
  7. package/build/services/DocumentParser/parsers/parse-current-filings-daily.js +37 -0
  8. package/build/services/ReportParser/ReportParser.d.ts +10 -14
  9. package/build/services/ReportParser/ReportParser.js +17 -24
  10. package/build/services/ReportRawBuilder/FactGrouper.d.ts +27 -0
  11. package/build/services/ReportRawBuilder/FactGrouper.js +206 -0
  12. package/build/services/{ReportBuilder → ReportRawBuilder}/FactPeriodResolver.d.ts +46 -2
  13. package/build/services/{ReportBuilder → ReportRawBuilder}/FactPeriodResolver.js +82 -20
  14. package/build/services/ReportRawBuilder/FactRecordBuilder.d.ts +9 -0
  15. package/build/services/{ReportBuilder → ReportRawBuilder}/FactRecordBuilder.js +6 -24
  16. package/build/services/ReportRawBuilder/FactSplitAdjuster.d.ts +43 -0
  17. package/build/services/ReportRawBuilder/FactSplitAdjuster.js +242 -0
  18. package/build/services/ReportRawBuilder/ReportRawBuilder.d.ts +39 -0
  19. package/build/services/ReportRawBuilder/ReportRawBuilder.js +158 -0
  20. package/build/services/ReportRawBuilder/index.d.ts +2 -0
  21. package/build/services/ReportRawBuilder/index.js +4 -0
  22. package/build/services/SecEdgarApi/SecEdgarApi.d.ts +32 -5
  23. package/build/services/SecEdgarApi/SecEdgarApi.js +65 -13
  24. package/build/types/common.type.d.ts +41 -0
  25. package/build/types/company-facts.type.d.ts +29 -2
  26. package/build/types/parsed-filings.type.d.ts +1 -0
  27. package/package.json +1 -1
  28. package/build/services/ReportBuilder/FactRecordBuilder.d.ts +0 -10
  29. package/build/services/ReportBuilder/FactSplitAdjuster.d.ts +0 -50
  30. package/build/services/ReportBuilder/FactSplitAdjuster.js +0 -214
  31. package/build/services/ReportBuilder/ReportBuilder.d.ts +0 -40
  32. package/build/services/ReportBuilder/ReportBuilder.js +0 -200
  33. package/build/services/ReportBuilder/ReportRawResolvable.d.ts +0 -17
  34. package/build/services/ReportBuilder/ReportRawResolvable.js +0 -114
  35. package/build/services/ReportBuilder/index.d.ts +0 -2
  36. package/build/services/ReportBuilder/index.js +0 -4
  37. package/build/services/ReportParser/ReportRawParser.d.ts +0 -5
  38. package/build/services/ReportParser/ReportRawParser.js +0 -14
  39. package/build/util/calculation-map-by-ns.d.ts +0 -6
  40. package/build/util/calculation-map-by-ns.js +0 -9
  41. /package/build/services/{ReportBuilder → ReportRawBuilder}/FactFiscalCalculator.d.ts +0 -0
  42. /package/build/services/{ReportBuilder → ReportRawBuilder}/FactFiscalCalculator.js +0 -0
@@ -0,0 +1,158 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var FactFiscalCalculator_1 = require("./FactFiscalCalculator");
4
+ var FactGrouper_1 = require("./FactGrouper");
5
+ var FactRecordBuilder_1 = require("./FactRecordBuilder");
6
+ var FactSplitAdjuster_1 = require("./FactSplitAdjuster");
7
+ /**
8
+ * Builds ReportRaw objects from company facts. Adjusts for splits and resolves period values.
9
+ */
10
+ var ReportRawBuilder = /** @class */ (function () {
11
+ function ReportRawBuilder() {
12
+ this.factRecordBuilder = new FactRecordBuilder_1.default();
13
+ }
14
+ ReportRawBuilder.prototype.createFacts = function (companyFacts, includeNamePrefix) {
15
+ if (includeNamePrefix === void 0) { includeNamePrefix = false; }
16
+ return this.factRecordBuilder.createFacts(companyFacts, includeNamePrefix);
17
+ };
18
+ ReportRawBuilder.prototype.createFiscalCalculator = function (params) {
19
+ var facts = params.facts;
20
+ var fiscalCalculator = new FactFiscalCalculator_1.default();
21
+ for (var _i = 0, facts_1 = facts; _i < facts_1.length; _i++) {
22
+ var fact = facts_1[_i];
23
+ fiscalCalculator.add(fact);
24
+ }
25
+ return fiscalCalculator;
26
+ };
27
+ ReportRawBuilder.prototype.buildReports = function (params) {
28
+ var facts = params.facts, reportDates = params.reportDates, splitsProp = params.splits, _a = params.resolvePeriodValues, resolvePeriodValues = _a === void 0 ? true : _a, _b = params.adjustForSplits, adjustForSplits = _b === void 0 ? true : _b;
29
+ if (facts.length === 0) {
30
+ return [];
31
+ }
32
+ var accessionByYearQuarter = new Map();
33
+ reportDates === null || reportDates === void 0 ? void 0 : reportDates.forEach(function (params) {
34
+ var year = params.year, quarter = params.quarter, accn = params.accn;
35
+ if (accn)
36
+ accessionByYearQuarter.set("".concat(year, "_").concat(quarter), accn);
37
+ });
38
+ var reportsCik = Number(facts[0].cik);
39
+ var fiscalCalculator = this.createFiscalCalculator({ facts: facts });
40
+ var factGrouper = new FactGrouper_1.default();
41
+ var factSplitAdjuster = new FactSplitAdjuster_1.default();
42
+ // if splits not included in params and need to adjust, extract from facts
43
+ var splits = adjustForSplits
44
+ ? splitsProp !== null && splitsProp !== void 0 ? splitsProp : factSplitAdjuster.getSplits({ splitFacts: factSplitAdjuster.filterSplitFacts({ facts: facts }) })
45
+ : splitsProp;
46
+ var _c = factGrouper.buildFactGroupsByReportKey({
47
+ facts: facts,
48
+ cik: reportsCik,
49
+ fiscalCalculator: fiscalCalculator,
50
+ resolvePeriodValues: resolvePeriodValues,
51
+ generateMissingGroups: false,
52
+ splits: splits,
53
+ }), factGroupsByReportKey = _c.factGroupsByReportKey, maxYear = _c.maxYear, minYear = _c.minYear;
54
+ return this.buildReportsFromGroups({
55
+ factGroupsByReportKey: factGroupsByReportKey,
56
+ fiscalCalculator: fiscalCalculator,
57
+ splits: splits,
58
+ minYear: minYear,
59
+ maxYear: maxYear,
60
+ cik: reportsCik,
61
+ });
62
+ };
63
+ ReportRawBuilder.prototype.createReportKey = function (params) {
64
+ var year = params.year, quarter = params.quarter, isAnnual = params.isAnnual;
65
+ return "".concat(year, "_").concat(isAnnual ? 'FY' : "Q".concat(quarter));
66
+ };
67
+ ReportRawBuilder.prototype.createReport = function (params) {
68
+ var _a;
69
+ var group = params.group, isAnnual = params.isAnnual, splitDate = params.splitDate, splitRatio = params.splitRatio, cik = params.cik;
70
+ var fiscalPeriod = isAnnual ? 'FY' : "Q".concat(group.quarter);
71
+ var accessionNoHyphen = (_a = group.accn) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '');
72
+ var url = group.accn
73
+ ? "https://www.sec.gov/Archives/edgar/data/".concat(cik, "/").concat(accessionNoHyphen, "/").concat(group.accn, ".txt")
74
+ : null;
75
+ return {
76
+ cik: cik,
77
+ url: url,
78
+ dateFiled: group.reportFiled,
79
+ dateReport: group.reportEnd,
80
+ fiscalPeriod: fiscalPeriod,
81
+ fiscalYear: group.fiscalYear,
82
+ splitDate: splitDate !== null && splitDate !== void 0 ? splitDate : null,
83
+ splitRatio: splitRatio !== null && splitRatio !== void 0 ? splitRatio : null,
84
+ };
85
+ };
86
+ ReportRawBuilder.prototype.round = function (value) {
87
+ var multiplier = 1000000;
88
+ return typeof value === 'number' ? Math.round(value * multiplier) / multiplier : value;
89
+ };
90
+ ReportRawBuilder.prototype.buildReportsFromGroups = function (params) {
91
+ var _this = this;
92
+ var factGroupsByReportKey = params.factGroupsByReportKey, minYear = params.minYear, maxYear = params.maxYear, cik = params.cik, splits = params.splits, fiscalCalculator = params.fiscalCalculator;
93
+ var splitByFiscals = new Map();
94
+ var reportByKey = new Map();
95
+ splits === null || splits === void 0 ? void 0 : splits.forEach(function (split) {
96
+ var _a = fiscalCalculator.getFiscalYearQuarter({ dateStr: split.endLast }), quarter = _a.quarter, year = _a.year;
97
+ splitByFiscals.set("".concat(year, "_").concat(quarter), split);
98
+ });
99
+ factGroupsByReportKey.forEach(function (groups) {
100
+ var _a, _b, _c, _d, _e, _f;
101
+ var groupWithDates = groups.find(function (g) { return g.reportEnd; });
102
+ if (!groupWithDates)
103
+ return;
104
+ var split = splitByFiscals.get("".concat(groupWithDates.fiscalYear, "_").concat(groupWithDates.quarter));
105
+ var splitDate = (_a = split === null || split === void 0 ? void 0 : split.endLast) !== null && _a !== void 0 ? _a : null;
106
+ var splitRatio = (_b = split === null || split === void 0 ? void 0 : split.splitRatio) !== null && _b !== void 0 ? _b : null;
107
+ var quarter = groupWithDates.quarter;
108
+ var reportPeriod = _this.createReport({
109
+ group: groupWithDates,
110
+ cik: cik,
111
+ isAnnual: false,
112
+ splitDate: splitDate,
113
+ splitRatio: splitRatio,
114
+ });
115
+ var reportKeyPeriod = _this.createReportKey({
116
+ year: reportPeriod.fiscalYear,
117
+ quarter: quarter,
118
+ isAnnual: false,
119
+ });
120
+ for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
121
+ var group = groups_1[_i];
122
+ var value = (_d = (_c = group.valuePeriodResolved) !== null && _c !== void 0 ? _c : group.valuePeriodFirst) !== null && _d !== void 0 ? _d : 0;
123
+ reportPeriod[group.name] = _this.round(value);
124
+ }
125
+ reportByKey.set(reportKeyPeriod, reportPeriod);
126
+ if (quarter !== 4)
127
+ return;
128
+ var reportAnnual = _this.createReport({
129
+ group: groupWithDates,
130
+ cik: cik,
131
+ isAnnual: true,
132
+ splitDate: splitDate,
133
+ splitRatio: splitRatio,
134
+ });
135
+ var reportKeyAnnual = "".concat(reportAnnual.fiscalYear, "_").concat(reportAnnual.fiscalPeriod);
136
+ for (var _g = 0, groups_2 = groups; _g < groups_2.length; _g++) {
137
+ var group = groups_2[_g];
138
+ var value = (_f = (_e = group.valueTrailingResolved) !== null && _e !== void 0 ? _e : group.valueTrailingFirst) !== null && _f !== void 0 ? _f : 0;
139
+ reportAnnual[group.name] = _this.round(value);
140
+ }
141
+ reportByKey.set(reportKeyAnnual, reportAnnual);
142
+ });
143
+ var reports = [];
144
+ for (var year = minYear; year <= maxYear; year++) {
145
+ for (var quarter = 1; quarter <= 5; quarter++) {
146
+ var isAnnual = quarter === 5;
147
+ var reportKey = this.createReportKey({ year: year, quarter: isAnnual ? 4 : quarter, isAnnual: isAnnual });
148
+ var report = reportByKey.get(reportKey);
149
+ if (report) {
150
+ reports.push(report);
151
+ }
152
+ }
153
+ }
154
+ return reports;
155
+ };
156
+ return ReportRawBuilder;
157
+ }());
158
+ exports.default = ReportRawBuilder;
@@ -0,0 +1,2 @@
1
+ import ReportRawBuilder from './ReportRawBuilder';
2
+ export default ReportRawBuilder;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var ReportRawBuilder_1 = require("./ReportRawBuilder");
4
+ exports.default = ReportRawBuilder_1.default;
@@ -1,4 +1,4 @@
1
- import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
1
+ import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, DailyFilingFormType, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
2
2
  import { FilingListDetails, FilingListItemTranslated, SubmissionList } from '../../types/submission.type';
3
3
  import { IClient } from '../Client';
4
4
  import DocumentParser from '../DocumentParser';
@@ -25,11 +25,19 @@ export interface GetSymbolParams {
25
25
  /** symbol or cik */
26
26
  symbol: string | number;
27
27
  }
28
- export interface GetReportsParams {
28
+ export interface GetReportsRawParams {
29
+ symbol: string | number;
30
+ includeNamePrefix?: boolean;
31
+ adjustForSplits?: boolean;
32
+ resolvePeriodValues?: boolean;
33
+ }
34
+ export interface GetReportsParams extends Omit<GetReportsRawParams, 'includeNamePrefix'> {
29
35
  /** symbol or cik */
30
36
  symbol: string | number;
31
37
  withWrapper?: boolean;
32
38
  usePropertyResolver?: boolean;
39
+ adjustForSplits?: boolean;
40
+ resolvePeriodValues?: boolean;
33
41
  }
34
42
  export interface GetFactParams {
35
43
  /** symbol or cik */
@@ -135,10 +143,9 @@ export default class SecEdgarApi {
135
143
  */
136
144
  getReports<T extends GetReportsParams>(params: T): Promise<T['withWrapper'] extends true ? ReportWrapper[] : ReportTranslated[]>;
137
145
  /**
138
- * Parses reports from company facts. Calculates missing properties and uses a single interface
139
- * for all reports.
146
+ * Parses reports from company facts.
140
147
  */
141
- getReportsRaw(params: GetSymbolParams): Promise<ReportRaw[]>;
148
+ getReportsRaw(params: GetReportsRawParams): Promise<ReportRaw[]>;
142
149
  /**
143
150
  * Gets a list of all tickers and CIKs from `https://www.sec.gov/files/company_tickers.json`
144
151
  *
@@ -226,5 +233,25 @@ export default class SecEdgarApi {
226
233
  * ```
227
234
  */
228
235
  createRequestProxyStatement(params: CreateRequestWrapperParams): SubmissionRequestWrapper<FormDef14aData>;
236
+ /**
237
+ * Gets list of latest filings.
238
+ *
239
+ * @see https://www.sec.gov/edgar/searchedgar/currentevents
240
+ */
241
+ getCurrentFilingsDaily(params?: {
242
+ formType?: DailyFilingFormType;
243
+ lookbackDays?: number;
244
+ }): Promise<{
245
+ date: string;
246
+ matchCount: number;
247
+ totalCount: number;
248
+ entries: {
249
+ accessionNumber: string;
250
+ form: string;
251
+ companyCik: number;
252
+ companyName: string;
253
+ filedDate: string;
254
+ }[];
255
+ }>;
229
256
  }
230
257
  export {};
@@ -1,4 +1,15 @@
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
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -251,33 +262,39 @@ var SecEdgarApi = /** @class */ (function () {
251
262
  */
252
263
  SecEdgarApi.prototype.getReports = function (params) {
253
264
  return __awaiter(this, void 0, void 0, function () {
254
- var symbol, _a, withWrapper, _b, usePropertyResolver, facts, reports;
265
+ var _a, withWrapper, _b, usePropertyResolver, reportsRaw, reports;
255
266
  return __generator(this, function (_c) {
256
267
  switch (_c.label) {
257
268
  case 0:
258
- symbol = params.symbol, _a = params.withWrapper, withWrapper = _a === void 0 ? false : _a, _b = params.usePropertyResolver, usePropertyResolver = _b === void 0 ? true : _b;
259
- return [4 /*yield*/, this.getFacts({ symbol: symbol })];
269
+ _a = params.withWrapper, withWrapper = _a === void 0 ? false : _a, _b = params.usePropertyResolver, usePropertyResolver = _b === void 0 ? true : _b;
270
+ return [4 /*yield*/, this.getReportsRaw(__assign(__assign({}, params), { includeNamePrefix: false }))];
260
271
  case 1:
261
- facts = _c.sent();
262
- reports = this.reportParser.parseReports(facts, usePropertyResolver);
272
+ reportsRaw = _c.sent();
273
+ reports = this.reportParser.parseReportsFromRaw({ reportsRaw: reportsRaw, usePropertyResolver: usePropertyResolver });
263
274
  return [2 /*return*/, withWrapper ? reports : reports.map(function (report) { return report.getReport(); })];
264
275
  }
265
276
  });
266
277
  });
267
278
  };
268
279
  /**
269
- * Parses reports from company facts. Calculates missing properties and uses a single interface
270
- * for all reports.
280
+ * Parses reports from company facts.
271
281
  */
272
282
  SecEdgarApi.prototype.getReportsRaw = function (params) {
273
283
  return __awaiter(this, void 0, void 0, function () {
274
- var facts;
275
- return __generator(this, function (_a) {
276
- switch (_a.label) {
277
- case 0: return [4 /*yield*/, this.getFacts(params)];
284
+ var symbol, _a, includeNamePrefix, _b, adjustForSplits, _c, resolvePeriodValues, companyFacts, reports;
285
+ return __generator(this, function (_d) {
286
+ switch (_d.label) {
287
+ case 0:
288
+ symbol = params.symbol, _a = params.includeNamePrefix, includeNamePrefix = _a === void 0 ? false : _a, _b = params.adjustForSplits, adjustForSplits = _b === void 0 ? true : _b, _c = params.resolvePeriodValues, resolvePeriodValues = _c === void 0 ? true : _c;
289
+ return [4 /*yield*/, this.getFacts({ symbol: symbol })];
278
290
  case 1:
279
- facts = _a.sent();
280
- return [2 /*return*/, this.reportParser.parseReportsRaw(facts)];
291
+ companyFacts = _d.sent();
292
+ reports = this.reportParser.parseReportsRaw(companyFacts, {
293
+ adjustForSplits: adjustForSplits,
294
+ resolvePeriodValues: resolvePeriodValues,
295
+ includeNamePrefix: includeNamePrefix,
296
+ });
297
+ return [2 /*return*/, reports];
281
298
  }
282
299
  });
283
300
  });
@@ -478,6 +495,41 @@ var SecEdgarApi = /** @class */ (function () {
478
495
  }); };
479
496
  return new RequestWrapper_1.default({ submissions: submissions, options: options, sendRequest: sendRequest });
480
497
  };
498
+ /**
499
+ * Gets list of latest filings.
500
+ *
501
+ * @see https://www.sec.gov/edgar/searchedgar/currentevents
502
+ */
503
+ SecEdgarApi.prototype.getCurrentFilingsDaily = function (params) {
504
+ var _a;
505
+ return __awaiter(this, void 0, void 0, function () {
506
+ var _b, _c, formType, _d, lookbackDays, indexByFormType, indexFormType, url, xml;
507
+ return __generator(this, function (_e) {
508
+ switch (_e.label) {
509
+ case 0:
510
+ _b = params !== null && params !== void 0 ? params : {}, _c = _b.formType, formType = _c === void 0 ? 'ALL' : _c, _d = _b.lookbackDays, lookbackDays = _d === void 0 ? 0 : _d;
511
+ if (lookbackDays > 5) {
512
+ throw new Error("lookbackDays must be <= 5. Received ".concat(lookbackDays));
513
+ }
514
+ indexByFormType = {
515
+ '10-K': 0,
516
+ '10-Q': 1,
517
+ '14': 2,
518
+ '485': 3,
519
+ '8-K': 4,
520
+ 'S-8': 5,
521
+ ALL: 6,
522
+ };
523
+ indexFormType = (_a = indexByFormType[formType]) !== null && _a !== void 0 ? _a : 0;
524
+ url = "".concat(this.baseUrlSec, "/cgi-bin/current?q1=").concat(lookbackDays, "&q2=").concat(indexFormType);
525
+ return [4 /*yield*/, this.request(url, true)];
526
+ case 1:
527
+ xml = (_e.sent());
528
+ return [2 /*return*/, this.documentParser.parseCurrentFilingsDaily({ xml: xml })];
529
+ }
530
+ });
531
+ });
532
+ };
481
533
  return SecEdgarApi;
482
534
  }());
483
535
  exports.default = SecEdgarApi;
@@ -1,3 +1,4 @@
1
+ import { FactItem } from './company-facts.type';
1
2
  export interface XMLParams {
2
3
  xml: string;
3
4
  }
@@ -10,3 +11,43 @@ export interface FieldDataResponse<Field extends string = string> {
10
11
  fields: Field[];
11
12
  data: (string | number)[][];
12
13
  }
14
+ export interface SplitData {
15
+ filedFirst: string;
16
+ filedLast: string;
17
+ endFirst: string;
18
+ endLast: string;
19
+ splitRatio: number;
20
+ }
21
+ export interface FactGroup {
22
+ name: string;
23
+ unit: string;
24
+ accn: string;
25
+ reportEnd: string;
26
+ reportFiled: string;
27
+ isResolverGenerated: boolean;
28
+ filedFirst: string;
29
+ filedLast: string;
30
+ endFirst: string;
31
+ endLast: string;
32
+ values: number[];
33
+ fiscalYear: number;
34
+ quarter: number;
35
+ facts: FactItem[];
36
+ valueSplitAdjustedPeriod: number | null;
37
+ valueSplitAdjustedTrailing: number | null;
38
+ valuePeriodResolved: number | null;
39
+ valueTrailingResolved: number | null;
40
+ valuePeriodFirst: number | null;
41
+ valuePeriodLast: number | null;
42
+ valueTrailingFirst: number | null;
43
+ valueTrailingLast: number | null;
44
+ }
45
+ export interface FactItemExtended extends FactItem {
46
+ period: number;
47
+ year: number;
48
+ quarter: number;
49
+ periodValue: number | null;
50
+ trailingValue: number | null;
51
+ splitValue: number | null;
52
+ splitsApplied: number[];
53
+ }
@@ -1,3 +1,4 @@
1
+ import { FiscalPeriod } from './report-raw.type';
1
2
  export interface CompanyFactListData {
2
3
  cik: number;
3
4
  entityName: string;
@@ -6,11 +7,12 @@ export interface CompanyFactListData {
6
7
  export interface CompanyFactList {
7
8
  dei: Record<string, CompanyFact>;
8
9
  invest?: Record<string, CompanyFact>;
10
+ srt?: Record<string, CompanyFact>;
9
11
  'us-gaap'?: Record<string, CompanyFact>;
10
12
  }
11
13
  export interface CompanyFact {
12
- label: string;
13
- description: string;
14
+ label: string | null;
15
+ description: string | null;
14
16
  units: Record<string, FactValue[]>;
15
17
  }
16
18
  export interface FactValue {
@@ -51,3 +53,28 @@ export interface MultiCompanyFactFrame {
51
53
  pts: number;
52
54
  data: MultiCompanyFactFrameItem[];
53
55
  }
56
+ export interface FactItem {
57
+ cik: number | string;
58
+ end: string;
59
+ filed: string;
60
+ name: string;
61
+ unit: string;
62
+ value: number | string;
63
+ start?: string;
64
+ hasSegments?: boolean;
65
+ accn?: string;
66
+ form?: string;
67
+ fp?: string;
68
+ frame?: string;
69
+ fy?: number;
70
+ /** For XBRL reports only */
71
+ segments?: {
72
+ value: string;
73
+ dimension: string;
74
+ }[];
75
+ uuid?: string;
76
+ }
77
+ export interface FactItemWithFiscals extends FactItem {
78
+ fiscalPeriod: FiscalPeriod;
79
+ year: number;
80
+ }
@@ -93,4 +93,5 @@ export interface FormDef14aData {
93
93
  executiveCompensation: ExecutiveCompensation[];
94
94
  holders: Holder[];
95
95
  }
96
+ export type DailyFilingFormType = '10-K' | '10-Q' | '8-K' | '14' | '485' | 'S-8' | 'ALL';
96
97
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sec-edgar-api",
3
- "version": "0.2.4",
3
+ "version": "0.3.1",
4
4
  "description": "Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.",
5
5
  "main": "build/index.js",
6
6
  "author": "Andrew Evers (https://github.com/andyevers)",
@@ -1,10 +0,0 @@
1
- import { FactItem } from './ReportBuilder';
2
- import { CompanyFactListData } from '../../types';
3
- /**
4
- * Builds an array of fact records.
5
- */
6
- export default class FactRecordBuilder {
7
- createFacts(data: CompanyFactListData, filterDuplicates?: boolean): {
8
- facts: FactItem[];
9
- };
10
- }
@@ -1,50 +0,0 @@
1
- import { FiscalPeriod } from '../../types/report-raw.type';
2
- import { FactItemWithFiscals } from './ReportBuilder';
3
- interface SplitData {
4
- end: string;
5
- filed: string;
6
- value: number;
7
- firstFiled: string;
8
- fiscalYear: number;
9
- fiscalPeriod: FiscalPeriod;
10
- }
11
- type FactItemWithFiscalsNumeric = Omit<FactItemWithFiscals, 'cik' | 'value'> & {
12
- value: number;
13
- };
14
- /**
15
- * Adjust share-based property values for splits. Checks where the split was applied,
16
- * and adjusts all previously filed share facts accordingly.
17
- */
18
- export default class FactSplitAdjuster {
19
- private readonly splitKey;
20
- private readonly splitByFiscalYearAmount;
21
- private readonly factsByYearQuarterByPropertyName;
22
- private readonly factsAnnaulByYearByPropertyName;
23
- private readonly resolvedProperties;
24
- private sortedSplits;
25
- private getMap;
26
- private filedFirstLastBySplitKey;
27
- add(fact: FactItemWithFiscalsNumeric & {
28
- filedLast?: string;
29
- }): void;
30
- getSplitsAsc(): SplitData[];
31
- isSplitProperty(propertyName: string): boolean;
32
- addSplitData(data: Omit<SplitData, 'firstFiled'>): void;
33
- /**
34
- * TODO: Find a more reliable way of checking if the split has already been applied.
35
- */
36
- private didApplySplit;
37
- isSplitAdjustableUnit(unit: string): boolean;
38
- isShareRatioUnit(unit: string): boolean;
39
- private getSortedFacts;
40
- resolveProperty(propertyName: string): void;
41
- get(propertyName: string, year: number, fiscalPeriod: FiscalPeriod): number | undefined;
42
- forEach(callback: (params: {
43
- propertyName: string;
44
- year: number;
45
- fiscalPeriod: FiscalPeriod;
46
- value: number;
47
- }) => void): void;
48
- private adjustValuesForSplits;
49
- }
50
- export {};