sec-edgar-api 0.2.1 → 0.2.2

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 (73) hide show
  1. package/README.md +3 -5
  2. package/build/services/DocumentParser/HtmlTableExtractor.d.ts +41 -0
  3. package/build/services/DocumentParser/HtmlTableExtractor.js +408 -0
  4. package/build/services/DocumentParser/XMLParser.d.ts +20 -5
  5. package/build/services/DocumentParser/XMLParser.js +122 -118
  6. package/build/services/DocumentParser/parsers/index.d.ts +5 -3
  7. package/build/services/DocumentParser/parsers/index.js +5 -3
  8. package/build/services/DocumentParser/parsers/parse-current-filings.d.ts +3 -0
  9. package/build/services/DocumentParser/parsers/parse-current-filings.js +98 -0
  10. package/build/services/DocumentParser/parsers/parse-form-13f.d.ts +6 -0
  11. package/build/services/DocumentParser/parsers/parse-form-13f.js +91 -0
  12. package/build/services/DocumentParser/parsers/parse-form-13g.js +2 -2
  13. package/build/services/DocumentParser/parsers/parse-form-4.d.ts +6 -1
  14. package/build/services/DocumentParser/parsers/parse-form-4.js +134 -204
  15. package/build/services/DocumentParser/parsers/parse-form-def14a.d.ts +1 -2
  16. package/build/services/DocumentParser/parsers/parse-form-def14a.js +157 -106
  17. package/build/services/ReportBuilder/FactFiscalCalculator.d.ts +47 -0
  18. package/build/services/ReportBuilder/FactFiscalCalculator.js +228 -0
  19. package/build/services/ReportBuilder/FactPeriodResolver.d.ts +44 -0
  20. package/build/services/ReportBuilder/FactPeriodResolver.js +185 -0
  21. package/build/services/ReportBuilder/FactRecordBuilder.d.ts +7 -0
  22. package/build/services/ReportBuilder/FactRecordBuilder.js +49 -0
  23. package/build/services/ReportBuilder/FactSplitAdjuster.d.ts +39 -0
  24. package/build/services/ReportBuilder/FactSplitAdjuster.js +192 -0
  25. package/build/services/ReportBuilder/ReportBuilder.d.ts +37 -0
  26. package/build/services/ReportBuilder/ReportBuilder.js +180 -0
  27. package/build/services/ReportBuilder/ReportRawResolvable.d.ts +17 -0
  28. package/build/services/ReportBuilder/ReportRawResolvable.js +114 -0
  29. package/build/services/ReportBuilder/index.d.ts +2 -0
  30. package/build/services/ReportBuilder/index.js +4 -0
  31. package/build/services/ReportParser/FactItem.d.ts +66 -0
  32. package/build/services/ReportParser/FactItem.js +50 -0
  33. package/build/services/ReportParser/FactItemFactory.d.ts +22 -0
  34. package/build/services/ReportParser/FactItemFactory.js +150 -0
  35. package/build/services/ReportParser/FactSplitMap.d.ts +16 -0
  36. package/build/services/ReportParser/FactSplitMap.js +101 -0
  37. package/build/services/ReportParser/PropertyResolver.d.ts +1 -0
  38. package/build/services/ReportParser/PropertyResolver.js +1 -0
  39. package/build/services/ReportParser/ReportParser.d.ts +3 -10
  40. package/build/services/ReportParser/ReportParser.js +8 -23
  41. package/build/services/ReportParser/ReportRawParser.d.ts +5 -28
  42. package/build/services/ReportParser/ReportRawParser.js +29 -141
  43. package/build/services/ReportParser/ReportWrapper.js +2 -5
  44. package/build/services/ReportParser/resolvers/index.d.ts +2 -0
  45. package/build/services/ReportParser/resolvers/index.js +2 -0
  46. package/build/services/ReportParser/resolvers/resolve-cash-flow-capex.js +4 -3
  47. package/build/services/ReportParser/resolvers/resolve-cash-flow-operating.js +1 -1
  48. package/build/services/ReportParser/resolvers/resolve-cash-flow-working-capital-non-cash.js +1 -1
  49. package/build/services/ReportParser/resolvers/resolve-expense-depreciation.js +1 -1
  50. package/build/services/ReportParser/resolvers/resolve-fiscal-year-cumulative-properties.js +28 -14
  51. package/build/services/ReportParser/resolvers/resolve-q4-fiscal-year-matching-properties.js +32 -4
  52. package/build/services/ReportParser/resolvers/resolve-split-ratio.d.ts +2 -0
  53. package/build/services/ReportParser/resolvers/resolve-split-ratio.js +37 -0
  54. package/build/services/SecEdgarApi/SecEdgarApi.d.ts +85 -47
  55. package/build/services/SecEdgarApi/SecEdgarApi.js +246 -108
  56. package/build/types/current-filings-xml.type.d.ts +74 -0
  57. package/build/types/current-filings-xml.type.js +6 -0
  58. package/build/types/current-filings.type.d.ts +44 -0
  59. package/build/types/current-filings.type.js +2 -0
  60. package/build/types/form-13f-xml.type.d.ts +105 -0
  61. package/build/types/form-13f-xml.type.js +2 -0
  62. package/build/types/form-4-xml.type.d.ts +132 -0
  63. package/build/types/form-4-xml.type.js +2 -0
  64. package/build/types/index.d.ts +2 -2
  65. package/build/types/index.js +2 -2
  66. package/build/types/parsed-filings.type.d.ts +144 -5
  67. package/build/types/report-raw.type.d.ts +4 -7
  68. package/build/types/report-translated.type.d.ts +1 -2
  69. package/build/types/submission.type.d.ts +3 -2
  70. package/build/util/calculation-map-by-ns.d.ts +6 -0
  71. package/build/util/calculation-map-by-ns.js +9 -0
  72. package/build/util/key-translations.js +1 -2
  73. package/package.json +5 -2
