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) { } }
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"); } }
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"); } }
public List<QuotesAndTrades> BindQuotesAndTradesData() { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); List<QuotesAndTrades> lst = bll.GetQuotesAndTrades(); return lst; }
private void BindHistoricalQuotesAndTradesTab(List<QuotesAndTrades> lst = null) { if (lst == null) { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); lst = bll.GetQuotesAndTrades(); } grdQuotesAndTrades.DataSource = lst; grdQuotesAndTrades.DataBind(); }
protected void ExportToCSV() { string csv_file_path = Server.MapPath("~/Temp/tempfile1.csv"); if (ddlImportType.SelectedValue == "Loan") { LoansBLL bll = new LoansBLL(); var loanList = bll.GetLoans().Select(x => new { LoanName = x.CodeName, Borrower = x.Borrower, Country = x.Country, Sector = x.Sector, SigingDate = x.Signing_Date, MaturityDate = x.Maturity_Date, FixedOrFloating = x.FixedOrFloating, Margin = x.Margin, Currency = x.Currency, CouponFrequency = x.CouponFrequency, FacilitySize = x.FacilitySize, Bilateral = x.Bilateral, Amortizing = x.Amortizing, CouponDate = x.CouponDate, Notional = x.Notional, AmortisationsStartPoint = x.AmortisationsStartPoint, NoOfAmortisationPoint = x.NoOfAmortisationPoint, StructureID = x.StructureID, PP = x.PP, FixedFloating = x.Fixed_Floating, CreditRatingModys = x.CreditRatingModys, CreditRatingSPs = x.CreditRatingSPs, CreditRatingFitch = x.CreditRatingFitch, CreditRatingING = x.CreditRatingING, Gurantor = x.Gurantor, Grid = x.Grid, SummitCreditEntity = x.SummitCreditEntity }); List<LoanTable> loanTable = new List<LoanTable>(); foreach (var item in loanList) { loanTable.Add(new LoanTable(item.LoanName, item.Borrower, item.Country, Convert.ToDateTime(item.SigingDate), Convert.ToDateTime(item.MaturityDate), item.FixedOrFloating, item.Margin, item.Currency, item.CouponFrequency, item.FacilitySize, Convert.ToBoolean(item.Bilateral), item.Amortizing, Convert.ToDateTime(item.CouponDate), item.Notional, item.AmortisationsStartPoint, Convert.ToInt16(item.NoOfAmortisationPoint), item.StructureID, item.PP, item.FixedFloating, item.CreditRatingModys, item.CreditRatingSPs, item.CreditRatingFitch, item.CreditRatingING, item.Gurantor, item.Grid, item.SummitCreditEntity)); } BLL.CsvExport<LoanTable> exportHelper = new CsvExport<LoanTable>(loanTable); exportHelper.ExportToFile(csv_file_path); LogActivity("Loans Exported", "Export the Loans", string.Empty); } else if (ddlImportType.SelectedValue == "Quotes") { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); var quotesList = bll.GetQuotesAndTrades().Select(x => new { LoanName = x.LoanName, TimeStamp = x.TimeStamp, CounterParty = x.CounterParty, BidPrice = x.BidPrice, OfferPrice = x.OfferPrice, BidSpread = x.BidSpread, OfferSpread = x.OfferSpread, Traded = x.Traded, MarketValue = x.MarketValue, Country = x.Country, AverageLife = x.AverageLife, AvgLifeDisc = x.AvgLifeDisc, AvgLifeRiskDisc = x.AvgLifeRiskDisc, AvgLifeNonDisc = x.AvgLifeNonDisc, SettlementDate = x.SettlementDate, Margin = x.Margin }); List<HistoricalQuote> quotes = new List<HistoricalQuote>(); foreach (var item in quotesList) { quotes.Add(new HistoricalQuote(item.LoanName, Convert.ToDateTime(item.TimeStamp.Value), item.CounterParty, Convert.ToDecimal(item.BidPrice), Convert.ToDecimal(item.OfferPrice), Convert.ToDecimal(item.BidSpread), Convert.ToDecimal(item.OfferSpread), Convert.ToBoolean(item.Traded), Convert.ToDecimal(item.MarketValue), item.Country, Convert.ToDecimal(item.AverageLife), Convert.ToDecimal(item.AvgLifeDisc), Convert.ToDecimal(item.AvgLifeRiskDisc), Convert.ToDecimal(item.AvgLifeNonDisc), Convert.ToDateTime(item.SettlementDate), item.Margin)); } BLL.CsvExport<HistoricalQuote> exportHelper = new CsvExport<HistoricalQuote>(quotes); exportHelper.ExportToFile(csv_file_path); LogActivity("QuotesAndTrades Exported", "Export the quotesAndtrades", string.Empty); } else if (ddlImportType.SelectedValue == "EUR Curve") { EURCurvesBL bll = new EURCurvesBL(); var list = bll.GetEURCurve().Select(x => new { UploadDate = x.UploadDate, SummitGenDate = x.SummitGenDate, CCY = x.CCY, Index = x.CurveIndex, Days = x.Days, Rate = x.Rate, DiscFreq = x.DiscFreq }); List<EURCurveTable> eurTable = new List<EURCurveTable>(); foreach (var item in list) { eurTable.Add(new EURCurveTable(Convert.ToDateTime(item.UploadDate), Convert.ToDateTime(item.SummitGenDate), item.CCY, item.Index, Convert.ToInt16(item.Days), Convert.ToDecimal(item.Rate), Convert.ToDecimal(item.DiscFreq))); } BLL.CsvExport<EURCurveTable> exportHelper = new CsvExport<EURCurveTable>(eurTable); exportHelper.ExportToFile(csv_file_path); LogActivity("EURCurve Exported", "Export the EURCurve", string.Empty); } else if (ddlImportType.SelectedValue == "US Curve") { USDCurveBL bll = new USDCurveBL(); var list = bll.GetUSCurve().Select(x => new { UploadDate = x.UploadDate, SummitGenDate = x.SummitGenDate, CCY = x.CCY, Index = x.CurveIndex, Days = x.Days, Rate = x.Rate, DiscFreq = x.DiscFreq }); List<USDCurveTable> eurTable = new List<USDCurveTable>(); foreach (var item in list) { eurTable.Add(new USDCurveTable(Convert.ToDateTime(item.UploadDate), Convert.ToDateTime(item.SummitGenDate), item.CCY, item.Index, Convert.ToInt16(item.Days), Convert.ToDecimal(item.Rate), Convert.ToDecimal(item.DiscFreq))); } BLL.CsvExport<USDCurveTable> exportHelper = new CsvExport<USDCurveTable>(eurTable); exportHelper.ExportToFile(csv_file_path); LogActivity("USCurve Exported", "Export the USCurve", string.Empty); } FileInfo file = new FileInfo(csv_file_path); if (file.Exists) { ShowMessage("Message", "Data has been exported successfully"); Response.Clear(); Response.ClearHeaders(); Response.ClearContent(); Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name); Response.AddHeader("Content-Length", file.Length.ToString()); Response.ContentType = "text/plain"; Response.Flush(); Response.TransmitFile(file.FullName); Response.End(); } }
protected void btnRemoveQuotes_Click(object sender, EventArgs e) { QuotesAndTradesBLL bll = new QuotesAndTradesBLL(); bool result = bll.RemoveAllQuotesAndTrades(); if (result) { List<QuotesAndTrades> lst = bll.GetQuotesAndTrades(); ApplicationHub.RefreshQuotesAndTrade(lst); ShowMessage("Message", "All quotes and trades deleted successfully"); LogActivity("Delete All QuotesAndTrades", "Remove all the quotes and trades", string.Empty); } else { LogActivity("Delete All QuotesAndTrades(Unsuccessfull)", "Remove all the quotes and trades", string.Empty); lblRemoveQuotesMessage.Text = "Unable to delete the quotes"; } }