UNPKG

@am92/securities-utility

Version:
36 lines (35 loc) 1.21 kB
/** * Handles indexing of ISIN codes by associating them with their corresponding * script IDs. This index is specifically designed for equity data and excludes * derivatives and underlying segments. * * @returns {TIndexHandler<TIsinCodeIndex>} An object containing methods to add rows to the index * and retrieve the indexed data. */ export const isinCodeIndexHandler = () => { const index = {}; const addRow = (segmentKey, itemIndex, itemData, derivativeItemIndex, derivativeItem) => { // Derivative & Unerlying does not have isincode if (derivativeItem || segmentKey.includes('UNDERLYING')) { return; } let item = itemData; const scriptId = item[0]; const isAslAllowed = item[3]; const isinCode = item[6]; const isValidIsincode = isinCode && isinCode !== '0'; // if script is not allowed don't add to any index if (isAslAllowed === 'N' || !isValidIsincode) { return; } if (!index[isinCode]) { index[isinCode] = []; } index[isinCode].push(scriptId); }; const getIndex = () => index; return { addRow, getIndex }; };