Exemplo n.º 1
0
        private void SetLoanC(string loanName, RadDatePicker dt)
        {
            //Fill up the detail now
            LoansBLL bll = new LoansBLL();
            //Loans loan = bll.GetLoanByCode(txtLoanNameC.Text);
            //  txtBoxTradeDate3.SelectedDate = DateTime.Now;
            string strLoanName = loanName;
            if (strLoanName.Contains(';'))
            {
                strLoanName = strLoanName.Replace(';', ' ');
            }
            // Session.Add("Legend", strLoanName);
            Loans loan = bll.GetLoanByCode(strLoanName.Trim());
            //lblNameC.Visible = true;
            //lblLoanNameC.Visible = true;
            //lblLoanNameC.InnerText = strLoanName;
            txtBoxTradeDate3.SelectedDate = Convert.ToDateTime(Session["Trade3"]);
            try
            {

                QuotesAndTradesBLL quotesBL = new QuotesAndTradesBLL();
                QuotesAndTrades quotes = quotesBL.GetQuotesAndTrades(loanName);
                if (quotes != null)
                {
                    if (quotes.BidPrice != null)
                        txtBoxBidPriceC.Text = quotes.BidPrice.Value.ToString();
                    if (quotes.BidSpread != null)
                        txtBoxBidSpreadC.Text = quotes.BidSpread.Value.ToString();
                    if (quotes.OfferPrice != null)
                        txtBoxOfferPriceC.Text = quotes.OfferPrice.Value.ToString();
                    if (quotes.OfferSpread != null)
                        txtBoxOfferSpreadC.Text = quotes.OfferSpread.Value.ToString();
                    if (quotes.AverageLife != null)
                        txtAvgLifeC.Text = quotes.AverageLife.Value.ToString();
                    if (quotes.AvgLifeDisc != null)
                        txtBoxAveLifDiscC.Text = quotes.AvgLifeDisc.Value.ToString();
                    if (quotes.AvgLifeRiskDisc != null)
                        txtBoxAveLifRiskyDiscC.Text = quotes.AvgLifeRiskDisc.Value.ToString();
                    if (quotes.Traded != null)
                        chkBoxTradedC.Checked = quotes.Traded.Value;
                }

            }
            catch (Exception)
            {

            }
            txtLoanNameC.SelectedValue = strLoanName;
            if (txtBoxTradeDate3.SelectedDate != null)
            {
                txtBoxSettlementDate3.SelectedDate = AddBusinessDays(txtBoxTradeDate3.SelectedDate.Value, 10);
            }

            if (loan != null)
            {
                hfSelectedLoanC.Value = loan.ID.ToString();
                if (loan.Signing_Date != string.Empty || loan.Signing_Date != "")
                {
                    txtBoxSettlementDate3.SelectedDate = Convert.ToDateTime(loan.Signing_Date);
                }
                if (loan.Maturity_Date != string.Empty || loan.Maturity_Date != "")
                {
                    txtMaturityDateC.SelectedDate = Convert.ToDateTime(loan.Maturity_Date);
                }
                txtInterestRateC.Text = loan.Margin;
                // txtLoanNameC.Text = loan.CodeName; // Nik Commented
                //txtDiscountMarginC.Text = loan.Margin;
                txtCurrencyC.Text = loan.Currency;
                txtBoxCouponFrequencyLoanC.Text = loan.CouponFrequency;
                txtLastFixingC.Text = loan.FixedOrFloating;
                // txtBoxIRCouponC.Text = loan.Margin;
                //DropDownListItem frequency = ddlAddCouponFrequency.FindItemByValue(loan.CouponFrequency);
                //if (frequency != null)
                //{
                //    frequency.Selected = true;
                //}
                if (loan.Maturity_Date != string.Empty && loan.Maturity_Date != null)
                {// && loan.Signing_Date != null && loan.Signing_Date != string.Empty
                    ComputeCouponDatesAndFractions(dt, txtLoanNameC, txtBoxSettlementDate3, txtMaturityDateC, txtBoxCouponFrequencyLoanC, txtBoxAveLifNonDiscC, grdCalculatedDates3, 3, txtBoxNotional3, txtInterestRateC, txtCurrencyC);
                }
                else
                {

                    grdCalculatedDates3.DataSource = null;
                    grdCalculatedDates3.DataBind();
                    RadWindowManager1.RadAlert("Cashflow generation failed as coupon frequency not valid or blank", 330, 180, "realedge associates", "alertCallBackFn");
                }
                LogActivity("Compute the CashFlow C", "Compute the cashflow for compact view C", string.Empty);
            }
            else
            {
                RadWindowManager1.RadAlert("This loan name does not exist in database", 330, 180, "realedge associates", "alertCallBackFn");
            }
        }
