UNPKG

sec-edgar-api

Version:

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

38 lines (37 loc) 1.47 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.resolveSplitRatio = void 0; function resolveSplitRatio(report) { var _a = report.getReportsFiscalYearByPeriod(), Q1 = _a.Q1, Q2 = _a.Q2, Q3 = _a.Q3, Q4 = _a.Q4; var splitReport = null; // FY will have already been matched with Q4 from resolve-q4-fiscal-year-matching-properties.ts var takenRatios = new Set(); for (var _i = 0, _b = [Q4, Q3, Q2, Q1]; _i < _b.length; _i++) { var report_1 = _b[_i]; if (!(report_1 === null || report_1 === void 0 ? void 0 : report_1.splitRatio)) continue; if (takenRatios.has(report_1.splitRatio)) { report_1.splitRatio = null; continue; } splitReport = report_1; takenRatios.add(report_1.splitRatio); } if (!splitReport) return; var prevReports = [ splitReport.getReportOffset(-1, 'QUARTERLY'), splitReport.getReportOffset(-2, 'QUARTERLY'), splitReport.getReportOffset(-3, 'QUARTERLY'), splitReport.getReportOffset(-4, 'QUARTERLY'), splitReport.getReportOffset(-1, 'ANNUAL'), ]; prevReports.forEach(function (prevReport) { if (prevReport === splitReport) return; if (prevReport && splitReport && prevReport.splitRatio === splitReport.splitRatio) { prevReport.splitRatio = null; } }); } exports.resolveSplitRatio = resolveSplitRatio;