Example #1
0
        protected List <CreditIndex_Output> GetCreditRiskResult()
        {
            _creditIndex = new CreditIndex(this._eclId, this._eclType);
            var data = _creditIndex.GetCreditIndexResult();

            Log4Net.Log.Info($"LGD_CreditRiskResult");
            return(data);
        }
Example #2
0
 public ScenarioLifetimeLGD(Guid eclId, EclType eclType, ECL_Scenario _scenario)
 {
     this._eclId = eclId;
     // this._scenario = scenario;
     this._eclType               = eclType;
     _sicrInputs                 = new SicrInputWorkings(this._eclId, _eclType);
     _sicrWorkings               = new SicrWorkings(this._eclId, _eclType);
     _lifetimeEadWorkings        = new LifetimeEadWorkings(this._eclId, _eclType);
     _scenarioLifetimeCollateral = new ScenarioLifetimeCollateral(ECL_Scenario.Best, this._eclId, _eclType);
     _pdMapping   = new PDMapping(this._eclId, _eclType);
     _creditIndex = new CreditIndex(this._eclId, _eclType);
 }
Example #3
0
        public bool ProcessTask(List <Loanbook_Data> loanbooks)
        {
            try
            {
                // Compute Credit Index
                var crdIndx = new CreditIndex(this._eclId, this._eclType);
                crdIndx.Run();



                if (loanbooks.Count <= 1000) //1 !=1)//
                {
                    RunPDJob(loanbooks);
                }
                else
                {
                    //var checker = loanbooks.Count / 60;

                    var groupedLoanBook = new List <List <Loanbook_Data> >();
                    var threads         = loanbooks.Count / 500;
                    threads = threads + 1;

                    for (int i = 0; i < threads; i++)
                    {
                        var sub_items = loanbooks.Skip(i * 500).Take(500).ToList();
                        if (sub_items.Count > 0)
                        {
                            groupedLoanBook.Add(sub_items);
                        }
                    }

                    var allAccountsGrouped = false;

                    try
                    {
                        while (!allAccountsGrouped)
                        {
                            allAccountsGrouped = true;
                            for (int i = 1; i < groupedLoanBook.Count; i++)
                            {
                                var lstfromPrev = groupedLoanBook[i - 1].LastOrDefault();
                                var fstfromCurr = groupedLoanBook[i].FirstOrDefault();
                                if (lstfromPrev.AccountNo == fstfromCurr.AccountNo)
                                {
                                    groupedLoanBook[i - 1].Add(fstfromCurr);
                                    groupedLoanBook[i].RemoveAt(0);
                                    allAccountsGrouped = false;
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                    }

                    var taskLst = new List <Task>();

                    //threads = 1;
                    for (int i = 0; i < threads; i++)
                    {
                        var sub_LoanBook = groupedLoanBook[i];//.Skip(i * 500).Take(500).ToList();

                        var task = Task.Run(() =>
                        {
                            RunPDJob(sub_LoanBook);
                        });
                        taskLst.Add(task);
                    }
                    Log4Net.Log.Info($"Total Task : {taskLst.Count()}");

                    var completedTask = taskLst.Where(o => o.IsCompleted).Count();
                    Log4Net.Log.Info($"Task Completed: {completedTask}");

                    //while (!taskLst.Any(o => o.IsCompleted))
                    var tskStatusLst = new List <TaskStatus> {
                        TaskStatus.RanToCompletion, TaskStatus.Faulted
                    };
                    while (0 < 1)
                    {
                        if (taskLst.All(o => tskStatusLst.Contains(o.Status)))
                        {
                            break;
                        }
                        //Do Nothing
                    }
                    //Task t = Task.WhenAll(taskLst);

                    //try
                    //{
                    //    t.Wait();
                    //}
                    //catch (Exception ex)
                    //{
                    //    Log4Net.Log.Error(ex);
                    //}
                    //Log4Net.Log.Info($"All Task status: {t.Status}");

                    //if (t.Status == TaskStatus.RanToCompletion)
                    //{
                    //    Log4Net.Log.Info($"All Task ran to completion");
                    //}
                    //if (t.Status == TaskStatus.Faulted)
                    //{
                    //    Log4Net.Log.Info($"All Task ran to fault");
                    //}
                }


                // Compute Scenario Life time Pd -- best
                var _slt_Pd_b = new ScenarioLifetimePd(ECL_Scenario.Best, this._eclId, this._eclType);
                _slt_Pd_b.Run();

                // Compute Scenario Redefault Lifetime Pds  -- best
                var sRedefault_lt_pd_b = new ScenarioRedefaultLifetimePds(Util.ECL_Scenario.Best, this._eclId, this._eclType);
                sRedefault_lt_pd_b.Run();

                // Compute Scenario Life time Pd -- Optimistic
                var _slt_Pd_o = new ScenarioLifetimePd(ECL_Scenario.Optimistic, this._eclId, this._eclType);
                _slt_Pd_o.Run();

                // Compute Scenario Redefault Lifetime Pds  -- Optimistic
                var sRedefault_lt_pd_o = new ScenarioRedefaultLifetimePds(Util.ECL_Scenario.Optimistic, this._eclId, this._eclType);
                sRedefault_lt_pd_o.Run();



                // Compute Scenario Life time Pd -- Downturn
                var slt_Pd_de = new ScenarioLifetimePd(ECL_Scenario.Downturn, this._eclId, this._eclType);
                slt_Pd_de.Run();

                // Compute Scenario Redefault Lifetime Pds  -- Downturn
                var sRedefault_lt_pd_de = new ScenarioRedefaultLifetimePds(Util.ECL_Scenario.Downturn, this._eclId, this._eclType);
                sRedefault_lt_pd_de.Run();


                return(true);
            }
            catch (Exception ex)
            {
                Log4Net.Log.Error(ex);
                return(true);
            }
        }