sec-edgar-api
Version:
Fetch and parse SEC earnings reports and other filings. Useful for financial analysis.
127 lines (126 loc) • 8.12 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.parseFormDef14a = void 0;
var XMLParserLegacy_1 = require("../XMLParserLegacy");
/**
* Form DEF 14a - Proxy Statement
*
* example at https://www.sec.gov/Archives/edgar/data/320193/000130817923000019/laap2023_def14a.htm
*/
function parseFormDef14a(params, xmlParser) {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
if (xmlParser === void 0) { xmlParser = new XMLParserLegacy_1.default(); }
var xml = params.xml;
var doc = xmlParser.getDocumentNode({ xml: xml });
var tables = doc.parseTables();
var usedTables = [];
var compensationArr = [];
var holderArr = [];
var findCompensationTables = function (type) {
var tablesFound = tables.filter(function (table) {
var _a, _b, _c, _d, _e;
var hasNameRow = (_a = table.rows[0]) === null || _a === void 0 ? void 0 : _a.some(function (col) { return "".concat(col).toLowerCase().includes('name'); });
var hasTotalRow = (_b = table.rows[0]) === null || _b === void 0 ? void 0 : _b.some(function (col) { return "".concat(col).toLowerCase().includes('total'); });
var hasAwardRow = (_c = table.rows[0]) === null || _c === void 0 ? void 0 : _c.some(function (col) { return "".concat(col).toLowerCase().includes('award'); });
var titleLower = table.title.toLowerCase();
var textLower = (_e = (_d = table.textBefore) === null || _d === void 0 ? void 0 : _d.toLowerCase()) !== null && _e !== void 0 ? _e : '';
var isTitleMatch = titleLower.includes(type) && titleLower.includes('compensation');
var isTextMatch = hasNameRow && hasTotalRow && hasAwardRow && textLower.includes(type);
return (isTitleMatch || isTextMatch) && !usedTables.includes(table);
});
tablesFound.forEach(function (t) { return usedTables.push(t); });
return tablesFound;
};
var tablesHolder = tables.filter(function (table) {
var _a, _b;
var hasNameRow = (_a = table.rows[0]) === null || _a === void 0 ? void 0 : _a.some(function (col) { return "".concat(col).toLowerCase().includes('name'); });
var hasPercent = (_b = table.rows[0]) === null || _b === void 0 ? void 0 : _b.some(function (col) { return "".concat(col).toLowerCase().includes('percent'); });
var titleLower = table.title.toLowerCase();
var isTitleMatch = titleLower.includes('security') && titleLower.includes('owner') && titleLower.includes('beneficial');
return isTitleMatch && hasNameRow && hasPercent;
});
var foundHoldersKeys = new Set();
var _loop_1 = function (table) {
var header = table.rows[0];
var getIndex = function (search) { return header.findIndex(function (col) { return "".concat(col).toLowerCase().includes(search); }); };
var indexName = getIndex('name');
var indexPercent = getIndex('percent');
var indexShares = (_b = (_a = table.rows[1]) === null || _a === void 0 ? void 0 : _a.findIndex(function (col) { return typeof col === 'number' && !isNaN(col); })) !== null && _b !== void 0 ? _b : -1;
for (var i = 1; i < table.rows.length; i++) {
for (var i_1 = 1; i_1 < table.rows.length; i_1++) {
var nameVal = (_d = (_c = table.rows[i_1]) === null || _c === void 0 ? void 0 : _c[indexName]) !== null && _d !== void 0 ? _d : null;
if (typeof nameVal !== 'string')
continue;
var nameParts = nameVal.split('}}');
var namePartsSpaces = nameVal.split(' ');
var position = (_e = nameParts[1]) !== null && _e !== void 0 ? _e : namePartsSpaces.slice(2, namePartsSpaces.length).join(' ');
var name_1 = nameParts[1] ? nameParts[0] : namePartsSpaces.slice(0, 2).join(' ');
var holder = {
name: name_1.replace(/{{/g, '').replace(/}}/g, '').trim(),
position: position.replace(/{{/g, '').replace(/}}/g, '').trim() || null,
shares: Number((_f = table.rows[i_1]) === null || _f === void 0 ? void 0 : _f[indexShares]) || null,
percentOfClass: String((_g = table.rows[i_1]) === null || _g === void 0 ? void 0 : _g[indexPercent]) || null,
};
var key = "".concat(holder.name).concat(holder.position).concat(holder.shares).concat(holder.percentOfClass);
if (!foundHoldersKeys.has(key))
holderArr.push(holder);
foundHoldersKeys.add(key);
}
}
};
for (var _i = 0, tablesHolder_1 = tablesHolder; _i < tablesHolder_1.length; _i++) {
var table = tablesHolder_1[_i];
_loop_1(table);
}
for (var _t = 0, _u = ['director', 'executive', 'summary']; _t < _u.length; _t++) {
var type = _u[_t];
var _loop_2 = function (table) {
if (!table)
return "continue";
var header = table.rows[0];
var getIndex = function (search) { return header.findIndex(function (col) { return "".concat(col).toLowerCase().includes(search); }); };
var indexName = getIndex('name');
var indexYear = getIndex('year');
var indexSalary = getIndex('salary') === -1 ? getIndex('cash') : getIndex('salary');
var indexBonus = getIndex('bonus');
var indexStock = getIndex('stock');
var indexNonEquity = getIndex('non-equity') === -1 ? getIndex('option') : getIndex('non-equity');
var indexOther = getIndex('other');
var indexTotal = getIndex('total');
var defaultPosition = {
director: 'Director',
executive: 'Executive',
summary: null,
}[type];
for (var i = 1; i < table.rows.length; i++) {
var nameVal = (_j = (_h = table.rows[i]) === null || _h === void 0 ? void 0 : _h[indexName]) !== null && _j !== void 0 ? _j : null;
if (typeof nameVal !== 'string')
continue;
var nameParts = nameVal.split('}}');
var namePartsSpaces = nameVal.split(' ');
var position = (_k = nameParts[1]) !== null && _k !== void 0 ? _k : namePartsSpaces.slice(2, namePartsSpaces.length).join(' ');
var name_2 = nameParts[1] ? nameParts[0] : namePartsSpaces.slice(0, 2).join(' ');
var compensation = {
name: name_2.replace(/{{/g, '').replace(/}}/g, '').trim(),
position: position.replace(/{{/g, '').replace(/}}/g, '').trim() || (defaultPosition !== null && defaultPosition !== void 0 ? defaultPosition : null),
year: Number((_l = table.rows[i]) === null || _l === void 0 ? void 0 : _l[indexYear]) || null,
salaryDollars: Number((_m = table.rows[i]) === null || _m === void 0 ? void 0 : _m[indexSalary]) || null,
bonusDollars: Number((_o = table.rows[i]) === null || _o === void 0 ? void 0 : _o[indexBonus]) || null,
stockAwardDollars: Number((_p = table.rows[i]) === null || _p === void 0 ? void 0 : _p[indexStock]) || null,
nonEquityDollars: Number((_q = table.rows[i]) === null || _q === void 0 ? void 0 : _q[indexNonEquity]) || null,
otherDollars: Number((_r = table.rows[i]) === null || _r === void 0 ? void 0 : _r[indexOther]) || null,
totalDollars: Number((_s = table.rows[i]) === null || _s === void 0 ? void 0 : _s[indexTotal]) || null,
};
if (compensation.totalDollars !== null) {
compensationArr.push(compensation);
}
}
};
for (var _v = 0, _w = findCompensationTables(type); _v < _w.length; _v++) {
var table = _w[_v];
_loop_2(table);
}
}
return { executiveCompensation: compensationArr, holders: holderArr };
}
exports.parseFormDef14a = parseFormDef14a;