Exemplo n.º 2
0
        private void SetLoanA()
        {
            //Fill up the detail now
            try
            {

                LoansBLL bll = new LoansBLL();
                string strLoanName = txtLoanNameA.Text.ToString();
                txtBoxTradeDate1.SelectedDate = DateTime.Now;
                if (strLoanName.Contains(';'))
                {
                    strLoanName = strLoanName.Replace(';', ' ');
                }
                Loans loan = bll.GetLoanByCode(strLoanName.Trim());
                //lblNameA.Visible = true;
                //lblLoanNameA.Visible = true;
                //lblLoanNameA.InnerText = strLoanName;
                txtLoanNameA.SelectedValue = strLoanName;
                try
                {
                    QuotesAndTradesBLL quotesBL = new QuotesAndTradesBLL();
                    QuotesAndTrades quotes = quotesBL.GetQuotesAndTrades(strLoanName);
                    if (quotes != null)
                    {
                        if (quotes.BidPrice != null)
                            txtBidPriceA.Text = quotes.BidPrice.Value.ToString();
                        if (quotes.BidSpread != null)
                            txtBidSpreadA.Text = quotes.BidSpread.Value.ToString();
                        if (quotes.OfferPrice != null)
                            txtOfferPriceA.Text = quotes.OfferPrice.Value.ToString();
                        if (quotes.OfferSpread != null)
                            txtOfferSpreadA.Text = quotes.OfferSpread.Value.ToString();
                        if (quotes.AverageLife != null)
                            txtAvgLifeA.Text = quotes.AverageLife.Value.ToString();
                        if (quotes.AvgLifeDisc != null)
                            txtAveLifDiscA.Text = quotes.AvgLifeDisc.Value.ToString();
                        if (quotes.AvgLifeRiskDisc != null)
                            txtAveLifRiskyDiscA.Text = quotes.AvgLifeRiskDisc.Value.ToString();
                        if (quotes.Traded != null)
                            chkBoxTradedA.Checked = quotes.Traded.Value;
                    }
                }
                catch (Exception)
                {

                }

                if (txtBoxTradeDate1.SelectedDate != null)
                {
                    txtBoxSettlementDate1.SelectedDate = AddBusinessDays(txtBoxTradeDate1.SelectedDate.Value, 10);
                }

                Session.Add("LegendA", strLoanName);
                if (loan != null)
                {
                    hfSelectedLoanA.Value = loan.ID.ToString();

                    if (loan.Maturity_Date != string.Empty || loan.Maturity_Date != "")
                    {
                        txtBoxMaturityDateA.SelectedDate = Convert.ToDateTime(loan.Maturity_Date);
                    }

                    txtBoxInterestRateA.Text = loan.Margin;         //by Nidhi
                    // txtLoanNameA.Text = loan.CodeName; / Nik Commented
                    //txtDiscountMarginA.Text = loan.Margin;
                    txtBoxCurrencyLoanA.Text = loan.Currency;
                    txtBoxCouponFrequencyLoanA.Text = loan.CouponFrequency;
                    txtBoxLastFixingA.Text = loan.FixedOrFloating;
                    // txtBoxIRCouponA.Text = loan.Margin;
                    ddlCounterPartyA.SelectedValue = "CounterPartyA"; //nik commneted 02-04

                    if (loan.Maturity_Date != string.Empty && loan.Maturity_Date != null)
                    {// && loan.Signing_Date != null && loan.Signing_Date != string.Empty
                        ComputeCouponDatesAndFractions(txtBoxTradeDate1, txtLoanNameA, txtBoxSettlementDate1, txtBoxMaturityDateA, txtBoxCouponFrequencyLoanA, txtAveLifNonDiscA, grdCalculatedDates1, 1, txtBoxNotional1, txtBoxInterestRateA, txtBoxCurrencyLoanA);
                    }
                    else
                    {
                        grdCalculatedDates1.DataSource = null;
                        grdCalculatedDates1.DataBind();
                        RadWindowManager1.RadAlert("Cashflow generation failed as coupon frequency not valid or blank", 330, 180, "realedge associates", "alertCallBackFn");
                    }

                    LogActivity("Compute the CashFlow A", "Compute the cashflow for compact view A", string.Empty);
                }
                else
                {
                    RadWindowManager1.RadAlert("This loan name does not exist in database", 330, 180, "realedge associates", "alertCallBackFn");
                }
            }
            catch (Exception ex)
            {
                RadWindowManager1.RadAlert("Error in SetLoan A : " + ex.Message, 330, 180, "realedge associates", "alertCallBackFn");

            }
        }
