public void GetByLabelTest()
 {
     StaticDataBusiness target = new StaticDataBusiness(); // TODO: Initialize to an appropriate value
     SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value
     string strLabel = string.Empty; // TODO: Initialize to an appropriate value
     MA_PCCF expected = null; // TODO: Initialize to an appropriate value
     MA_PCCF actual;
     actual = target.GetByLabel(sessioninfo, strLabel);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
 public void CreatePCCFTest()
 {
     StaticDataBusiness target = new StaticDataBusiness(); // TODO: Initialize to an appropriate value
     SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value
     MA_PCCF pccf = null; // TODO: Initialize to an appropriate value
     MA_PCCF expected = null; // TODO: Initialize to an appropriate value
     MA_PCCF actual;
     actual = target.CreatePCCF(sessioninfo, pccf);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Пример #3
0
 public static object GetPCCFFXSpotByLabel(SessionInfo sessioninfo, string CCYPairLabel)
 {
     StaticDataBusiness _staticBusiness = new StaticDataBusiness();
     LookupBusiness _lookupBusiness = new LookupBusiness();
     var productID = _lookupBusiness.GetProductAll().FirstOrDefault(p => p.LABEL.Replace(" ", string.Empty) == ProductCode.FXSPOT.ToString()).ID;
     MA_PCCF pccf = _staticBusiness.GetPCCFByLabelProduct(sessioninfo, CCYPairLabel, productID);
     if (pccf != null)
     {
         return null;// new { CURRENCY1 = pccf.MA_CURRENCY1.LABEL, CURRENCY2 = pccf.MA_CURRENCY2.LABEL, CURRENCYID1 = pccf.MA_CURRENCY1.ID, CURRENCYID2 = pccf.MA_CURRENCY2.ID, FLAG_MULTIPLY = pccf.FLAG_MULTIPLY };
     }
     else {
         throw new Exception("Invalid currency pair.");
     }
 }
Пример #4
0
        public static object Create(SessionInfo sessioninfo, MA_PCCF record)
        {
            try
            {
                StaticDataBusiness _staticBusiness = new StaticDataBusiness();
                record.ID = Guid.NewGuid();

                //record.FLAG_MULTIPLY = record.FLAG_MULTIPLY == null || !record.FLAG_MULTIPLY.Value ? false : true;
                record.LABEL = record.LABEL.ToUpper();
                record.LOG.INSERTDATE = DateTime.Now;
                record.LOG.INSERTBYUSERID = sessioninfo.CurrentUserId;
                var added = _staticBusiness.CreatePCCF(sessioninfo, record);
                return new { Result = "OK", Record = added };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
Пример #5
0
        public static object GetPCCFByFilter(SessionInfo sessioninfo, string label, int jtStartIndex, int jtPageSize, string jtSorting)
        {
            try
            {
                StaticDataBusiness _staticBusiness = new StaticDataBusiness();

                //Get data from database
                List<MA_PCCF> pccfs = _staticBusiness.GetPCCFByFilter(sessioninfo, label, jtSorting);

                //Return result to jTable
                return new { Result = "OK",
                             Records = jtPageSize > 0 ? pccfs.Skip(jtStartIndex).Take(jtPageSize).ToList() : pccfs,
                             TotalRecordCount = pccfs.Count };
            }
            catch (BusinessWorkflowsException bex)
            {
                return new { Result = "ERROR", Message = bex.Message };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
 public void UpdatePCCFTest()
 {
     StaticDataBusiness target = new StaticDataBusiness(); // TODO: Initialize to an appropriate value
     SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value
     MA_PCCF pccf = null; // TODO: Initialize to an appropriate value
     target.UpdatePCCF(sessioninfo, pccf);
     Assert.Inconclusive("A method that does not return a value cannot be verified.");
 }
 public void StaticDataBusinessConstructorTest()
 {
     StaticDataBusiness target = new StaticDataBusiness();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }
 public void GetPCCFByFilterTest()
 {
     StaticDataBusiness target = new StaticDataBusiness(); // TODO: Initialize to an appropriate value
     SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value
     string label = string.Empty; // TODO: Initialize to an appropriate value
     int startIndex = 0; // TODO: Initialize to an appropriate value
     int count = 0; // TODO: Initialize to an appropriate value
     string sorting = string.Empty; // TODO: Initialize to an appropriate value
     List<MA_PCCF> expected = null; // TODO: Initialize to an appropriate value
     List<MA_PCCF> actual;
     actual = target.GetPCCFByFilter(sessioninfo, label, startIndex, count, sorting);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Пример #9
0
        /// <summary>
        /// Build Transation for Matching Deal between DMK Deal No. and OPICS Deal No.
        /// </summary>
        /// <param name="sessioninfo"></param>
        /// <param name="opicdeals"></param>
        /// <param name="deal"></param>
        /// <param name="UpdateDeals"></param>
        private static void BuildTransation(SessionInfo sessioninfo, List<DEALModel> opicdeals, 
            DA_TRN deal, ref List<DA_TRN> UpdateDeals)
        {
            ReconcileBusiness _reconcileBusiness = new ReconcileBusiness();
            StaticDataBusiness _staticdataBusiness = new StaticDataBusiness();
            DealBusiness _dealBusiness = new DealBusiness();
            CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
            InstrumentBusiness _instrumentBusiness = new InstrumentBusiness();
            List<DealTranModel> DealTrans = new List<DealTranModel>();

            DA_TRN newDeal = null;
            LoggingHelper.Debug("BuildTransation OPICS data and DMK deal");

            if (opicdeals != null)
            {
                bool flag = true;
                foreach (DEALModel opicdeal in opicdeals)
                {
                    flag = ValidateOPICS(opicdeal);
                    if( !flag ) break;
                }
                if (flag)
                {
                    //Begin transaction - Update DMK Deal No
                    deal.EXT_DEAL_NO = opicdeals[0].EXT_DEAL_NO;
                    deal.EXT_PORTFOLIO = opicdeals[0].EXT_PORTFOLIO;
                    deal.STATUS_ID = _lookupvaluesRepository.StatusRepository.GetByLabel(StatusCode.MATCHED.ToString()).ID;
                    deal.LOG.MODIFYBYUSERID = sessioninfo.CurrentUserId;
                    deal.LOG.MODIFYDATE = DateTime.Now;
                    deal.INSERT_BY_EXT = opicdeals[0].INSERT_BY_EXT;

                    ProductCode eProduct = (ProductCode)Enum.Parse(typeof(ProductCode), opicdeals[0].PRODUCT.Replace(" ", string.Empty));

                    //Update dealmaker data
                    DealTrans.Add(new DealTranModel() { UpdateStates = UpdateStates.Editing, Transaction = deal, ProductTransaction = eProduct });

                    //Create DMK Deal from OPICS Deal
                    foreach (DEALModel opicdeal in opicdeals)
                    {
                        newDeal = GenerateTrnObject(sessioninfo, opicdeal, deal, sessioninfo.Process.NextDate);

                        //Import Opics transaction
                        DealTrans.Add(new DealTranModel() { UpdateStates = UpdateStates.Adding, Transaction = newDeal, ProductTransaction = eProduct });
                    }
                    //Update transaction
                    _reconcileBusiness.UpdateDealReconcile(sessioninfo, DealTrans);
                }
            }
        }
Пример #10
0
        public static object GetPCCFOptions(SessionInfo sessioninfo)
        {
            try
            {
                StaticDataBusiness _staticBusiness = new StaticDataBusiness();
                //Get data from database
                var pccfs = _staticBusiness.GetPCCFAll().Where(t => t.ISACTIVE == true);

                //Return result to jTable
                return new { Result = "OK", Options = pccfs.OrderBy(t => t.LABEL).Select(c => new { DisplayText = c.LABEL, Value = c.ID }) };
            }
            catch (Exception ex)
            {
                return new { Result = "ERROR", Message = ex.Message };
            }
        }
Пример #11
0
        public List<RepoReportModel> GetRepoReport(SessionInfo sessioninfo, string strReportDate, string strSource, string strCtpy)
        {
            try
            {
                DateTime dteReport;
                LimitCheckBusiness _limitBusiness = new LimitCheckBusiness();
                DealBusiness _dealBusiness = new DealBusiness();
                LimitProductBusiness _limitProductBusiness = new LimitProductBusiness();
                LookupBusiness _lookupBusiness = new LookupBusiness();
                StaticDataBusiness _staticBusiness = new StaticDataBusiness();
                List<RepoReportModel> reports = new List<RepoReportModel>();
                RepoReportModel report;
                Guid guCtpyID = Guid.Empty;

                if (String.IsNullOrEmpty(strReportDate))
                    throw this.CreateException(new Exception(), "Please input report date.");
                else if (!DateTime.TryParseExact(strReportDate, "dd/MM/yyyy", null, DateTimeStyles.None, out dteReport))
                    throw this.CreateException(new Exception(), "Invalid report date.");
                else
                    dteReport = DateTime.ParseExact(strReportDate, "dd/MM/yyyy", null);

                if (Guid.TryParse(strCtpy, out guCtpyID))
                {
                    guCtpyID = Guid.Parse(strCtpy);
                }

                Guid guProductID = _lookupBusiness.GetProductByUsercode(ProductCode.REPO.ToString()).ID;
                MA_PCCF rev_pccf = _staticBusiness.GetPCCFByID(sessioninfo, Guid.Parse("84f608c9-8b58-48eb-a6dd-a5407548784a"));
                MA_PCCF rep_gov_pccf = _staticBusiness.GetPCCFByID(sessioninfo, Guid.Parse("28b24b19-e81d-4f82-a2f0-7c834ee3f91c"));
                MA_PCCF rep_soe_pccf = _staticBusiness.GetPCCFByID(sessioninfo, Guid.Parse("7014b05e-198f-4f62-94b0-1d54322efbca"));

                var limits = _limitBusiness.GetPCEByCriteria(dteReport, guCtpyID, guProductID, strSource, Guid.Empty, Guid.Empty).Distinct(new LimitCheckComparer()).ToList();

                foreach (LimitCheckModel limit in limits)
                {
                    report = new RepoReportModel();

                    report.PROCESSING_DATE = limit.PROCESSING_DATE;
                    report.SNAME = limit.SNAME;
                    report.LIMIT_LABEL = limit.LIMIT_LABEL;
                    report.GEN_AMOUNT = limit.GEN_AMOUNT;
                    report.TEMP_AMOUNT = limit.TEMP_AMOUNT;
                    //report.AMOUNT = limit.AMOUNT;
                    report.EXPIRE_DATE = limit.EXPIRE_DATE;
                    report.ORIGINAL_KK_CONTRIBUTE = limit.ORIGINAL_KK_CONTRIBUTE;
                    report.DEAL_CONTRIBUTION = 0;
                    report.REV_AMOUNT = report.AVAILABLE / rev_pccf.C1.Value * 100;
                    report.REP_GOV_5_AMOUNT = report.AVAILABLE / rep_gov_pccf.C5.Value * 100;
                    report.REP_GOV_10_AMOUNT = report.AVAILABLE / rep_gov_pccf.C10.Value * 100;
                    report.REP_GOV_20_AMOUNT = report.AVAILABLE / rep_gov_pccf.C20.Value * 100;
                    report.REP_GOV_20s_AMOUNT = report.AVAILABLE / rep_gov_pccf.more20.Value * 100;
                    report.REP_SOE_5_AMOUNT = report.AVAILABLE / rep_soe_pccf.C5.Value * 100;
                    report.REP_SOE_10_AMOUNT = report.AVAILABLE / rep_soe_pccf.C10.Value * 100;
                    report.REP_SOE_20_AMOUNT = report.AVAILABLE / rep_soe_pccf.C20.Value * 100;
                    report.REP_SOE_20s_AMOUNT = report.AVAILABLE / rep_soe_pccf.more20.Value * 100;

                    reports.Add(report);
                }

                return reports;
            }

            catch (DataServicesException ex)
            {
                throw this.CreateException(ex, null);
            }
        }
Пример #12
0
        //public LimitDisplayModel CheckPCE(SessionInfo sessioninfo, DA_TRN trn)
        //{
        //    StaticDataBusiness _staticDataBusiness = new StaticDataBusiness();
        //    LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness();
        //    LimitDisplayModel limitDisplay = new LimitDisplayModel();
        //    trn.KK_PCCF = _staticDataBusiness.GetPCCF(sessioninfo, trn);
        //    if (trn.KK_PCCF != null)
        //    {
        //        trn.KK_CONTRIBUTE = Math.Ceiling(trn.NOTIONAL_THB.Value * trn.KK_PCCF.Value / 100);
        //        List<LimitCheckModel> limits = _limitCheckBusiness.GetPCEByCriteria(sessioninfo.Process.CurrentDate, trn.CTPY_ID, trn.PRODUCT_ID.Value, "", Guid.Empty, Guid.Empty);
        //        foreach (LimitCheckModel limit in limits)
        //        {
        //            limit.DEAL_CONTRIBUTION = trn.KK_CONTRIBUTE.Value;
        //            SetLimitDisplayStatus(limit, ref limitDisplay);
        //        }
        //        limitDisplay.LimitDisplayObject = limits;
        //    }
        //    else
        //    {
        //        limitDisplay.LimitCheckStatus = eLimitCheckStatus.NOTALLOW;
        //        limitDisplay.LimitErrorObj = new { Result = "ERROR", Message = "This deal breach allowed tenor." };
        //    }
        //    return limitDisplay;
        //}
        public LimitDisplayModel CheckPCE(SessionInfo sessioninfo, DA_TRN trn, string strExcludeID)
        {
            StaticDataBusiness _staticDataBusiness = new StaticDataBusiness();
            LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness();
            LimitDisplayModel limitDisplay = new LimitDisplayModel();
            Guid guExcludeID = Guid.Empty;

            trn.KK_PCCF = _staticDataBusiness.GetPCCF(sessioninfo, trn);

            //Find original deal for exclude it from limit calculation
            if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID))
                guExcludeID = Guid.Parse(strExcludeID.Replace("\"", ""));

            if (trn.KK_PCCF != null)
            {
                trn.KK_CONTRIBUTE = Math.Ceiling(trn.NOTIONAL_THB.Value * trn.KK_PCCF.Value / 100);

                List<LimitCheckModel> limits = _limitCheckBusiness.CheckAllPCE(sessioninfo.Process.CurrentDate, trn, guExcludeID, Guid.Empty);

                foreach (LimitCheckModel limit in limits)
                {
                    limit.DEAL_CONTRIBUTION = trn.KK_CONTRIBUTE.Value;
                    SetLimitDisplayStatus(limit, sessioninfo.PCEOverwrite, ref limitDisplay);
                }

                if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE)
                    trn.OVER_AMOUNT = limitDisplay.OverAmount;

                limitDisplay.LimitDisplayObject = limits;
            }
            else
            {
                limitDisplay.LimitCheckStatus = eLimitCheckStatus.ERROR;
                limitDisplay.Message = "This deal breach allowed tenor.";
            }

            return limitDisplay;
        }
Пример #13
0
        public string SubmitFXDeal(SessionInfo sessioninfo
										 , DA_TRN trn
										 , string strOverApprover
										 , string strOverComment
										 , string strProductId)
        {
            StaticDataBusiness _staticdataBusiness = new StaticDataBusiness();
             LookupBusiness _lookupBusiness = new LookupBusiness();
             if (!String.IsNullOrEmpty(strOverApprover))
             {
                 trn.OVER_APPROVER = strOverApprover;
                 trn.OVER_COMMENT = strOverComment;
             }

             using (EFUnitOfWork unitOfWork = new EFUnitOfWork())
             {
                 Guid guTemp;
                 if (Guid.TryParse(strProductId, out guTemp))
                 {
                     var foundDeal = unitOfWork.DA_TRNRepository.All().FirstOrDefault(p => p.ID == guTemp);
                     if (foundDeal == null)
                         throw this.CreateException(new Exception(), "Data not found!");
                     else
                     {
                         foundDeal.STATUS_ID = _lookupBusiness.GetStatusAll().FirstOrDefault(p => p.LABEL == StatusCode.CANCELLED.ToString()).ID;
                         foundDeal.REMARK = trn.REMARK;
                     }
                 }
                 trn.REMARK = null;
                 if (trn.INT_DEAL_NO == null)
                     trn.INT_DEAL_NO = GetNewDealNo(sessioninfo.Process.CurrentDate);
                 unitOfWork.DA_TRNRepository.Add(trn);
                 unitOfWork.Commit();
             }
             return trn.INT_DEAL_NO;
        }
Пример #14
0
        public LimitDisplayModel CheckFXSwapPCE(SessionInfo sessioninfo, DA_TRN trn1, DA_TRN trn2, string strExcludeID)
        {
            StaticDataBusiness _staticDataBusiness = new StaticDataBusiness();
            LimitCheckBusiness _limitCheckBusiness = new LimitCheckBusiness();
            LimitDisplayModel limitDisplay = new LimitDisplayModel();
            DA_TRN oldtrn1 = null;
            DA_TRN oldtrn2 = null;
            Guid guExcludeID1 = Guid.Empty;
            Guid guExcludeID2 = Guid.Empty;

            //Exposure include far leg only -> set near leg to 0
            trn1.KK_PCCF = 0;
            trn2.KK_PCCF = _staticDataBusiness.GetPCCF(sessioninfo, trn2);

            //Find original deals for exclude them from limit calculation
            if (strExcludeID != null && Guid.TryParse(strExcludeID.Replace("\"", ""), out guExcludeID1))
            {
                guExcludeID1 = Guid.Parse(strExcludeID.Replace("\"", ""));

                oldtrn1 = GetByID(guExcludeID1);
                oldtrn2 = GetDealByProcessDate(sessioninfo.Process.CurrentDate).FirstOrDefault(p => p.INT_DEAL_NO == oldtrn1.INT_DEAL_NO && p.VERSION == oldtrn1.VERSION && p.ID != oldtrn1.ID);

                if (oldtrn2 == null || oldtrn1 == null)
                    throw this.CreateException(new Exception(), "Cannot find original deals.");

                guExcludeID1 = oldtrn1.ID;
                guExcludeID2 = oldtrn2.ID;
            }

            if (trn1.KK_PCCF != null && trn2.KK_PCCF != null)
            {
                trn1.KK_CONTRIBUTE = 0;
                trn2.KK_CONTRIBUTE = Math.Ceiling(trn2.NOTIONAL_THB.Value * trn2.KK_PCCF.Value / 100);

                List<LimitCheckModel> limits = _limitCheckBusiness.CheckAllPCE(sessioninfo.Process.CurrentDate, trn1, guExcludeID1, guExcludeID2);

                foreach (LimitCheckModel limit in limits)
                {
                    limit.DEAL_CONTRIBUTION = trn1.KK_CONTRIBUTE.Value + trn2.KK_CONTRIBUTE.Value;
                    SetLimitDisplayStatus(limit, sessioninfo.PCEOverwrite, ref limitDisplay);
                }

                if (limitDisplay.LimitCheckStatus == eLimitCheckStatus.NEEDAPPROVE)
                {
                    trn1.OVER_AMOUNT = limitDisplay.OverAmount;
                    trn2.OVER_AMOUNT = limitDisplay.OverAmount;
                }

                limitDisplay.LimitDisplayObject = limits;
            }
            else
            {
                limitDisplay.LimitCheckStatus = eLimitCheckStatus.ERROR;
                limitDisplay.Message = "This deal breach allowed tenor.";
            }

            return limitDisplay;
        }
Пример #15
0
        /// <summary>
        /// Generate DA_TRN object from Opics Transaction
        /// </summary>
        /// <param name="sessioninfo"></param>
        /// <param name="opicdeal"></param>
        /// <param name="processdate"></param>
        private static DA_TRN GenerateTrnObject(SessionInfo sessioninfo, DEALModel opicdeal, DA_TRN dmkDeal, DateTime processdate)
        {
            StaticDataBusiness _staticdataBusiness = new StaticDataBusiness();
            CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
            InstrumentBusiness _instrumentBusiness = new InstrumentBusiness();
            LookupBusiness _lookupBusiness = new LookupBusiness();

            LoggingHelper.Debug("Generate transaction object : " + opicdeal.EXT_DEAL_NO);
            DA_TRN newDeal = CreateDealTemplate(sessioninfo);
            try
            {

            newDeal.ENGINE_DATE = processdate;
            newDeal.STATUS_ID = _lookupvaluesRepository.StatusRepository.GetByLabel(StatusCode.MATCHED.ToString()).ID;
            newDeal.PRODUCT_ID = _lookupvaluesRepository.ProductRepository.GetByLabel(opicdeal.PRODUCT.Trim()).ID;
            //newDeal.INT_DEAL_NO = dmkNo;
            newDeal.EXT_DEAL_NO = opicdeal.EXT_DEAL_NO;
            //newDeal.VERSION = 1;
            newDeal.SOURCE = SourceType.EXT.ToString();
            newDeal.CTPY_ID = _counterpartyBusiness.GetByUsercode(Convert.ToInt32(opicdeal.CPTY.Trim())).ID;
            newDeal.EXT_PORTFOLIO = opicdeal.EXT_PORTFOLIO;
            newDeal.FLAG_BUYSELL = opicdeal.BUY_SELL;
            if (!String.IsNullOrEmpty(opicdeal.PORTFOLIO.Trim()))
                newDeal.PORTFOLIO_ID = _lookupvaluesRepository.PortfolioRepository.GetByLabel(opicdeal.PORTFOLIO.Trim()).ID;
            newDeal.START_DATE = opicdeal.START_DATE;
            newDeal.MATURITY_DATE = opicdeal.MATURITY_DATE;
            newDeal.TRADE_DATE = opicdeal.TRADE_DATE;
            newDeal.INSERT_BY_EXT = opicdeal.INSERT_BY_EXT;
            newDeal.FLAG_SETTLE = dmkDeal != null && dmkDeal.FLAG_SETTLE != null ? dmkDeal.FLAG_SETTLE : opicdeal.FLAG_SETTLE == 1 ? true : false;

            if (dmkDeal != null)
            {
                newDeal.INT_DEAL_NO = dmkDeal.INT_DEAL_NO;
                newDeal.VERSION = dmkDeal.VERSION;
                newDeal.REMARK = dmkDeal.REMARK + " " + opicdeal.REMARK;

                newDeal.LOG.INSERTDATE = dmkDeal.LOG.INSERTDATE;
                newDeal.LOG.INSERTBYUSERID = dmkDeal.LOG.INSERTBYUSERID;

                //newDeal.FLAG_SETTLE = dmkDeal.FLAG_SETTLE;
                newDeal.OVER_AMOUNT = dmkDeal.OVER_AMOUNT;
                newDeal.OVER_APPROVER = dmkDeal.OVER_APPROVER;
                newDeal.OVER_COMMENT = dmkDeal.OVER_COMMENT;
                newDeal.OVER_SETTL_AMOUNT = dmkDeal.OVER_SETTL_AMOUNT;
            }
            else
            {
                newDeal.VERSION = 1;
            }

            var spotrate = _lookupBusiness.GetSpotRateAll().AsQueryable();
            MA_SPOT_RATE firstrate = new MA_SPOT_RATE();
            MA_SPOT_RATE secondRate = new MA_SPOT_RATE();

            switch ((ProductCode)Enum.Parse(typeof(ProductCode), opicdeal.PRODUCT.Replace(" ", string.Empty)))
            {
                case ProductCode.BOND:
                    newDeal.INSTRUMENT_ID = _instrumentBusiness.GetByLabel(sessioninfo, opicdeal.INSTRUMENT.Trim()).ID;

                    //First only
                    if (!String.IsNullOrEmpty(opicdeal.CCY1))
                        newDeal.FIRST.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY1).ID;
                    newDeal.FIRST.NOTIONAL = opicdeal.NOTIONAL1;

                    //THB Notional
                    var firstRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.FIRST.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);

                    if (firstRate != null)
                    {
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE);
                    }
                    else
                    {
                        throw new UIPException(new Exception(), "Error : There is no " + opicdeal.CCY1 + " spot rate on " + newDeal.TRADE_DATE.Value.ToString(FormatTemplate.DATE_DMY_LABEL));
                    }
                    newDeal.FLAG_PCE = dmkDeal != null && dmkDeal.FLAG_PCE != null ? dmkDeal.FLAG_PCE : false;

                    newDeal.KK_PCCF = _staticdataBusiness.GetPCCF(sessioninfo, newDeal);
                    newDeal.KK_CONTRIBUTE = Math.Ceiling(newDeal.NOTIONAL_THB.Value * newDeal.KK_PCCF.Value / 100);

                    break;
                case ProductCode.REPO:
                    newDeal.INSTRUMENT_ID = _instrumentBusiness.GetByLabel(sessioninfo, opicdeal.INSTRUMENT.Trim()).ID;

                    //First only
                    if (!String.IsNullOrEmpty(opicdeal.CCY1))
                        newDeal.FIRST.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY1).ID;
                    newDeal.FIRST.NOTIONAL = newDeal.NOTIONAL_THB = opicdeal.NOTIONAL1;

                    newDeal.KK_PCCF = _staticdataBusiness.GetPCCF(sessioninfo, newDeal);
                    newDeal.KK_CONTRIBUTE = Math.Ceiling(newDeal.NOTIONAL_THB.Value * newDeal.KK_PCCF.Value / 100);

                    break;
                case ProductCode.SWAP:
                    newDeal.INSTRUMENT_ID = _instrumentBusiness.GetByLabel(sessioninfo, opicdeal.INSTRUMENT.Trim()).ID;

                    //First and Second
                    if (!String.IsNullOrEmpty(opicdeal.CCY1))
                        newDeal.FIRST.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY1).ID;

                    if (!String.IsNullOrEmpty(opicdeal.FREQ1))
                        newDeal.FIRST.FREQTYPE_ID = _lookupvaluesRepository.FrequencyRepository.GetByUsercode(opicdeal.FREQ1).ID;

                    newDeal.FIRST.FIRSTFIXINGAMT = opicdeal.FIRST_FIXING1;
                    newDeal.FIRST.FLAG_FIXED = opicdeal.FIXED_FLOAT1 == CouponType.FIXED.ToString() ? true : false;
                    newDeal.FIRST.FLAG_PAYREC = opicdeal.PAY_REC1;
                    newDeal.FIRST.NOTIONAL = newDeal.NOTIONAL_THB = opicdeal.NOTIONAL1;
                    newDeal.FIRST.RATE = opicdeal.RATE1;

                    //Second
                    if (!String.IsNullOrEmpty(opicdeal.CCY2))
                        newDeal.SECOND.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY2).ID;

                    if (!String.IsNullOrEmpty(opicdeal.FREQ2))
                        newDeal.SECOND.FREQTYPE_ID = _lookupvaluesRepository.FrequencyRepository.GetByUsercode(opicdeal.FREQ2).ID;

                    newDeal.SECOND.FIRSTFIXINGAMT = opicdeal.FIRST_FIXING2;
                    newDeal.SECOND.FLAG_FIXED = opicdeal.FIXED_FLOAT2 == CouponType.FIXED.ToString() ? true : false;
                    newDeal.SECOND.FLAG_PAYREC = opicdeal.PAY_REC2;
                    newDeal.SECOND.NOTIONAL = opicdeal.NOTIONAL2;
                    newDeal.SECOND.RATE = opicdeal.RATE2;

                    //THB Notional
                    if (opicdeal.CCY1 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value);
                    else if (opicdeal.CCY2 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value);
                    else
                    {
                        firstRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.FIRST.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);
                        secondRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.SECOND.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);

                        if (firstRate != null && secondRate != null)
                        {
                            if (Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE) > Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE))
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE);
                            else
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE);
                        }
                        else
                        {
                            string mess = string.Empty;
                            mess += firstRate == null ? opicdeal.CCY1 : string.Empty;
                            mess += secondRate == null ? (mess != string.Empty ? " and " + opicdeal.CCY2 : opicdeal.CCY2) : string.Empty;
                            throw new UIPException(new Exception(), "Error : There is no " + mess + " spot rate on " + newDeal.TRADE_DATE.Value.ToString(FormatTemplate.DATE_DMY_LABEL));
                        }
                    }

                    newDeal.KK_PCCF = _staticdataBusiness.GetPCCF(sessioninfo, newDeal);
                    newDeal.KK_CONTRIBUTE = Math.Ceiling(newDeal.NOTIONAL_THB.Value * newDeal.KK_PCCF.Value / 100);

                    //newDeal.BOT_PCCF = _staticdataBusiness.GetSwapBOTPCCF(sessioninfo, newDeal);
                    //newDeal.BOT_CONTRIBUTE = Math.Ceiling(newDeal.NOTIONAL_THB.Value * newDeal.BOT_PCCF.Value / 100);

                    break;
                case ProductCode.FXSPOT:
                    newDeal.INSTRUMENT_ID = _instrumentBusiness.GetFXInstrumentByCCY(sessioninfo, ProductCode.FXSPOT, opicdeal.CCY1, opicdeal.CCY2).ID;

                    if (!String.IsNullOrEmpty(opicdeal.CCY1))
                        newDeal.FIRST.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY1).ID;
                    newDeal.FIRST.FLAG_PAYREC = opicdeal.PAY_REC1;
                    newDeal.FIRST.NOTIONAL = opicdeal.NOTIONAL1;
                    newDeal.FIRST.RATE = opicdeal.RATE1;

                    if (!String.IsNullOrEmpty(opicdeal.CCY2))
                        newDeal.SECOND.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY2).ID;
                    newDeal.SECOND.FLAG_PAYREC = opicdeal.PAY_REC2;
                    newDeal.SECOND.NOTIONAL = opicdeal.NOTIONAL2;

                    //THB Notional
                    if (opicdeal.CCY1 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value);
                    else if (opicdeal.CCY2 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value);
                    else
                    {
                        firstRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.FIRST.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);
                        secondRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.SECOND.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);

                        if (firstRate != null && secondRate != null)
                        {
                            if (Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE) > Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE))
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE);
                            else
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE);
                        }
                        else
                        {
                            string mess = string.Empty;
                            mess += firstRate == null ? opicdeal.CCY1 : string.Empty;
                            mess += secondRate == null ? (mess != string.Empty ? " and " + opicdeal.CCY2 : opicdeal.CCY2) : string.Empty;
                            throw new UIPException(new Exception(), "Error : There is no " + mess + " spot rate on " + newDeal.TRADE_DATE.Value.ToString(FormatTemplate.DATE_DMY_LABEL));
                        }
                    }

                    newDeal.KK_PCCF = _staticdataBusiness.GetPCCF(sessioninfo, newDeal);
                    newDeal.KK_CONTRIBUTE = Math.Ceiling(newDeal.NOTIONAL_THB.Value * newDeal.KK_PCCF.Value / 100);

                    break;

                case ProductCode.FXFORWARD:
                    newDeal.INSTRUMENT_ID = _instrumentBusiness.GetFXInstrumentByCCY(sessioninfo, ProductCode.FXFORWARD, opicdeal.CCY1, opicdeal.CCY2).ID;
                    newDeal.START_DATE = dmkDeal != null ? dmkDeal.START_DATE : opicdeal.START_DATE;

                    if (!String.IsNullOrEmpty(opicdeal.CCY1))
                        newDeal.FIRST.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY1).ID;
                    newDeal.FIRST.FLAG_PAYREC = opicdeal.PAY_REC1;
                    newDeal.FIRST.NOTIONAL = opicdeal.NOTIONAL1;
                    newDeal.FIRST.RATE = opicdeal.RATE1;
                    newDeal.FIRST.SWAP_POINT = opicdeal.SWAP_POINT1;

                    if (!String.IsNullOrEmpty(opicdeal.CCY2))
                        newDeal.SECOND.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY2).ID;
                    newDeal.SECOND.FLAG_PAYREC = opicdeal.PAY_REC2;
                    newDeal.SECOND.NOTIONAL = opicdeal.NOTIONAL2;
                    newDeal.SECOND.SWAP_POINT = opicdeal.SWAP_POINT2;

                    //THB Notional
                    if (opicdeal.CCY1 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value);
                    else if (opicdeal.CCY2 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value);
                    else
                    {
                        firstRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.FIRST.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);
                        secondRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.SECOND.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);

                        if (firstRate != null && secondRate != null)
                        {
                            if (Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE) > Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE))
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE);
                            else
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE);
                        }
                        else
                        {
                            string mess = string.Empty;
                            mess += firstRate == null ? opicdeal.CCY1 : string.Empty;
                            mess += secondRate == null ? (mess != string.Empty ? " and " + opicdeal.CCY2 : opicdeal.CCY2) : string.Empty;
                            throw new UIPException(new Exception(), "Error : There is no " + mess + " spot rate on " + newDeal.TRADE_DATE.Value.ToString(FormatTemplate.DATE_DMY_LABEL));
                        }
                    }

                    newDeal.SPOT_DATE = opicdeal.SPOT_DATE;

                    newDeal.KK_PCCF = _staticdataBusiness.GetPCCF(sessioninfo, newDeal);
                    newDeal.KK_CONTRIBUTE = Math.Ceiling(newDeal.NOTIONAL_THB.Value * newDeal.KK_PCCF.Value / 100);

                    break;

                case ProductCode.FXSWAP:
                    newDeal.INSTRUMENT_ID = _instrumentBusiness.GetFXInstrumentByCCY(sessioninfo, ProductCode.FXSWAP, opicdeal.CCY1, opicdeal.CCY2).ID;
                    newDeal.FLAG_NEARFAR = opicdeal.FLAG_NEARFAR;
                    newDeal.START_DATE = dmkDeal != null ? dmkDeal.START_DATE : opicdeal.START_DATE;

                    if (!String.IsNullOrEmpty(opicdeal.CCY1))
                        newDeal.FIRST.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY1).ID;
                    newDeal.FIRST.FLAG_PAYREC = opicdeal.PAY_REC1;
                    newDeal.FIRST.NOTIONAL = opicdeal.NOTIONAL1;
                    newDeal.FIRST.RATE = opicdeal.RATE1;
                    newDeal.FIRST.SWAP_POINT = opicdeal.SWAP_POINT1;

                    if (!String.IsNullOrEmpty(opicdeal.CCY2))
                        newDeal.SECOND.CCY_ID = _lookupvaluesRepository.CurrencyRepository.GetByLabel(opicdeal.CCY2).ID;
                    newDeal.SECOND.FLAG_PAYREC = opicdeal.PAY_REC2;
                    newDeal.SECOND.NOTIONAL = opicdeal.NOTIONAL2;
                    newDeal.SECOND.SWAP_POINT = opicdeal.SWAP_POINT2;

                    //THB Notional
                    if (opicdeal.CCY1 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value);
                    else if (opicdeal.CCY2 == "THB")
                        newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value);
                    else
                    {
                        firstRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.FIRST.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);
                        secondRate = spotrate.FirstOrDefault(p => p.CURRENCY_ID == newDeal.SECOND.CCY_ID && p.PROC_DATE == newDeal.TRADE_DATE);

                        if (firstRate != null && secondRate != null)
                        {
                            if (Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE) > Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE))
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.FIRST.NOTIONAL.Value * firstRate.RATE);
                            else
                                newDeal.NOTIONAL_THB = Math.Abs(newDeal.SECOND.NOTIONAL.Value * secondRate.RATE);
                        }
                        else
                        {
                            string mess = string.Empty;
                            mess += firstRate == null ? opicdeal.CCY1 : string.Empty;
                            mess += secondRate == null ? (mess != string.Empty ? " and " + opicdeal.CCY2 : opicdeal.CCY2) : string.Empty;
                            throw new UIPException(new Exception(), "Error : There is no " + mess + " spot rate on " + newDeal.TRADE_DATE.Value.ToString(FormatTemplate.DATE_DMY_LABEL));
                        }
                    }

                    newDeal.SPOT_DATE = opicdeal.SPOT_DATE;

                    //Exposure include far leg only -> set near leg to 0
                    if (newDeal.FLAG_NEARFAR == "N")
                    {
                        newDeal.KK_PCCF = 0;
                        newDeal.KK_CONTRIBUTE = 0;
                    }
                    else
                    {
                        newDeal.KK_PCCF = _staticdataBusiness.GetPCCF(sessioninfo, newDeal);
                        newDeal.KK_CONTRIBUTE = Math.Ceiling(newDeal.NOTIONAL_THB.Value * newDeal.KK_PCCF.Value / 100);
                    }

                    break;
                default:
                    throw new UIPException(new Exception(), String.Format("The product is not defined in the OPICS deal no {0}.", opicdeal.EXT_DEAL_NO));
            }
            }

            catch (Exception ex)
            {
                throw new UIPException(new Exception(), ex.Message);
            }
            return newDeal;
        }
