Exemple #1
0
        //public void Run()
        //{
        //    var dataTable = ComputeSicrInput();

        //    string stop = "stop";
        //}

        //public List<SicrInputs> ComputeSicrInput()
        //{
        //    var sicrInput = new List<SicrInputs>();

        //    //string[] testAccounts = { "15033346", "15036347", "222017177" };

        //    var loanbookTable = GetLoanbookData().Where(x => x.ContractId.Substring(0, 3) != ECLStringConstants.i.ExpiredContractsPrefix).ToList();
        //    var lifetimePds = _scenarioLifetimePd.ComputeLifetimePd();
        //    var redefaultLifetimePds = _scenarioRedefaultLifetimePd.ComputeRedefaultLifetimePd();
        //    //var pdMapping = _pdMapping.ComputePdMappingTable();

        //    foreach (var loanbookRow in loanbookTable)
        //    {
        //        var contractPdMapping = pdMapping.FirstOrDefault(x => x.ContractId == loanbookRow.ContractId);
        //        if (contractPdMapping == null)
        //        {
        //            continue;
        //        }
        //        string contractPdGroup = contractPdMapping.PdGroup;
        //        int contractTtmMonths = contractPdMapping.TtmMonths;
        //        string impairedDate = null;
        //        if(loanbookRow.ImpairedDate != null)
        //        {
        //            impairedDate=loanbookRow.ImpairedDate.ToString().Contains("1900") ? null : loanbookRow.ImpairedDate.ToString();
        //        }
        //        string defaultDate = null;
        //        if(loanbookRow.DefaultDate!=null)
        //        {
        //            defaultDate = loanbookRow.DefaultDate.ToString().Contains("1900") ? null : loanbookRow.DefaultDate.ToString();
        //        }

        //        int maxClassification = contractPdMapping.MaxClassificationScore;
        //        long maxDpd = contractPdMapping.MaxDpd;

        //        var sicrRow = new SicrInputs();
        //        sicrRow.ContractId = loanbookRow.ContractId;
        //        sicrRow.Pd12Month = ComputeLifetimeAndRedefaultPds(lifetimePds, contractPdGroup, 12);
        //        sicrRow.LifetimePd = ComputeLifetimeAndRedefaultPds(lifetimePds, contractPdGroup, contractTtmMonths);
        //        sicrRow.RedefaultLifetimePd = ComputeLifetimeAndRedefaultPds(redefaultLifetimePds, contractPdGroup, contractTtmMonths);
        //        sicrRow.Stage1Transition = Math.Round(ComputeStageDaysPastDue(impairedDate));
        //        sicrRow.Stage2Transition = ComputeStageDaysPastDue(defaultDate);
        //        sicrRow.DaysPastDue = ComputeDaysPastDue(maxClassification, maxDpd);



        //        sicrInput.Add(sicrRow);
        //    }

        //    return sicrInput;
        //}

        public SicrInputs ComputeSICRInput(Loanbook_Data loanbookRow, PdMappings contractPdMapping, List <LifeTimeObject> lifetimePds, List <LifeTimeObject> redefaultLifetimePds)
        {
            string contractPdGroup   = contractPdMapping.PdGroup;
            int    contractTtmMonths = contractPdMapping.TtmMonths;
            string impairedDate      = null;

            if (loanbookRow.ImpairedDate != null)
            {
                impairedDate = loanbookRow.ImpairedDate.ToString().Contains("1900") ? null : loanbookRow.ImpairedDate.ToString();
            }
            string defaultDate = null;

            if (loanbookRow.DefaultDate != null)
            {
                defaultDate = loanbookRow.DefaultDate.ToString().Contains("1900") ? null : loanbookRow.DefaultDate.ToString();
            }

            int  maxClassification = contractPdMapping.MaxClassificationScore;
            long maxDpd            = contractPdMapping.MaxDpd;

            var sicrRow = new SicrInputs();

            //sicrRow.ContractId = loanbookRow.ContractId;
            sicrRow.Pd12Month           = ComputeLifetimeAndRedefaultPds(lifetimePds, contractPdGroup, 12);
            sicrRow.LifetimePd          = ComputeLifetimeAndRedefaultPds(lifetimePds, contractPdGroup, contractTtmMonths);
            sicrRow.RedefaultLifetimePd = ComputeLifetimeAndRedefaultPds(redefaultLifetimePds, contractPdGroup, contractTtmMonths);
            sicrRow.Stage1Transition    = int.Parse(Math.Round(ComputeStageDaysPastDue(impairedDate)).ToString());
            sicrRow.Stage2Transition    = int.Parse(Math.Round(ComputeStageDaysPastDue(defaultDate)).ToString());
            sicrRow.DaysPastDue         = ComputeDaysPastDue(maxClassification, maxDpd);

            return(sicrRow);
        }
