UNPKG

sec-edgar-api

Version:

Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.

93 lines (92 loc) 3.72 kB
import type { FiscalPeriod } from '../../types/report-raw.type'; /** * Resolves quarterly and annual values for a property. This is because filers provide total values for the * current fiscal year, rather than values for the individual quarters * ex: Net income for Q2 will give 6 months revenue, not 3 month. */ export default class FactPeriodResolver { /** Values for each quarter [numQ1, numQ2, numQ3, numQ4] */ private readonly valueByQuarterByPropertyByYear; /** Same as by quarter but string values */ private readonly valueByQuarterByPropertyByYearString; /** Value sums (each includes sum of previous quarter). last el used for annual report. [sumQ1, sumQ2, sumQ3, sumFY] */ private readonly sumByQuarterByPropertyByYear; /** Which properties have a range that need to be resolved to get quarterly value */ private readonly propertiesResolvableByYear; /** all properties present for each year */ private readonly propertiesByYear; /** prevent values from being added multiple times */ private readonly resolvedValues; private readonly unresolvedReports; private readonly cik; private readonly preferOriginalFilingValues; constructor(args: { cik: number; preferOriginalFilingValues?: boolean; }); /** * Some properties have a start and end that represent a period average, rather than a period total. * These properties should be treated as instantaneous properties, meaning * the value for Q4 and FY should be the same. * * I believe the only properties like this are share related: * us-gaap:WeightedAverageNumberOfDilutedSharesOutstanding and us-gaap:WeightedAverageNumberOfSharesOutstandingBasic. * May need to update this in the future if there are more */ static isAverageShares(params: { propertyName: string; }): boolean; private isAverageShares; /** * Used to check if this should potentially overwrite a value that has already been set. */ private isPreferredValue; private getOrSetBucketArr; private addPropertyByYear; resolveValues(propertyName: string, year: number): void; get(propertyName: string, year: number, fiscalPeriod: FiscalPeriod): number | undefined; private getPropertyBuckets; /** * 0, 3, 6, 9, or 12 month period. 0 is instantaneous data that doesn't have a time period, (ex: assets) * other facts have values that are for a period of time. (like revenue over the last 6 months). * * Use periods 0 and 3 for quarterly reports and 0 and 12 for annual reports. */ static getPeriod(params: { start?: string; end: string; }): 0 | 3 | 6 | 12 | 9; getPeriod(params: { start?: string; end: string; }): 0 | 3 | 6 | 12 | 9; private getOrSetReport; /** * True if the filed date is within 60 days of the end date. This indicates that it is likely * the original filing of the fact because filers are required to submit within 45 days of the * period end, and subsequent reports are filed 90 days apart. */ isOriginalFiling(params: { end: string; filed: string; }): boolean; add(params: { year: number; quarter: number; start?: string; end: string; value: number | string; name: string; filed: string; }): void; private buildUnresolvedReports; forEach(callback: (params: { year: number; fiscalPeriod: FiscalPeriod; propertyName: string; value: number | string; valueQuarter: number; valueTrailing: number; quarter: number; }) => void): void; }