Пример #16
0
 public void GetFIPCCFTest()
 {
     StaticDataBusiness target = new StaticDataBusiness(); // TODO: Initialize to an appropriate value
     SessionInfo sessioninfo = null; // TODO: Initialize to an appropriate value
     Guid guID = new Guid(); // TODO: Initialize to an appropriate value
     DateTime dteStart = new DateTime(); // TODO: Initialize to an appropriate value
     Decimal expected = new Decimal(); // TODO: Initialize to an appropriate value
     Decimal actual;
     actual = target.GetFIPCCF(sessioninfo, guID, dteStart);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
Пример #17
0
        /// <summary>
        /// Import Passed for OPICS Deal to DA_TRN table
        /// </summary>
        /// <param name="sessioninfo"></param>
        /// <param name="opicdeal"></param>
        private static void ImportPassedOPICSDeal(SessionInfo sessioninfo, DEALModel opicdeal, DateTime processdate, ref List<DealTranModel> DealTrans)
        {
            StaticDataBusiness _staticdataBusiness = new StaticDataBusiness();
            DealBusiness _dealBusiness = new DealBusiness();
            CounterpartyBusiness _counterpartyBusiness = new CounterpartyBusiness();
            InstrumentBusiness _instrumentBusiness = new InstrumentBusiness();

            DA_TRN pastimported = _dealBusiness.GetPastImportedDealsByExtNo(opicdeal.EXT_DEAL_NO);

            DA_TRN newDeal = GenerateTrnObject(sessioninfo, opicdeal, pastimported, processdate);

            DealTrans.Add(new DealTranModel() { ProductTransaction = (ProductCode)Enum.Parse(typeof(ProductCode), opicdeal.PRODUCT.Replace(" ", string.Empty)), Transaction = newDeal, UpdateStates = UpdateStates.Adding });
        }