Exemple #2
0
        private int ComputeForwardScore(SicrInputs sicrInputRecord, Loanbook_Data loanBookRecord, List <EclAssumptions> assumption)
        {
            var    currentRating           = loanBookRecord.CurrentRating ?? "";
            double currentCreditRankRating = string.IsNullOrWhiteSpace(currentRating) ? 1 : Convert.ToDouble(assumption.FirstOrDefault(o => o.AssumptionGroup == 6 && o.Value == currentRating).Key.Replace("CreditRatingRank", ""));// &&  Convert.ToDouble(GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.CreditRatingRank + currentRating.ToString()));

            double stage2to3creditRating = Convert.ToDouble(GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.CreditRatingDefaultIndicator));
            double stage1to2Forward      = Convert.ToDouble(GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.ForwardTransitionStage1to1));
            double stage2to3Forward      = Convert.ToDouble(GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.ForwardTransitionStage2to3));
            long   daysPastDue           = sicrInputRecord.DaysPastDue;

            if (currentCreditRankRating < stage2to3creditRating)
            {
                return(daysPastDue < stage1to2Forward ? 1 : (daysPastDue >= stage2to3Forward ? 3 : 2));
            }
            else
            {
                return(3);
            }
        }
Exemple #3
0
        private int ComputeStage(SicrInputs sicrInputRecord, Loanbook_Data loanBookRecord, List <EclAssumptions> assumption, string pdMapping)
        {
            int pdAbsoluteScore   = ComputePdAbsoluteScore(sicrInputRecord, loanBookRecord, assumption);
            int pdRelativeScore   = ComputePdRelativeScore(sicrInputRecord, loanBookRecord, assumption);
            int creditRatingScore = ComputeCreditRatingScore(loanBookRecord, assumption);
            int watchlistScore    = ComputeWatchlistIndicatorScore(loanBookRecord, assumption);
            int restructureScore  = ComputeRestructureIndicatorScore(loanBookRecord, assumption);
            int forwardScore      = ComputeForwardScore(sicrInputRecord, loanBookRecord, assumption);
            int backwardScore     = ComputeBackwardScore(sicrInputRecord, assumption);
            int expDefault        = ComputeExpDefaultScore(pdMapping);

            int maxScore1 = Math.Max(pdAbsoluteScore, pdRelativeScore);
            int maxScore2 = Math.Max(creditRatingScore, watchlistScore);
            int maxScore3 = Math.Max(forwardScore, backwardScore);
            int maxScore4 = Math.Max(restructureScore, expDefault);

            int maxScore5 = Math.Max(maxScore1, maxScore2);
            int maxScore6 = Math.Max(maxScore3, maxScore4);

            return(Math.Max(maxScore5, maxScore6));
        }
Exemple #4
0
        private int ComputePdAbsoluteScore(SicrInputs sicrInputRecord, Loanbook_Data loanBookRecord, List <EclAssumptions> assumption)
        {
            string absoluteType      = GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.AbsoluteCreditQualityCriteria);
            double absoluteThreshold = Convert.ToDouble(GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.AbsoluteCreditQualityThreshold));

            switch (absoluteType)
            {
            case FrameworkConstants.CreditQualityCriteriaLifetimePd:
                double sicrLifetimePd = sicrInputRecord.LifetimePd;
                double loanLifetimePd = loanBookRecord.LifetimePD ?? 0;

                return(((sicrLifetimePd - loanLifetimePd) > absoluteThreshold) ? 2 : 1);

            case FrameworkConstants.CreditQualityCriteria12MonthPd:
                double sicr12MonthPd = sicrInputRecord.Pd12Month;
                double loan12MonthPd = loanBookRecord.Month12PD ?? 0;

                return(((sicr12MonthPd - loan12MonthPd) > absoluteThreshold) ? 2 : 1);

            default:
                return(0);
            }
        }
Exemple #5
0
        private int ComputeBackwardScore(SicrInputs sicrInputRecord, List <EclAssumptions> assumption)
        {
            double stage2to1Backward = Convert.ToDouble(GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.BackwardTransitionsStage2to1));
            double stage3to2Backward = Convert.ToDouble(GetImpairmentAssumptionValue(assumption, ImpairmentRowKeys.BackwardTransitionsStage3to2));
            long   stage1Transition  = sicrInputRecord.Stage1Transition;
            long   stage2Transition  = sicrInputRecord.Stage2Transition;

            if (stage2Transition < stage3to2Backward && stage2Transition != 0)
            {
                return(3);
            }
            else
            {
                if ((stage1Transition < stage2to1Backward && stage1Transition != 0) || (stage2Transition < stage3to2Backward + stage2to1Backward && stage2Transition != 0))
                {
                    return(2);
                }
                else
                {
                    return(1);
                }
            }
        }