UNPKG

@turnbuckle/aprs-calculator-services

Version:

Anchorpoint Risk Calculator Service.

46 lines (45 loc) 2.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.calculateCcfTermStructure = void 0; var ts_stopwatch_1 = require("ts-stopwatch"); var assert_1 = require("../../common/assert"); var sort_module_1 = require("../../common/sort.module"); /** * @AgeAnalysisInputModel input * - ageAnalysis: array of age analysis complete with ageing steps and scoring * - defaultsMinDays: the maximum term to use when filtering out age analysis terms (use the defaults bucket minDays) * calculates the CCF term structure * @TermStructureOutputModel output * - termStructure: LGD term structure */ // TODO: still needs attention; not currently used function calculateCcfTermStructure(input) { var sw = new ts_stopwatch_1.Stopwatch(); sw.start(); (0, assert_1.assert)(input.ageAnalysis.length > 0, "'ageAnalysis' parameter was not provided"); (0, assert_1.assert)(input.defaultsMinDays !== null, "'defaultsMinDays' parameter was not provided"); var termStructure = []; var ageAnalysis = (0, sort_module_1.sortByTransactionNumberAndThenDate)(input.ageAnalysis); // only get terms between 1st and last bucket in the ageing table that falls on a 30-day interval var terms = ageAnalysis.filter(function (item) { return item.ageing >= 0 && item.ageing <= input.defaultsMinDays && item.ageing % 30 === 0; }); var _loop_1 = function (i) { var currentItem = terms[i]; var defaultItem = terms.find(function (item) { return item.transactionNumber === currentItem.transactionNumber && item.ageing === input.defaultsMinDays; }); if (defaultItem) { termStructure.push({ // id: currentItem.transactionNumber, term: currentItem.ageing, value: defaultItem.balance / currentItem.balance }); } }; for (var i = 0; i < terms.length; i++) { _loop_1(i); } sw.stop(); return { executeDuration: sw.getTime(), termStructure: termStructure, }; } exports.calculateCcfTermStructure = calculateCcfTermStructure;