Exemplo n.º 3
0
        private void SetLoanB()
        {
            //Fill up the detail now
            try
            {
                LoansBLL bll = new LoansBLL();

                string strLoanName = txtLoanNameB.Text.ToString();
                txtBoxTradeDate2.SelectedDate = DateTime.Now;
                //if (strLoanName.Contains(';'))
                //{
                //    strLoanName = strLoanName.Replace(';', ' ');
                //}
                try
                {

                    QuotesAndTradesBLL quotesBL = new QuotesAndTradesBLL();
                    QuotesAndTrades quotes = quotesBL.GetQuotesAndTrades(strLoanName);
                    if (quotes != null)
                    {
                        if (quotes.BidPrice != null)
                            txtBidPriceA.Text = quotes.BidPrice.Value.ToString();
                        if (quotes.BidSpread != null)
                            txtBidSpreadA.Text = quotes.BidSpread.Value.ToString();
                        if (quotes.OfferPrice != null)
                            txtOfferPriceA.Text = quotes.OfferPrice.Value.ToString();
                        if (quotes.OfferSpread != null)
                            txtOfferSpreadA.Text = quotes.OfferSpread.Value.ToString();
                        if (quotes.AverageLife != null)
                            txtAvgLifeA.Text = quotes.AverageLife.Value.ToString();
                        if (quotes.AvgLifeDisc != null)
                            txtAveLifDiscA.Text = quotes.AvgLifeDisc.Value.ToString();
                        if (quotes.AvgLifeRiskDisc != null)
                            txtAveLifRiskyDiscA.Text = quotes.AvgLifeRiskDisc.Value.ToString();
                        if (quotes.Traded != null)
                            chkBoxTradedA.Checked = quotes.Traded.Value;
                    }
                }
                catch (Exception)
                {

                }
                Loans loan = bll.GetLoanByCode(strLoanName.Trim());
                if (txtBoxTradeDate2.SelectedDate != null)
                {
                    txtBoxSettlementDate2.SelectedDate = AddBusinessDays(txtBoxTradeDate2.SelectedDate.Value, 10);
                }

                if (loan != null)
                {

                    txtLoanNameB.SelectedValue = strLoanName;
                    Session.Add("LegendB", strLoanName);
                    if (loan != null)
                    {
                        hfSelectedLoanB.Value = loan.ID.ToString();
                        //if (loan.Signing_Date != string.Empty || loan.Signing_Date != "")
                        //{
                        //    txtBoxSettlementDate2.SelectedDate = Convert.ToDateTime(loan.Signing_Date);
                        //}
                        if (loan.Maturity_Date != string.Empty || loan.Maturity_Date != "")
                        {
                            txtBoxMaturityDateB.SelectedDate = Convert.ToDateTime(loan.Maturity_Date);
                        }
                        txtInterestRateB.Text = loan.Margin;

                        //txtDiscountMarginB.Text = loan.Margin;
                        txtCurrencyB.Text = loan.Currency;
                        txtBoxCouponFrequencyLoanB.Text = loan.CouponFrequency;
                        txtBoxLastFixingB.Text = loan.FixedOrFloating;
                        // txtBoxIRCouponB.Text = loan.Margin;
                        ddlCounterPartyB.SelectedValue = "CounterPartyB";
                        //  DropDownListItem frequency = ddlAddCouponFrequency.FindItemByValue(loan.CouponFrequency);
                        //if (frequency != null)
                        //{
                        //    frequency.Selected = true;
                        //}

                        if (loan.Maturity_Date != string.Empty && loan.Maturity_Date != null)
                        {// && loan.Signing_Date != null && loan.Signing_Date != string.Empty
                            ComputeCouponDatesAndFractions(txtBoxTradeDate2, txtLoanNameB, txtBoxSettlementDate2, txtBoxMaturityDateB, txtBoxCouponFrequencyLoanB, txtBoxAveLifNonDiscB, grdCalculatedDates2, 2, txtBoxNotional2, txtInterestRateB, txtCurrencyB);
                        }
                        else
                        {

                            grdCalculatedDates2.DataSource = null;
                            grdCalculatedDates2.DataBind();
                            RadWindowManager1.RadAlert("Cashflow generation failed as coupon frequency not valid or blank", 330, 180, "realedge associates", "alertCallBackFn");
                        }
                        LogActivity("Compute the CashFlow B", "Compute the cashflow for compact view B", string.Empty);
                    }
                }
                else
                {
                    RadWindowManager1.RadAlert("This loan name does not exist in database", 330, 180, "realedge associates", "alertCallBackFn");
                }

            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 4
0
 private Loans GetLoanByName(string loanName)
 {
     LoansBLL bll = new LoansBLL();
     Loans loan = bll.GetLoanByCode(loanName);
     return loan;
 }
Exemplo n.º 5
0
        private void SetLoan0()
        {
            //Fill up the detail now
            LoansBLL bll = new LoansBLL();
            Loans loan = bll.GetLoanByCode(txtBoxAddLoanCode.Text);

            hfLoanID.Value = loan.ID.ToString();
            ddlBorrower.SelectedValue = loan.Borrower;
            // txtBoxAddSector.Text = loan.Sector;
            ddlSector.SelectedValue = loan.Sector;
            txtBoxAddSigningDate.SelectedDate = Convert.ToDateTime(loan.Signing_Date);
            txtBoxAddMaturityDate.SelectedDate = Convert.ToDateTime(loan.Maturity_Date);
            DropDownListItem item = ddlAddFixedOrFloating.FindItemByValue(loan.FixedOrFloating);
            if (item != null)
            {
                item.Selected = true;
            }
            txtBoxAddMargin.Text = loan.Margin;
            DropDownListItem currencyItem = ddlAddCurrency.FindItemByValue(loan.Currency);
            if (currencyItem != null)
            {
                currencyItem.Selected = true;
            }
            DropDownListItem frequency = ddlAddCouponFrequency.FindItemByValue(loan.CouponFrequency);
            if (frequency != null)
            {
                frequency.Selected = true;
            }
            txtBoxFacilitySize.Text = Convert.ToDecimal(loan.FacilitySize).ToString("N");
            DropDownListItem yesno;
            if (loan.Bilateral.HasValue && loan.Bilateral.Value)
            {
                yesno = ddlAddBilateral.FindItemByValue("Yes");
            }
            else
            {
                yesno = ddlAddBilateral.FindItemByValue("No");
            }
            yesno.Selected = true;
            DropDownListItem amort = ddlAmortizing.FindItemByValue(loan.Amortizing);
            if (amort != null)
            {
                amort.Selected = true;
            }
        }
Exemplo n.º 6
0
        private void ComputeCouponDatesAndFractions(RadDatePicker txtBoxTradeDate, RadComboBox txtBoxLoanName, RadDatePicker txtBoxSettlementDate,
           RadDatePicker txtBoxMaturityDate, RadTextBox txtBoxCouponFrequency, RadTextBox txtNonDiscountedAverageLife, RadGrid grdCalculatedDates, int type, RadTextBox txtNotional, RadTextBox txtMargin, RadTextBox txtCurrency)
        {
            try
            {

                int countryID = getCountryForLoan(txtBoxLoanName);
                //PublicHolidayBLL bll = new PublicHolidayBLL();
                //List<tblHoliday> publicHolidays = bll.GetPublicHolidays(countryID);

                List<CalculatedDates> calculatedList = new List<CalculatedDates>();

                DateTime cpnDT;
                cpnDT = AddBusinessDays(DateTime.Now, 10);
                LoanScheduleBL loanScheduleBL = new LoanScheduleBL();
                DataTable dtSchedule = loanScheduleBL.GenerateTable(15, 10, cpnDT, txtBoxCouponFrequency.Text, txtNotional.Text, txtBoxMaturityDate.SelectedDate.Value, cpnDT, Convert.ToDecimal(txtMargin.Text), Convert.ToString(txtCurrency.Text), Convert.ToDateTime(txtBoxTradeDate.SelectedDate.Value), txtBoxSettlementDate.SelectedDate.Value);
                if (dtSchedule.Rows.Count > 0)
                {
                    LoansBLL loanBL = new LoansBLL();

                    int loanID = loanBL.GetLoanByCode(txtBoxLoanName.Text).ID;
                    loanScheduleBL.EditSchedule(loanID, dtSchedule);
                }

                foreach (DataRow dr in dtSchedule.Rows)
                {
                    CalculatedDates cal = new CalculatedDates();
                    cal.Fraction = dr["CoupFrac"].ToString();
                    cal.CalculatedDate = Convert.ToDateTime(dr["EndDate"]);
                    calculatedList.Add(cal);
                }

                grdCalculatedDates.Visible = true;
                grdCalculatedDates.DataSource = calculatedList;
                grdCalculatedDates.DataBind();

                switch (type)
                {
                    case 1:
                        tempCalculatedList1 = calculatedList;
                        break;
                    case 2:
                        tempCalculatedList2 = calculatedList;
                        break;
                    case 3:
                        tempCalculatedList3 = calculatedList;
                        break;
                    default:
                        break;
                }

            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 7
0
        public void InsertRecord(string param, int flag)
        {
            try
            {
                string[] strSplit = param.Split(',');
                QuotesAndTrades model = new QuotesAndTrades();
                if (!string.IsNullOrEmpty(strSplit[0].Remove(0, 10)))
                {
                    model.BidPrice = Convert.ToDecimal(strSplit[0].Remove(0, 10));
                }
                if (!string.IsNullOrEmpty(strSplit[1].Remove(0, 10)))
                {
                    string strBidSpread = Convert.ToDecimal(strSplit[1].Remove(0, 10)).ToString("0.00");
                    model.BidSpread = Convert.ToDecimal(strBidSpread);
                }
                model.CounterParty = strSplit[2].Remove(0, 13);
                model.LoanName = strSplit[3].Remove(0, 9);
                if (!string.IsNullOrEmpty(strSplit[4].Remove(0, 11)))
                {
                    model.OfferPrice = Convert.ToDecimal(strSplit[4].Remove(0, 11));
                }
                if (!string.IsNullOrEmpty(strSplit[5].Remove(0, 12)))
                {
                    string strOfferSpread = Convert.ToDecimal(strSplit[5].Remove(0, 12)).ToString("0.00");
                    model.OfferSpread = Convert.ToDecimal(strOfferSpread);
                }
                // model.MarketValue
                model.TimeStamp = DateTime.Now;
                if (strSplit[6].Remove(0, 9) == "true")
                    model.Traded = true;
                else
                    model.Traded = false;

                if (strSplit[3].Remove(0, 9) != string.Empty)
                {
                    LoansBLL loanBLL = new LoansBLL();
                    model.Country = loanBLL.GetCoutryIDbyLoanID(strSplit[3].Remove(0, 9));
                }
                if (!string.IsNullOrEmpty(strSplit[12].Remove(0, 10)))
                {
                    string str = strSplit[12].Remove(0, 10);
                    DateTime tradeDate = DateTime.Now;
                    if (str.Contains('-'))
                    {
                        string[] strSpl = str.Split('-');
                        string datetime = strSpl[1] + "/" + strSpl[0] + "/" + strSpl[2] + " " + strSpl[3] + ":" + strSpl[4] + ":" + strSpl[5];
                        tradeDate = Convert.ToDateTime(datetime);
                    }
                    else
                        tradeDate = Convert.ToDateTime(str);
                    model.TradedDate = Convert.ToDateTime(tradeDate);
                }
                if (!string.IsNullOrEmpty(strSplit[13].Remove(0, 12)))
                {
                    string avgLifeDisc = Convert.ToDecimal(strSplit[13].Remove(0, 12)).ToString("0.00");
                    model.AvgLifeDisc = Convert.ToDecimal(avgLifeDisc);
                }
                if (!string.IsNullOrEmpty(strSplit[14].Remove(0, 16)))
                {
                    string avgLifeRiscDisc = Convert.ToDecimal(strSplit[14].Remove(0, 16)).ToString("0.00");
                    model.AvgLifeRiskDisc = Convert.ToDecimal(avgLifeRiscDisc);
                }
                if (!string.IsNullOrEmpty(strSplit[15].Remove(0, 15)))
                {
                    string avgLifeNonDisc = Convert.ToDecimal(strSplit[15].Remove(0, 15)).ToString("0.00");
                    model.AvgLifeNonDisc = Convert.ToDecimal(avgLifeNonDisc);
                }
                if (!string.IsNullOrEmpty(strSplit[16].Remove(0, 15)))
                {
                    DateTime settlementDate = Convert.ToDateTime(strSplit[16].Remove(0, 15));
                    model.SettlementDate = settlementDate;
                }
                if (!string.IsNullOrEmpty(strSplit[17].Remove(0, 7)))
                {
                    string margin = Convert.ToString(strSplit[17].Remove(0, 7));
                    model.Margin = margin;
                }
                if (!string.IsNullOrEmpty(strSplit[18].Remove(0, 9)))
                {
                    string notional = Convert.ToDecimal(Convert.ToString(strSplit[18].Remove(0, 9))).ToString("0.00");
                    model.MarketValue = Convert.ToDecimal(notional);
                }
                if (!string.IsNullOrEmpty(strSplit[19].Remove(0, 9)))
                {
                    string averageLife = Convert.ToDecimal(Convert.ToString(strSplit[19].Remove(0, 12).Replace('}', ' '))).ToString("0.00");
                    model.AverageLife = Convert.ToDecimal(averageLife);
                }
                // model.CountryID = Convert.ToInt32(ddlRegionA.SelectedValue);
                List<QuotesAndTrades> lst = new List<QuotesAndTrades>();
                lst.Add(model);
                QuotesAndTradesBLL bll = new QuotesAndTradesBLL();

                bll.AddImportedQuotesAndTrades(lst);

                BindHistoricalQuotesAndTradesTab();

                // broadcast that quote and trade has been added
                ApplicationHub.NewQuotesAndTradeAdded(model);

                if (string.IsNullOrEmpty(hfSelectedLoanA.Value))
                {
                    // Add the Loans as well
                    Loans loanModel = new Loans();
                    //loanModel.Amortizing
                    //loanModel.Bilateral
                    loanModel.CodeName = strSplit[3].Remove(0, 9);
                    //loanModel.Country
                    loanModel.CouponFrequency = strSplit[7].Remove(0, 8);
                    loanModel.Currency = strSplit[8].Remove(0, 9);
                    //loanModel.FacilitySize
                    loanModel.Margin = strSplit[9].Remove(0, 9);
                    //   loanModel.Margin = strSplit[10].Remove(0, 8);
                    loanModel.Maturity_Date = strSplit[11].Remove(0, 8);
                    //loanModel.Sector
                    loanModel.Signing_Date = strSplit[12].Remove(0, 10).ToString().Trim();

                    // Persist in database
                    LoansBLL loanBll = new LoansBLL();

                    if (loanBll.CheckForLoanCode(strSplit[3].Remove(0, 9).Trim()))
                    {
                        loanBll.SaveLoan(loanModel);

                        //new loan has been added.
                        //Broadcast it
                        ApplicationHub.NewLoanAdded(loanModel);
                        BindLoansTab();
                        ShowMessage("Message", "Quote and Loan added Successfully");
                    }
                    else
                    {
                        int loanID = loanBll.GetLoanByCode(strSplit[3].Remove(0, 9)).ID;
                        loanBll.EditLoan(loanModel, loanID, 1);       //by nidhi for update the existing loan.

                        DuplicateLoan duplicateLoan = new DuplicateLoan();
                        //loanModel.Amortizing
                        //loanModel.Bilateral
                        duplicateLoan.CodeName = strSplit[3].Remove(0, 9);
                        //loanModel.Country
                        duplicateLoan.CouponFrequency = strSplit[7].Remove(0, 8);
                        duplicateLoan.Currency = strSplit[8].Remove(0, 9);
                        //loanModel.FacilitySize
                        duplicateLoan.FixedOrFloating = strSplit[9].Remove(0, 9);
                        duplicateLoan.Margin = strSplit[10].Remove(0, 8);
                        duplicateLoan.Maturity_Date = strSplit[11].Remove(0, 8);
                        //loanModel.Sector
                        duplicateLoan.Signing_Date = strSplit[12].Remove(0, 10).ToString().Trim();
                        loanBll.SaveDuplicateLoan(duplicateLoan);
                    }
                }

                hdnQuoteTemp.Value = "N";
                ShowMessage("Message", "Quote and Loan added Successfully");
                switch (flag)
                {
                    case 1:
                        LogActivity("Quote and Loan A added", "Add the quote and trade on compact view A", string.Empty);
                        break;
                    case 2:
                        LogActivity("Quote and Loan B added", "Add the quote and trade on compact view B", string.Empty);
                        break;
                    case 3:
                        LogActivity("Quote and Loan C added", "Add the quote and trade on compact view C", string.Empty);
                        break;
                    default:
                        break;
                }

            }
            catch (Exception)
            {
            }
        }
Exemplo n.º 8
0
        private string CalculateIRR(string loanName, string marketPrice)
        {
            LoansBLL bll = new LoansBLL();
            Loans loan = bll.GetLoanByCode(loanName);
            int loanID = loan.ID;
            double notional = Convert.ToDouble(loan.Notional);
            LoanScheduleBL loanScheduleBL = new LoanScheduleBL();
            List<LoanSchedule> loanSchedule = new List<LoanSchedule>();
            loanSchedule = loanScheduleBL.GetLoanByID(loanID);
            double[] cashFlows;
            double[] days;
            List<DateTime> scheduleDateTime = new List<DateTime>();
            if (loanSchedule != null)
            {
                List<double> cashFlowDouble = new List<double>();
                double mktPrice = 0.99;
                if (marketPrice != string.Empty)
                {
                    mktPrice = Convert.ToDouble(marketPrice) / 100;
                }

                double dFirstCashFlow = (Convert.ToDouble(mktPrice) * Convert.ToDouble(notional)) * -1;
                scheduleDateTime.Add(loanSchedule.First().StartDate.Value);
                cashFlowDouble.Add(dFirstCashFlow);

                List<double> day = new List<double>();
                foreach (var item in loanSchedule)
                {
                    cashFlowDouble.Add(Convert.ToDouble(item.AmortisationInt));
                    day.Add(Convert.ToInt16(item.Days));
                    scheduleDateTime.Add(Convert.ToDateTime(item.EndDate));
                }
                cashFlows = cashFlowDouble.ToArray();

                days = day.ToArray();
            }
            else
            {
                cashFlows = new double[1] { 0.0 };
                days = new double[1] { 0.0 };

            }

            //Zainco.NewtonRaphson.IRRCalculator.Domain.ICalculator calculator = new NewtonRaphsonIRRCalc(cashFlows);
            //Double d = calculator.Execute();
            IRR irr = new IRR();

            //double xirr = irr.Newtons_method(0.1,
            //                           irr.total_f_xirr(cashFlows, days),
            //                           irr.total_df_xirr(cashFlows, days));

            double xirr = System.Numeric.Financial.XIrr(cashFlows, scheduleDateTime) * 100;
            return Convert.ToDecimal(xirr).ToString("0.00");
            // return d;
        }
Exemplo n.º 9
0
        //private void BindLoanCodeDetails()
        //{
        //    try
        //    {
        //        LoansBLL bll = new LoansBLL();
        //        string strLoanName = ddlAddLoanCode.Text.ToString();
        //        if (strLoanName.Contains(';'))
        //        {
        //            strLoanName = strLoanName.Replace(';', ' ');
        //        }
        //        Loans loan = bll.GetLoanByCode(strLoanName.Trim());
        //        if (loan != null)
        //        {
        //            txtBoxAddBorrower.Text = Convert.ToString(loan.Borrower);
        //            txtBoxAddSector.Text = Convert.ToString(loan.Sector);
        //            if (loan.Signing_Date != "")
        //                txtBoxAddSigningDate.SelectedDate = Convert.ToDateTime(loan.Signing_Date);
        //            else
        //                txtBoxAddSigningDate.Clear();
        //            if (loan.Maturity_Date != "")
        //                txtBoxAddMaturityDate.SelectedDate = Convert.ToDateTime(loan.Maturity_Date);
        //            else
        //                txtBoxAddMaturityDate.Clear();
        //            txtBoxFacilitySize.Text = loan.FacilitySize;
        //            ddlAddFixedOrFloating.SelectedValue = loan.FixedOrFloating;
        //            txtBoxAddMargin.Text = loan.Margin;
        //            ddlAddCurrency.SelectedValue = loan.Currency;
        //            ddlCountry.SelectedValue = loan.Country;
        //            ddlAddCouponFrequency.SelectedValue = loan.CouponFrequency;
        //            if (loan.Bilateral == true)
        //                ddlAddBilateral.SelectedValue = "Yes";
        //            else
        //                ddlAddBilateral.SelectedValue = "No";
        //            ddlAmortizing.SelectedValue = loan.Amortizing;
        //            lblConfirm.Text = "Loan already exists, do you wish to overwrite?";
        //            _operation = "Edit";
        //        }
        //        else
        //        {
        //            _operation = "Add";
        //        }
        //        //else
        //        //{
        //        //    Clear();
        //        //}
        //    }
        //    catch (Exception)
        //    {
        //    }
        //}
        private void BindLoanCodeDetails()
        {
            try
            {
                LoansBLL bll = new LoansBLL();
                string strLoanName = ddlAddLoanCode.Text.ToString();
                if (strLoanName.Contains(';'))
                {
                    strLoanName = strLoanName.Replace(';', ' ');
                }
                Loans loan = bll.GetLoanByCode(strLoanName.Trim());
                if (loan != null)
                {
                    if (loan.Borrower != null)
                    {
                        ddlBorrower.SelectedValue = Convert.ToString(loan.Borrower);
                        BorrowersBL borrowerBL = new BorrowersBL();
                        if (ddlBorrower.SelectedValue != string.Empty)
                        {
                            if (ddlBorrower.SelectedItem != null)
                            {
                                Borrower borrower = borrowerBL.GetBorrower(ddlBorrower.SelectedItem.Text);
                                txtGrid.Text = loan.Grid;
                                txtSummitCredit.Text = loan.SummitCreditEntity;
                            }
                        }

                    }

                    //  txtBoxAddSector.Text = Convert.ToString(loan.Sector);
                    if (loan.Sector != null)
                    {
                        ddlSector.SelectedValue = Convert.ToString(loan.Sector);
                    }

                    if (loan.Signing_Date != "" && loan.Signing_Date != null)
                        txtBoxAddSigningDate.SelectedDate = Convert.ToDateTime(loan.Signing_Date);
                    else
                        txtBoxAddSigningDate.Clear();
                    if (loan.Maturity_Date != "" && loan.Maturity_Date != null)
                        txtBoxAddMaturityDate.SelectedDate = Convert.ToDateTime(loan.Maturity_Date);
                    else
                        txtBoxAddMaturityDate.Clear();
                    if (loan.CouponDate != "" && loan.CouponDate != null)
                        txtCouponDate.SelectedDate = Convert.ToDateTime(loan.CouponDate);
                    else
                        txtCouponDate.Clear();
                    if (loan.FacilitySize != null)
                    {
                        txtBoxFacilitySize.Text = Convert.ToDecimal(loan.FacilitySize).ToString("N");

                    }
                    if (loan.Fixed_Floating != null)
                    {
                        ddlAddFixedOrFloating.SelectedValue = loan.FixedOrFloating;
                    }

                    txtBoxAddMargin.Text = loan.Margin;
                    if (loan.Currency != null)
                    {
                        ddlAddCurrency.SelectedValue = loan.Currency;
                    }
                    if (loan.Country != null)
                    {
                        ddlCountry.SelectedValue = loan.Country;
                    }

                    txtPP.Text = loan.PP;
                    //  txtCRating.Text = loan.CreditRating;
                    txtStructureID.Text = loan.StructureID;
                    if (loan.CouponFrequency != null)
                    {
                        ddlAddCouponFrequency.SelectedValue = loan.CouponFrequency;
                    }

                    txtNotional.Text = Convert.ToDecimal(loan.Notional).ToString("N");
                    if (loan.Bilateral == true)
                        ddlAddBilateral.SelectedValue = "Yes";
                    else
                        ddlAddBilateral.SelectedValue = "No";
                    if (loan.Amortizing == "Yes")
                    {
                        ddlAmortizing.SelectedValue = loan.Amortizing;
                        if (ddlAmortizing.SelectedValue == "Yes")
                        {
                            if (loan.AmortisationsStartPoint != null)
                                txtAmortisationsStartDate.SelectedDate = Convert.ToDateTime(loan.AmortisationsStartPoint);
                            txtAmortisations.Text = loan.NoOfAmortisationPoint.ToString();
                            trDate.Visible = true;
                            trNo.Visible = true;
                            tblAmortisation.Visible = true;
                        }
                    }
                    else
                    {
                        ddlAmortizing.SelectedValue = "No";
                        trDate.Visible = false;
                        trNo.Visible = false;
                        tblAmortisation.Visible = false;
                    }
                    txtGurantor.Text = loan.Gurantor;
                    txtGrid.Text = loan.Grid;
                    txtSummitCredit.Text = loan.SummitCreditEntity;

                    CheckNodes(tvCreditRating, loan);

                    txtBoxAddMargin.Text = loan.Margin;

                    LoanScheduleBL scheduleBL = new LoanScheduleBL();
                    List<LoanSchedule> scheduleList = scheduleBL.GetLoanByID(loan.ID);

                    if (scheduleList != null && scheduleList.Count > 0)
                    {
                        dt1.Clear();
                        //dt1.Columns.Add("ID", typeof(int));
                        //dt1.Columns.Add("StartDate", typeof(DateTime));
                        //dt1.Columns.Add("EndDate", typeof(DateTime));
                        //dt1.Columns.Add("Notional", typeof(long));
                        //dt1.Columns.Add("Factor", typeof(float));

                        for (int i = 0; i < scheduleList.Count; i++)
                        {
                            // dt1.Rows.Add(scheduleList[i].ID, scheduleList[i].StartDate, scheduleList[i].EndDate, scheduleList[i].Notation, scheduleList[i].Factor);
                            dt1.Rows.Add(i + 1, scheduleList[i].StartDate.Value.ToShortDateString(), scheduleList[i].EndDate.Value.ToShortDateString(), scheduleList[i].CoupFrac, scheduleList[i].Notation, scheduleList[i].Amortisation, scheduleList[i].Factor, scheduleList[i].Spread, scheduleList[i].CouponPaymentDate, scheduleList[i].RiskFreeDP1, scheduleList[i].RiskFreeDP2, scheduleList[i].FloatingRate, scheduleList[i].AllInRate, scheduleList[i].Interest, scheduleList[i].Days, scheduleList[i].AmortisationInt);
                        }
                        pnlAmortizing.Visible = true;
                        grdAmortizing.Visible = true;
                        btnCalculatSchedule.Visible = true;
                        Session.Add("LoanScheduleData", dt1);
                        grdAmortizing.DataSource = dt1;
                        grdAmortizing.DataBind();
                    }
                    else
                    {
                        Session.Remove("LoanScheduleData");
                        dt1.Clear();
                        pnlAmortizing.Visible = false;
                        btnCalculatSchedule.Visible = false;
                        grdAmortizing.Visible = false;
                    }
                    hfLoanID.Value = loan.ID.ToString();
                    Session.Add("EditLoanID", loan.ID.ToString());
                    lblConfirm.Text = "Loan already exists, do you wish to overwrite?";
                    _operation = "Edit";
                }
                else
                {
                    hfLoanID.Value = string.Empty;
                    _operation = "Add";
                    lblConfirm.Text = "Are you sure you want to add this loan to database?";
                    // Clear();
                }
            }
            catch (Exception)
            {

            }
        }
Exemplo n.º 10
0
        protected DataTable GetCompactChartData(string loanName)
        {
            try
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("ID");
                dt.Columns.Add("EndDate");
                dt.Columns.Add("Notation");

                LoansBLL loanBL = new LoansBLL();
                int loanID = loanBL.GetLoanByCode(loanName).ID;
                LoanScheduleBL loanScheduleBL = new LoanScheduleBL();
                List<LoanSchedule> loanSchedule = loanScheduleBL.GetLoanByID(loanID);

                if (loanSchedule != null)
                {
                    for (int i = 0; i < loanSchedule.Count; i++)
                    {
                        dt.Rows.Add((i + 1), new DateTime(loanSchedule[i].EndDate.Value.Year, loanSchedule[i].EndDate.Value.Month, loanSchedule[i].EndDate.Value.Day), loanSchedule[i].Notation.ToString());
                    }
                }
                return dt;
            }
            catch (Exception)
            {
                return null;
            }
        }