@@ -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;
@@ -1,18 +1,16 @@
1
- import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, FieldDataResponse, Form10KData, Form13GData, Form4Data, FormDef14aData, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
1
+ import { CompanyFactFrame, CompanyFactListData, CompanyTickerItem, FieldDataResponse, FiscalPeriod, MultiCompanyFactFrame, ReportRaw, ReportTranslated } from '../../types';
2
2
  import { FilingListDetails, FilingListItemTranslated, SubmissionList } from '../../types/submission.type';
3
3
  import { IClient } from '../Client';
4
- import DocumentParser from '../DocumentParser';
4
+ import _parsers from '../DocumentParser/parsers';
5
5
  import ReportParser from '../ReportParser';
6
- import { ParseReportsOptions } from '../ReportParser/ReportRawParser';
7
6
  import ReportWrapper from '../ReportParser/ReportWrapper';
8
- import SubmissionRequestWrapper from './RequestWrapper';
9
7
  import { IThrottler } from './Throttler';
10
8
  interface SecApiArgs {
11
9
  throttler: IThrottler;
12
10
  client: IClient;
13
11
  cikBySymbol: Record<string, number>;
14
12
  reportParser: ReportParser;
15
- documentParser: DocumentParser;
13
+ parsers: typeof _parsers;
16
14
  }
