//------------------------------------------------------------------------- public PortfolioItemSummary summarize() { // 5Y USD 2mm Rec USD-LIBOR-6M Cap 1% / Pay Premium : 21Jan17-21Jan22 StringBuilder buf = new StringBuilder(96); IborCapFloorLeg mainLeg = product.CapFloorLeg; buf.Append(SummarizerUtils.datePeriod(mainLeg.StartDate.Unadjusted, mainLeg.EndDate.Unadjusted)); buf.Append(' '); buf.Append(SummarizerUtils.amount(mainLeg.Currency, mainLeg.Notional.InitialValue)); buf.Append(' '); if (mainLeg.PayReceive.Receive) { buf.Append("Rec "); summarizeMainLeg(mainLeg, buf); buf.Append(Premium.Present ? " / Pay Premium" : (product.PayLeg.Present ? " / Pay Periodic" : "")); } else { buf.Append(Premium.Present ? "Rec Premium / Pay " : (product.PayLeg.Present ? "Rec Periodic / Pay " : "")); summarizeMainLeg(mainLeg, buf); } buf.Append(" : "); buf.Append(SummarizerUtils.dateRange(mainLeg.StartDate.Unadjusted, mainLeg.EndDate.Unadjusted)); return(SummarizerUtils.summary(this, ProductType.IBOR_CAP_FLOOR, buf.ToString(), mainLeg.Currency)); }
//------------------------------------------------------------------------- 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)); }
//------------------------------------------------------------------------- public PortfolioItemSummary summarize() { // Pay USD 2mm : 21Jan18 StringBuilder buf = new StringBuilder(64); buf.Append(product.PayReceive); buf.Append(' '); buf.Append(SummarizerUtils.amount(product.Value)); buf.Append(" : "); buf.Append(SummarizerUtils.date(product.Date.Unadjusted)); return(SummarizerUtils.summary(this, ProductType.BULLET_PAYMENT, buf.ToString(), product.Currency)); }
//------------------------------------------------------------------------- public PortfolioItemSummary summarize() { // 6M USD 2mm Deposit 0.8% : 21Jan18-21Jul18 StringBuilder buf = new StringBuilder(64); buf.Append(SummarizerUtils.datePeriod(product.StartDate, product.EndDate)); buf.Append(' '); buf.Append(SummarizerUtils.amount(product.Currency, product.Notional)); buf.Append(' '); buf.Append(product.BuySell == BuySell.BUY ? "Deposit " : "Loan "); buf.Append(SummarizerUtils.percent(product.Rate)); buf.Append(" : "); buf.Append(SummarizerUtils.dateRange(product.StartDate, product.EndDate)); return(SummarizerUtils.summary(this, ProductType.TERM_DEPOSIT, buf.ToString(), product.Currency)); }
//------------------------------------------------------------------------- public PortfolioItemSummary summarize() { // Long Barrier Pay USD 1mm Premium USD 100k @ GBP/USD 1.32 : 21Jan18 StringBuilder buf = new StringBuilder(96); CurrencyAmount @base = product.UnderlyingOption.Underlying.BaseCurrencyAmount; CurrencyAmount counter = product.UnderlyingOption.Underlying.CounterCurrencyAmount; buf.Append(product.UnderlyingOption.LongShort); buf.Append(" Barrier "); buf.Append(SummarizerUtils.fx(@base, counter)); buf.Append(" Premium "); buf.Append(SummarizerUtils.amount(premium.Value.mapAmount(v => Math.Abs(v)))); buf.Append(" : "); buf.Append(SummarizerUtils.date(product.UnderlyingOption.ExpiryDate)); CurrencyPair currencyPair = product.CurrencyPair; return(SummarizerUtils.summary(this, ProductType.FX_SINGLE_BARRIER_OPTION, buf.ToString(), currencyPair.Base, currencyPair.Counter)); }
// a summary of the leg private string legSummary(SwapLeg leg) { if (leg is RateCalculationSwapLeg) { RateCalculationSwapLeg rcLeg = (RateCalculationSwapLeg)leg; RateCalculation calculation = rcLeg.Calculation; if (calculation is FixedRateCalculation) { FixedRateCalculation calc = (FixedRateCalculation)calculation; string vary = calc.Rate.Steps.Count > 0 || calc.Rate.StepSequence.Present ? " variable" : ""; return(SummarizerUtils.percent(calc.Rate.InitialValue) + vary); } if (calculation is IborRateCalculation) { IborRateCalculation calc = (IborRateCalculation)calculation; string gearing = calc.Gearing.map(g => " * " + SummarizerUtils.value(g.InitialValue)).orElse(""); string spread = calc.Spread.map(s => " + " + SummarizerUtils.percent(s.InitialValue)).orElse(""); return(calc.Index.Name + gearing + spread); } if (calculation is OvernightRateCalculation) { OvernightRateCalculation calc = (OvernightRateCalculation)calculation; string avg = calc.AccrualMethod == OvernightAccrualMethod.AVERAGED ? " avg" : ""; string gearing = calc.Gearing.map(g => " * " + SummarizerUtils.value(g.InitialValue)).orElse(""); string spread = calc.Spread.map(s => " + " + SummarizerUtils.percent(s.InitialValue)).orElse(""); return(calc.Index.Name + avg + gearing + spread); } if (calculation is InflationRateCalculation) { InflationRateCalculation calc = (InflationRateCalculation)calculation; string gearing = calc.Gearing.map(g => " * " + SummarizerUtils.value(g.InitialValue)).orElse(""); return(calc.Index.Name + gearing); } } if (leg is KnownAmountSwapLeg) { KnownAmountSwapLeg kaLeg = (KnownAmountSwapLeg)leg; string vary = kaLeg.Amount.Steps.Count > 0 || kaLeg.Amount.StepSequence.Present ? " variable" : ""; return(SummarizerUtils.amount(kaLeg.Currency, kaLeg.Amount.InitialValue) + vary); } ImmutableSet <Index> allIndices = leg.allIndices(); return(allIndices.Empty ? "Fixed" : allIndices.ToString()); }
// the notional, with trailing space if present private string notional(SwapLeg leg) { if (leg is RateCalculationSwapLeg) { RateCalculationSwapLeg rcLeg = (RateCalculationSwapLeg)leg; NotionalSchedule notionalSchedule = rcLeg.NotionalSchedule; ValueSchedule amount = notionalSchedule.Amount; double notional = amount.InitialValue; string vary = amount.Steps.Count > 0 || amount.StepSequence.Present ? " variable" : ""; Currency currency = notionalSchedule.FxReset.map(fxr => fxr.ReferenceCurrency).orElse(rcLeg.Currency); return(SummarizerUtils.amount(currency, notional) + vary); } if (leg is RatePeriodSwapLeg) { RatePeriodSwapLeg rpLeg = (RatePeriodSwapLeg)leg; return(SummarizerUtils.amount(rpLeg.PaymentPeriods.get(0).NotionalAmount)); } return(""); }
//------------------------------------------------------------------------- public PortfolioItemSummary summarize() { // 2Y Buy USD 1mm INDEX / 1.5% : 21Jan18-21Jan20 PeriodicSchedule paymentSchedule = product.PaymentSchedule; StringBuilder buf = new StringBuilder(96); buf.Append(SummarizerUtils.datePeriod(paymentSchedule.StartDate, paymentSchedule.EndDate)); buf.Append(' '); buf.Append(product.BuySell); buf.Append(' '); buf.Append(SummarizerUtils.amount(product.Currency, product.Notional)); buf.Append(' '); buf.Append(product.CdsIndexId.Value); buf.Append(" / "); buf.Append(SummarizerUtils.percent(product.FixedRate)); buf.Append(" : "); buf.Append(SummarizerUtils.dateRange(paymentSchedule.StartDate, paymentSchedule.EndDate)); return(SummarizerUtils.summary(this, ProductType.CDS_INDEX, buf.ToString(), product.Currency)); }