public List <VasicekEtiNplIndex> ComputeVasicekScenario() { var vasicek = new List <VasicekEtiNplIndex>(); double pdTtc = ComputePdTtc(); double averageFittedIndex = ComputeVasicekAverageFitted(); var indexForecast = GetScenarioIndexForecastResult(); int month = 1; var ecls = Queries.EclsRegister(_eclType.ToString(), _eclId.ToString()); var dtR = DataAccess.i.GetData(ecls); var eclReg = new EclRegister { OrganizationUnitId = -1 }; if (dtR.Rows.Count > 0) { eclReg = DataAccess.i.ParseDataToObject(new EclRegister(), dtR.Rows[0]); } foreach (var row in indexForecast) { double scenarioPd = ComputeVasicekIndex(row.Standardised, pdTtc, ECLNonStringConstants.i.Rho(eclReg.OrganizationUnitId)); var dr = new VasicekEtiNplIndex(); dr.Date = row.Date; dr.Month = month; dr.ScenarioIndex = row.Standardised; dr.ScenarioPd = scenarioPd; dr.ScenarioFactor = averageFittedIndex == 0 ? 1 : scenarioPd / averageFittedIndex; vasicek.Add(dr); month++; } return(vasicek); }
public List <VasicekEtiNplIndex> ComputeEtiNplIndex() { var etiNpl = new ProcessECL_PD(this._eclId, this._eclType).Get_PDI_ETI_NPL(); var historicIndex = new ProcessECL_PD(this._eclId, this._eclType).Get_PDI_HistoricIndex(); historicIndex = historicIndex.OrderBy(o => o.Date).ToList(); double pdTtc = etiNpl.Take(32).Average(o => o.Series);// ComputePdTtc(); var vasicekEtiNplIndex = new List <VasicekEtiNplIndex>(); var ecls = Queries.EclsRegister(_eclType.ToString(), _eclId.ToString()); var dtR = DataAccess.i.GetData(ecls); var eclReg = new EclRegister { OrganizationUnitId = -1 }; if (dtR.Rows.Count > 0) { eclReg = DataAccess.i.ParseDataToObject(new EclRegister(), dtR.Rows[0]); } var rho = ECLNonStringConstants.i.Rho(eclReg.OrganizationUnitId); foreach (var etiNplRecord in etiNpl) { double index = 0; try { index = historicIndex.FirstOrDefault(o => o.Date == etiNplRecord.Date).Standardised; } catch { } var newRecord = new VasicekEtiNplIndex(); newRecord.Date = etiNplRecord.Date; newRecord.EtiNpl = etiNplRecord.Series; newRecord.Index = index; newRecord.Fitted = ComputeVasicekIndex(index, pdTtc, rho); newRecord.Residuals = etiNplRecord.Series - ComputeVasicekIndex(index, pdTtc, rho); vasicekEtiNplIndex.Add(newRecord); } vasicekEtiNplIndex = vasicekEtiNplIndex.OrderBy(o => o.Date).ToList(); return(vasicekEtiNplIndex); }