예제 #1
0
        private List <CreditIndex_Output> ComputeCreditIndex()
        {
            var creditIndices = new List <CreditIndex_Output>();

            var indexForecastBest       = GetScenarioIndexForecasting(_indexForecastBest);
            var indexForecastOptimistic = GetScenarioIndexForecasting(_indexForecastOptimistics);
            var indexForecastDownturn   = GetScenarioIndexForecasting(_indexForecastDownturn);

            indexForecastBest       = indexForecastBest.OrderBy(o => o.Date).Take(24).ToList();
            indexForecastOptimistic = indexForecastOptimistic.OrderBy(o => o.Date).Take(24).ToList();
            indexForecastDownturn   = indexForecastDownturn.OrderBy(o => o.Date).Take(24).ToList();

            double vasicekIndexUsed = GetScenarioVasicekIndex();
            var    rpDate           = GetReportingDate(_eclType, _eclId);

            for (int month = 0; month <= _maxCreditIndexMonth; month++)
            {
                int monthOffset = Convert.ToInt32((month - 1) / 3) * 3 + 3;

                var eoMonth = ExcelFormulaUtil.EOMonth(rpDate, monthOffset);

                var dr = new CreditIndex_Output();
                dr.ProjectionMonth = month;

                //***************************************************
                double standard           = 0;
                var    _indexForecastBest = indexForecastBest.FirstOrDefault(o => o.Date == eoMonth);
                if (_indexForecastBest != null)
                {
                    standard = _indexForecastBest.Standardised;
                }

                dr.BestEstimate = month < 1 ? vasicekIndexUsed : standard;

                standard = 0;
                var _indexForecastOptimistic = indexForecastOptimistic.FirstOrDefault(o => o.Date == eoMonth);
                if (_indexForecastOptimistic != null)
                {
                    standard = _indexForecastOptimistic.Standardised;
                }

                dr.Optimistic = month < 1 ? vasicekIndexUsed : standard;


                standard = 0;
                var _indexForecastDownturn = indexForecastDownturn.FirstOrDefault(o => o.Date == eoMonth);
                if (_indexForecastDownturn != null)
                {
                    standard = _indexForecastDownturn.Standardised;
                }

                dr.Downturn = month < 3 ? vasicekIndexUsed : standard;

                creditIndices.Add(dr);
            }

            return(creditIndices);
        }
예제 #2
0
        protected int ComputeTimeToMaturityMonthsPerRecord(Loanbook_Data loanbookRecord, int expOdPerformacePastRepoting, int odPerformancePastExpiry)
        {
            if (loanbookRecord.ContractId.Substring(0, 3) == ECLStringConstants.i.ExpiredContractsPrefix)
            {
                return(0);
            }
            else
            {
                int xValue = 0;
                int yValue = 0;

                DateTime?endDate = new DateTime(1900, 01, 01);
                if (loanbookRecord.RestructureIndicator && loanbookRecord.RestructureEndDate != null)
                {
                    if (loanbookRecord.RestructureEndDate == null)
                    {
                        xValue = 0;
                    }
                    else
                    {
                        endDate = DateTime.Parse(loanbookRecord.RestructureEndDate.ToString());
                    }
                }
                else
                {
                    if (loanbookRecord.ContractEndDate == null)
                    {
                        xValue = 0;
                    }
                    else
                    {
                        endDate = DateTime.Parse(loanbookRecord.ContractEndDate.ToString());
                    }
                }

                var prod = 0;
                if (endDate != null && endDate != new DateTime(1900, 01, 01))
                {
                    if (!endDate.ToString().Contains("0001"))
                    {
                        var eomonth  = ExcelFormulaUtil.EOMonth(endDate);
                        var yearFrac = ExcelFormulaUtil.YearFrac(GetReportingDate(_eclType, _eclId), eomonth);
                        var round    = Convert.ToInt32(Math.Round(yearFrac * 12, 0));

                        var rptDate = GetReportingDate(_eclType, _eclId);
                        xValue = endDate > rptDate ? round : 0;

                        var maxx = Math.Max(expOdPerformacePastRepoting - round, 0);
                        prod = endDate < rptDate ? maxx : odPerformancePastExpiry;
                    }
                }
                loanbookRecord.ProductType = loanbookRecord.ProductType ?? "";
                yValue = loanbookRecord.ProductType.ToLower() == ECLStringConstants.i._productType_card.ToLower() || loanbookRecord.ProductType.ToLower() == ECLStringConstants.i._productType_od.ToLower() ? prod : 0;

                //Financial.YearFrac()
                return(xValue + yValue);
            }
        }