//------------------------------------------------------------------------- public PortfolioItemSummary summarize() { // 3x6 USD 1mm Rec GBP-LIBOR / Pay 2.5% : 21Jan18-21Apr18 StringBuilder buf = new StringBuilder(64); Optional <LocalDate> tradeDate = info.TradeDate; if (tradeDate.Present) { // use a three day fudge to avoid most holiday and end of month issues when calculating months buf.Append(MONTHS.between(tradeDate.get(), product.StartDate.plusDays(3))); buf.Append("x"); buf.Append(MONTHS.between(tradeDate.get(), product.EndDate.plusDays(3))); } else { buf.Append(product.Index.Tenor); } buf.Append(' '); string floatingRate = product.Index.FloatingRateName.normalized().ToString(); string fixedRate = SummarizerUtils.percent(product.FixedRate); buf.Append(SummarizerUtils.amount(product.Currency, product.Notional)); buf.Append(" Rec "); buf.Append(product.BuySell.Buy ? floatingRate : fixedRate); buf.Append(" / Pay "); buf.Append(product.BuySell.Buy ? fixedRate : floatingRate); buf.Append(" : "); buf.Append(SummarizerUtils.dateRange(product.StartDate, product.EndDate)); return(SummarizerUtils.summary(this, ProductType.FRA, buf.ToString(), product.Currency)); }
/// <summary> /// Converts a date range to a period string. /// </summary> /// <param name="start"> the start date </param> /// <param name="end"> the end date </param> /// <returns> the string form </returns> public static string datePeriod(LocalDate start, LocalDate end) { int months = Math.toIntExact(MONTHS.between(start, end.plusDays(3))); if (months > 0) { return(Tenor.of(Period.ofMonths((int)months)).normalized().ToString()); } else { return(Tenor.of(Period.ofDays((int)start.until(end, ChronoUnit.DAYS))).ToString()); } }