예제 #1
0
        //public static DataSet GetOverridableVariables(int projectId, string asOfDate = null)
        //{
        //    var folderInfo = new ModelFolderInfo(projectId, asOfDate);
        //    return m_nancy.GetOverridableVariables(folderInfo.YmlFolder, folderInfo.DsFolder);
        //}

        public static NancyStaticAnalysisResult RunStaticResultByPath(string cdr, string cpr, string path, string dsPath,
                                                                      AssetOverrideSetting assetOverrideSetting = null)
        {
            if (assetOverrideSetting == null)
            {
                assetOverrideSetting = new AssetOverrideSetting();
            }

            var result = m_nancy.RunStaticResultByPath(cdr, cpr, path, dsPath, assetOverrideSetting.PaymentDate.ToString("yyyy-MM-dd"),
                                                       assetOverrideSetting.IsOverride, assetOverrideSetting.Interest, assetOverrideSetting.Principal);

            var isCsdcDeal  = false;
            var ymlFilePath = Path.Combine(path, @"Script.yml");

            if (File.Exists(ymlFilePath))
            {
                using (StreamReader sr = new StreamReader(ymlFilePath))
                {
                    var nancyDealData = NancyUtils.GetNancyDealDataByFile(sr.BaseStream);
                    if (nancyDealData != null)
                    {
                        isCsdcDeal = nancyDealData.IsCsdcDeal;
                    }
                }
            }

            RunSpecialRules(result, isCsdcDeal);
            return(result);
        }
예제 #2
0
        public static DealSchedule GetDealSchedule(int projectId, string asOfDate = null, bool ignoreException = true)
        {
            try
            {
                var dbAdapter   = new DBAdapter();
                var rootFolder  = WebConfigUtils.RootFolder;
                var project     = dbAdapter.Project.GetProjectById(projectId);
                var modelFolder = Path.Combine(rootFolder, project.Model.ModelFolder);
                var ymlFilePath = modelFolder + @"\Script.yml";
                if (File.Exists(ymlFilePath))
                {
                    using (StreamReader sr = new StreamReader(ymlFilePath))
                    {
                        var dateFromYml = ReadYmlExInfo(sr);

                        var nancyDealData = NancyUtils.GetNancyDealDataByFile(sr.BaseStream);
                        if (nancyDealData != null)
                        {
                            var scheduleData = nancyDealData.ScheduleData;
                            var dealSchedule = new DealSchedule();
                            //第一个偿付期的计息区间起始日期就是起息日
                            dealSchedule.FirstAccrualDate   = scheduleData.ClosingDate;
                            dealSchedule.ClosingDate        = scheduleData.ClosingDate;
                            dealSchedule.LegalMaturity      = scheduleData.LegalMaturity;
                            dealSchedule.PaymentDates       = scheduleData.PaymentSchedule.Periods.Select(x => x.PaymentDate).ToArray();
                            dealSchedule.DeterminationDates = scheduleData.PaymentSchedule.Periods.Select(x => x.DeterminationDate).ToArray();

                            dealSchedule.FirstCollectionPeriodStartDate = dateFromYml.Item1.HasValue
                                ? dateFromYml.Item1.Value : scheduleData.PaymentSchedule.Periods.First().CollectionBegin;
                            dealSchedule.FirstCollectionPeriodEndDate = scheduleData.PaymentSchedule.Periods.First().CollectionEnd;

                            var scheduledPaymentDateArray = nancyDealData.ScheduleData.PaymentSchedule.Periods.Select(x => x.ScheduledPaymentDate).ToArray();
                            dealSchedule.NoteAccrualDates = new Dictionary <string, DateTime[]>();
                            nancyDealData.Notes.ForEach(x => dealSchedule.NoteAccrualDates[x.Name] = scheduledPaymentDateArray);

                            return(dealSchedule);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                if (ignoreException)
                {
                    return(null);
                }
                else
                {
                    throw e;
                }
            }

            return(null);
        }
예제 #3
0
        public static NancyStaticAnalysisResult GetStaticAnalyticsResult(int projectId, DataSet dsVariables = null,
                                                                         string asOfDate = null, AssetOverrideSetting assetOverrideSetting = null)
        {
            if (assetOverrideSetting == null)
            {
                assetOverrideSetting = new AssetOverrideSetting();
            }

            //if (dsVariables == null)
            //{
            //    dsVariables = GetOverridableVariables(projectId, asOfDate);
            //}

            var folderInfo = new ModelFolderInfo(projectId, asOfDate);
            //NancyMockUtils.SetOverridableVariables(dsVariables, folderInfo.DsFolder);

            var result = m_nancy.RunStaticResultByPath("0", "0", folderInfo.YmlFolder, folderInfo.DsFolder,
                                                       assetOverrideSetting.PaymentDate.ToString("yyyy-MM-dd"),
                                                       assetOverrideSetting.IsOverride, assetOverrideSetting.Interest, assetOverrideSetting.Principal);

            var isCsdcDeal  = false;
            var ymlFilePath = Path.Combine(folderInfo.YmlFolder, "Script.yml");

            if (File.Exists(ymlFilePath))
            {
                using (StreamReader sr = new StreamReader(ymlFilePath))
                {
                    var nancyDealData = NancyUtils.GetNancyDealDataByFile(sr.BaseStream);
                    if (nancyDealData != null)
                    {
                        isCsdcDeal = nancyDealData.IsCsdcDeal;
                    }
                }
            }

            RunSpecialRules(result, isCsdcDeal);

            return(result);
        }