17
15
  export interface CreateRequestWrapperParams {
18
16
  /** symbol or cik */
@@ -48,12 +46,7 @@ export interface GetDocumentXMLParams {
48
46
  /** symbol or cik */
49
47
  symbol: string | number;
50
48
  accessionNumber: string;
51
- primaryDocument: string;
52
- }
53
- export interface GetSubmissionsParams {
54
- /** symbol or cik */
55
- symbol: string;
56
- includeTranslated?: boolean;
49
+ primaryDocument?: string;
57
50
  }
58
51
  /**
59
52
  * Gets reports from companies filed with the SEC
@@ -67,11 +60,12 @@ export default class SecEdgarApi {
67
60
  private readonly client;
68
61
  readonly cikBySymbol: Record<string, number>;
69
62
  readonly reportParser: ReportParser;
70
- readonly documentParser: DocumentParser;
63
+ private readonly parsers;
71
64
  constructor(args?: SecApiArgs);
72
65
  private request;
73
66
  private mapFilingListDetails;
74
- private getCreateRequestSubmissions;
67
+ private filterSubmissionsInFiscalPeriodAsc;
68
+ private extractSubmissionsWithXml;
75
69
  /**
76
70
  * If symbol is not in cikBySymbol, assume it is a cik. does not make a request
77
71
  */
@@ -86,7 +80,7 @@ export default class SecEdgarApi {
86
80
  *
87
81
  * endpoint: `/submissions/CIK${cik}.json`
88
82
  */
89
- getSubmissions(params: GetSubmissionsParams): Promise<SubmissionList>;
83
+ getSubmissions(params: GetSymbolParams): Promise<SubmissionList>;
90
84
  /**
91
85
  * The company-concept API returns all the XBRL disclosures from a single company (CIK)
92
86
  * and concept (a taxonomy and tag) into a single JSON file, with a separate array
@@ -139,7 +133,7 @@ export default class SecEdgarApi {
139
133
  * Parses reports from company facts. Calculates missing properties and uses a single interface
140
134
  * for all reports.
141
135
  */
142
- getReportsRaw(params: GetSymbolParams & ParseReportsOptions): Promise<ReportRaw[]>;
136
+ getReportsRaw(params: GetSymbolParams): Promise<ReportRaw[]>;
143
137
  /**
144
138
  * Gets a list of all tickers and CIKs from `https://www.sec.gov/files/company_tickers.json`
145
139
  *
@@ -159,7 +153,8 @@ export default class SecEdgarApi {
159
153
  */
160
154
  getMutualFundList(): Promise<FieldDataResponse<'cik' | 'seriesId' | 'classId' | 'symbol'>>;
161
155
  /**
162
- * Gets a raw xml document string. the parameters are found in the submission list response. (response.filings.recent or response.filings.recentTranslated)
156
+ * Gets a raw xml document string. the parameters are found in the submission list response.
157
+ * (response.filings.recent or response.filings.recentTranslated)
163
158
  *
164
159
  * Some form types can be parsed using the DocumentParser such as form 4 (insider transactions) and form 13g (institutional holders)
165
160
  *
@@ -181,51 +176,94 @@ export default class SecEdgarApi {
181
176
  url: string;
182
177
  }): Promise<string>;
183
178
  /**
184
- * Used for getting insider transactions. extracts insider transaction urls from submission list response, and parses the xml doc.
179
+ * Used for getting security holdings.
180
+ *
181
+ * Forms: 13F, 13F/A, 13F-HR, 13F-HR/A
185
182
  *
186
- * ```ts
187
- * const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
188
- * const requestWrapper = secEdgarApi.createRequestInsiderTransactions({ symbol: 'AAPL', filings: submissions.filings.recent })
183
+ * Extracts holdings urls from submission list response, and parses the xml doc.
189
184
  *
190
- * const transactions1 = (await requestWrapper.requestNext()).result.transactions // array of transactions from most recent doc
191
- * const transactions2 = (await requestWrapper.requestNext()).result.transactions // array of transactions from second most recent doc
192
- * ```
185
+ * Sends 2 requests by default, 1 request if submissions is provided, and 0 requests if documentXml is provided.
186
+ *
187
+ * WARNING: XML and HTML docs can be formatted differently and is prone to innacuracies.
193
188
  */
194
- createRequestInsiderTransactions(params: CreateRequestWrapperParams): SubmissionRequestWrapper<Form4Data>;
189
+ getHoldings(params: {
190
+ symbol: string;
191
+ lookback?: number;
192
+ fiscalYear?: number;
193
+ fiscalPeriod?: FiscalPeriod;
194
+ submissions?: SubmissionList;
195
+ documentXml?: string;
196
+ }): Promise<{
197
+ url: string | null;
198
+ holdingsForm: import("../../types").Form13FData | null;
199
+ submissions: FilingListItemTranslated[];
200
+ }>;
195
201
  /**
196
- * Used for getting institutional holders. extracts holders urls from submission list response, and parses the xml doc.
202
+ * Gets institutional holders that have a large stake in the company.
203
+ * If multiple submissions are found within the fiscal period, uses the first submission.
204
+ *
205
+ * Forms: SC 13G, SC 13G/A
197
206
  *
198
- * ```ts
199
- * const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
200
- * const requestWrapper = secEdgarApi.createRequestInstitutionalHolders({ symbol: 'AAPL', filings: submissions.filings.recent })
207
+ * Sends 2 requests by default, 1 request if submissions is provided, and 0 requests if documentXml is provided.
201
208
  *
202
- * const holders1 = (await requestWrapper.requestNext()).result.holders // array of holders from most recent doc
203
- * const holders2 = (await requestWrapper.requestNext()).result.holders // array of holders from second most recent doc
204
- * ```
209
+ * WARNING: XML and HTML docs can be formatted differently and is prone to innacuracies.
205
210
  */
206
- createRequestInstitutionalHolders(params: CreateRequestWrapperParams): SubmissionRequestWrapper<Form13GData>;
211
+ getInstitutionalHolders(params: {
212
+ symbol: string;
213
+ lookback?: number;
214
+ fiscalPeriod?: FiscalPeriod;
215
+ fiscalYear?: number;
216
+ submissions?: SubmissionList;
217
+ documentXml?: string;
218
+ }): Promise<{
219
+ url: string | null;
220
+ institutionalHolders: import("../../types").InstitutionalHolder[];
221
+ submissions: FilingListItemTranslated[];
222
+ }>;
207
223
  /**
208
- * Used for getting earnings report tables from submission files.
224
+ * Gets executive compensation from the proxy statement.
209
225
  *
210
- * ```ts
211
- * const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
212
- * const requestWrapper = secEdgarApi.createRequesEarningsReports({ symbol: 'AAPL', filings: submissions.filings.recent })
226
+ * Forms: DEF 14A
213
227
  *
214
- * const tables1 = (await requestWrapper.requestNext()).result.tables // array of tables from most recent doc
215
- * const tables2 = (await requestWrapper.requestNext()).result.tables // array of tables from second most recent doc
216
- * ```
228
+ * Sends 2 requests by default, 1 request if submissions is provided, and 0 requests if documentXml is provided.
229
+ *
230
+ * WARNING: XML and HTML docs can be formatted differently and is prone to innacuracies.
217
231
  */
218
- createRequestEarningsReports(params: CreateRequestWrapperParams): SubmissionRequestWrapper<Form10KData>;
232
+ getExecutivesCompensation(params: {
233
+ symbol: string;
234
+ lookback?: number;
235
+ fiscalYear?: number;
236
+ submissions?: SubmissionList;
237
+ documentXml?: string;
238
+ }): Promise<{
239
+ url: string | null;
240
+ executiveCompensation: import("../../types").ExecutiveCompensation[];
241
+ submissions: FilingListItemTranslated[];
242
+ }>;
219
243
  /**
220
- * Proxy statement includes list of holders, executiveCompensation, and other tables. returns FormDef14aData
244
+ * Gets insider transactions - when a company's executives buy or sell shares, options, or other securities in the company.
245
+ *
246
+ * Forms: 4, 4/A, 5, 5/A
221
247
  *
222
- * ```ts
223
- * const submissions = await secEdgarApi.getSubmissions({ symbol: 'AAPL' })
224
- * const requestWrapper = secEdgarApi.createRequesProxyStatement({ symbol: 'AAPL', filings: submissions.filings.recent })
248
+ * Sends 2 requests by default, 1 request if submissions is provided, and 0 requests if documentXml is provided.
225
249
  *
226
- * const { holders, executiveCompensation } = (await requestWrapper.requestNext()).result
227
- * ```
250
+ * WARNING: XML and HTML docs can be formatted differently and is prone to innacuracies.
251
+ */
252
+ getInsiderTransaction(params: {
253
+ symbol: string;
254
+ lookback: number;
255
+ submissions?: SubmissionList;
256
+ documentXml?: string;
257
+ }): Promise<{
258
+ url: string | null;
259
+ insiderTransaction: import("../../types").Form4Data | null;
260
+ submissions: FilingListItemTranslated[];
261
+ }>;
262
+ /**
263
+ * @see https://www.sec.gov/structureddata/rss-feeds-submitted-filings
228
264
  */
229
- createRequestProxyStatement(params: CreateRequestWrapperParams): SubmissionRequestWrapper<FormDef14aData>;
265
+ getCurrentFilings(params?: {
266
+ taxonomy?: 'usGaap' | 'mutualFund' | 'inlineXbrl' | 'allXbrl';
267
+ }): Promise<import("../../types/current-filings.type").CurrentFilingsList | null>;
230
268
  }
231
269
  export {};