private Cms(CmsLeg cmsLeg, SwapLeg payLeg) { JodaBeanUtils.notNull(cmsLeg, "cmsLeg"); this.cmsLeg = cmsLeg; this.payLeg = payLeg; validate(); }
//------------------------------------------------------------------------- public PortfolioItemSummary summarize() { // 5Y USD 2mm Rec USD-LIBOR-1100-1Y Cap 1% / Pay Premium : 21Jan17-21Jan22 StringBuilder buf = new StringBuilder(96); CmsLeg mainLeg = product.CmsLeg; 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.CMS, buf.ToString(), mainLeg.Currency)); }
public virtual void test_builder_fail() { // index is null assertThrowsIllegalArg(() => CmsLeg.builder().capSchedule(CAP).notional(NOTIONAL).payReceive(RECEIVE).paymentSchedule(SCHEDULE_EUR).build()); // floorSchedule and capSchedule are present assertThrowsIllegalArg(() => CmsLeg.builder().capSchedule(CAP).floorSchedule(FLOOR).index(INDEX).notional(NOTIONAL).payReceive(RECEIVE).paymentSchedule(SCHEDULE_EUR).build()); // stub is on assertThrowsIllegalArg(() => CmsLeg.builder().index(INDEX).notional(NOTIONAL).payReceive(RECEIVE).paymentSchedule(PeriodicSchedule.of(START, END, FREQUENCY, BUSS_ADJ_EUR, StubConvention.SHORT_INITIAL, RollConventions.NONE)).build()); }
public virtual void test_resolve() { CmsLeg baseFloor = CmsLeg.builder().floorSchedule(FLOOR).index(INDEX).notional(NOTIONAL).payReceive(PAY).paymentSchedule(SCHEDULE_EUR).build(); ResolvedCmsLeg resolvedFloor = baseFloor.resolve(REF_DATA); LocalDate end1 = LocalDate.of(2016, 10, 21); LocalDate fixing1 = EUR_EURIBOR_6M.calculateFixingFromEffective(START, REF_DATA); LocalDate fixing2 = EUR_EURIBOR_6M.calculateFixingFromEffective(end1, REF_DATA); LocalDate fixing3 = EUR_EURIBOR_6M.calculateFixingFromEffective(END, REF_DATA); LocalDate endDate = SCHEDULE_EUR.calculatedEndDate().adjusted(REF_DATA); CmsPeriod period1 = CmsPeriod.builder().currency(EUR).floorlet(FLOOR.InitialValue).notional(-NOTIONAL.InitialValue).index(INDEX).startDate(START).endDate(end1).unadjustedStartDate(START).unadjustedEndDate(end1).fixingDate(fixing1).paymentDate(end1).yearFraction(EUR_EURIBOR_6M.DayCount.yearFraction(START, end1)).dayCount(EUR_EURIBOR_6M.DayCount).underlyingSwap(createUnderlyingSwap(fixing1)).build(); CmsPeriod period2 = CmsPeriod.builder().currency(EUR).floorlet(FLOOR.Steps[0].Value.ModifyingValue).notional(-NOTIONAL.Steps[0].Value.ModifyingValue).index(INDEX).startDate(end1).endDate(endDate).unadjustedStartDate(end1).unadjustedEndDate(END).fixingDate(fixing2).paymentDate(endDate).yearFraction(EUR_EURIBOR_6M.DayCount.yearFraction(end1, endDate)).dayCount(EUR_EURIBOR_6M.DayCount).underlyingSwap(createUnderlyingSwap(fixing2)).build(); assertEquals(resolvedFloor.Currency, EUR); assertEquals(resolvedFloor.StartDate, baseFloor.StartDate.adjusted(REF_DATA)); assertEquals(resolvedFloor.EndDate, baseFloor.EndDate.adjusted(REF_DATA)); assertEquals(resolvedFloor.Index, INDEX); assertEquals(resolvedFloor.PayReceive, PAY); assertEquals(resolvedFloor.CmsPeriods.size(), 2); assertEquals(resolvedFloor.CmsPeriods.get(0), period1); assertEquals(resolvedFloor.CmsPeriods.get(1), period2); CmsLeg baseFloorEnd = CmsLeg.builder().floorSchedule(FLOOR).fixingRelativeTo(FixingRelativeTo.PERIOD_END).index(INDEX).notional(NOTIONAL).payReceive(PAY).paymentSchedule(SCHEDULE_EUR).build(); ResolvedCmsLeg resolvedFloorEnd = baseFloorEnd.resolve(REF_DATA); CmsPeriod period1End = CmsPeriod.builder().currency(EUR).floorlet(FLOOR.InitialValue).notional(-NOTIONAL.InitialValue).index(INDEX).startDate(START).endDate(end1).unadjustedStartDate(START).unadjustedEndDate(end1).fixingDate(fixing2).paymentDate(end1).yearFraction(EUR_EURIBOR_6M.DayCount.yearFraction(START, end1)).dayCount(EUR_EURIBOR_6M.DayCount).underlyingSwap(createUnderlyingSwap(fixing2)).build(); CmsPeriod period2End = CmsPeriod.builder().currency(EUR).floorlet(FLOOR.Steps[0].Value.ModifyingValue).notional(-NOTIONAL.Steps[0].Value.ModifyingValue).index(INDEX).startDate(end1).endDate(endDate).unadjustedStartDate(end1).unadjustedEndDate(END).fixingDate(fixing3).paymentDate(endDate).yearFraction(EUR_EURIBOR_6M.DayCount.yearFraction(end1, endDate)).dayCount(EUR_EURIBOR_6M.DayCount).underlyingSwap(createUnderlyingSwap(fixing3)).build(); assertEquals(resolvedFloorEnd.Currency, EUR); assertEquals(resolvedFloorEnd.StartDate, baseFloor.StartDate.adjusted(REF_DATA)); assertEquals(resolvedFloorEnd.EndDate, baseFloor.EndDate.adjusted(REF_DATA)); assertEquals(resolvedFloorEnd.Index, INDEX); assertEquals(resolvedFloorEnd.PayReceive, PAY); assertEquals(resolvedFloorEnd.CmsPeriods.size(), 2); assertEquals(resolvedFloorEnd.CmsPeriods.get(0), period1End); assertEquals(resolvedFloorEnd.CmsPeriods.get(1), period2End); CmsLeg baseCap = CmsLeg.builder().index(INDEX).capSchedule(CAP).notional(NOTIONAL).payReceive(PAY).paymentSchedule(SCHEDULE_EUR).paymentDateOffset(PAYMENT_OFFSET).build(); ResolvedCmsLeg resolvedCap = baseCap.resolve(REF_DATA); CmsPeriod periodCap1 = CmsPeriod.builder().currency(EUR).notional(-NOTIONAL.InitialValue).index(INDEX).caplet(CAP.InitialValue).startDate(START).endDate(end1).unadjustedStartDate(START).unadjustedEndDate(end1).fixingDate(fixing1).paymentDate(PAYMENT_OFFSET.adjust(end1, REF_DATA)).yearFraction(EUR_EURIBOR_6M.DayCount.yearFraction(START, end1)).dayCount(EUR_EURIBOR_6M.DayCount).underlyingSwap(createUnderlyingSwap(fixing1)).build(); CmsPeriod periodCap2 = CmsPeriod.builder().currency(EUR).notional(-NOTIONAL.Steps[0].Value.ModifyingValue).index(INDEX).caplet(CAP.InitialValue).startDate(end1).endDate(endDate).unadjustedStartDate(end1).unadjustedEndDate(END).fixingDate(fixing2).paymentDate(PAYMENT_OFFSET.adjust(endDate, REF_DATA)).yearFraction(EUR_EURIBOR_6M.DayCount.yearFraction(end1, endDate)).dayCount(EUR_EURIBOR_6M.DayCount).underlyingSwap(createUnderlyingSwap(fixing2)).build(); assertEquals(resolvedCap.Currency, EUR); assertEquals(resolvedCap.StartDate, baseCap.StartDate.adjusted(REF_DATA)); assertEquals(resolvedCap.EndDate, baseCap.EndDate.adjusted(REF_DATA)); assertEquals(resolvedCap.Index, INDEX); assertEquals(resolvedCap.PayReceive, PAY); assertEquals(resolvedCap.CmsPeriods.size(), 2); assertEquals(resolvedCap.CmsPeriods.get(0), periodCap1); assertEquals(resolvedCap.CmsPeriods.get(1), periodCap2); }
// summarize the main leg private void summarizeMainLeg(CmsLeg mainLeg, StringBuilder buf) { buf.Append(mainLeg.Index); buf.Append(' '); if (mainLeg.CapSchedule.Present) { buf.Append("Cap "); buf.Append(SummarizerUtils.percent(mainLeg.CapSchedule.get().InitialValue)); } if (mainLeg.FloorSchedule.Present) { buf.Append("Floor "); buf.Append(SummarizerUtils.percent(mainLeg.FloorSchedule.get().InitialValue)); } }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case -1356515323: // cmsLeg this.cmsLeg = (CmsLeg)newValue; break; case -995239866: // payLeg this.payLeg = (SwapLeg)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
public virtual void test_builder_full() { CmsLeg test = CmsLeg.builder().currency(GBP).dayCount(ACT_365_ACTUAL).fixingRelativeTo(FixingRelativeTo.PERIOD_END).fixingDateOffset(FIXING_OFFSET).paymentDateOffset(PAYMENT_OFFSET).floorSchedule(FLOOR).index(INDEX).notional(NOTIONAL).payReceive(PAY).paymentSchedule(SCHEDULE).build(); assertEquals(test.PayReceive, PAY); assertFalse(test.CapSchedule.Present); assertEquals(test.FloorSchedule.get(), FLOOR); assertEquals(test.Currency, GBP); assertEquals(test.Notional, NOTIONAL); assertEquals(test.DayCount, ACT_365_ACTUAL); assertEquals(test.StartDate, AdjustableDate.of(START, SCHEDULE.BusinessDayAdjustment)); assertEquals(test.EndDate, SCHEDULE.calculatedEndDate()); assertEquals(test.Index, INDEX); assertEquals(test.PaymentSchedule, SCHEDULE); assertEquals(test.FixingRelativeTo, FixingRelativeTo.PERIOD_END); assertEquals(test.FixingDateOffset, FIXING_OFFSET); assertEquals(test.PaymentDateOffset, PAYMENT_OFFSET); }
public virtual void test_builder_min_coupon() { CmsLeg test = CmsLeg.builder().index(INDEX).notional(NOTIONAL).payReceive(RECEIVE).paymentSchedule(SCHEDULE_EUR).build(); assertEquals(test.PayReceive, RECEIVE); assertFalse(test.CapSchedule.Present); assertFalse(test.FloorSchedule.Present); assertEquals(test.Currency, EUR_EURIBOR_6M.Currency); assertEquals(test.Notional, NOTIONAL); assertEquals(test.DayCount, EUR_EURIBOR_6M.DayCount); assertEquals(test.StartDate, AdjustableDate.of(START, SCHEDULE_EUR.BusinessDayAdjustment)); assertEquals(test.EndDate, SCHEDULE_EUR.calculatedEndDate()); assertEquals(test.Index, INDEX); assertEquals(test.PaymentSchedule, SCHEDULE_EUR); assertEquals(test.FixingRelativeTo, FixingRelativeTo.PERIOD_START); assertEquals(test.FixingDateOffset, EUR_EURIBOR_6M.FixingDateOffset); assertEquals(test.PaymentDateOffset, DaysAdjustment.NONE); }
/// <summary> /// Obtains an instance from a CMS leg and a pay leg. /// </summary> /// <param name="cmsLeg"> the CMS leg </param> /// <param name="payLeg"> the pay leg </param> /// <returns> the CMS </returns> public static Cms of(CmsLeg cmsLeg, SwapLeg payLeg) { return(new Cms(cmsLeg, payLeg)); }
//------------------------------------------------------------------------- /// <summary> /// Obtains an instance from a CMS leg with no pay leg. /// <para> /// The pay leg is absent in the resulting CMS. /// /// </para> /// </summary> /// <param name="cmsLeg"> the CMS leg </param> /// <returns> the CMS </returns> public static Cms of(CmsLeg cmsLeg) { return(new Cms(cmsLeg, null)); }
internal static CmsLeg sutFloor() { return(CmsLeg.builder().floorSchedule(FLOOR).index(SwapIndices.USD_LIBOR_1100_10Y).notional(ValueSchedule.of(1.e6)).payReceive(PAY).paymentSchedule(SCHEDULE).fixingRelativeTo(FixingRelativeTo.PERIOD_END).fixingDateOffset(FIXING_OFFSET).paymentDateOffset(FIXING_OFFSET).dayCount(ACT_365_ACTUAL).build()); }
//------------------------------------------------------------------------- internal static CmsLeg sutCap() { return(CmsLeg.builder().capSchedule(CAP).index(INDEX).notional(NOTIONAL).payReceive(RECEIVE).paymentSchedule(SCHEDULE_EUR).build()); }
internal static Cms sutFloor() { return(Cms.of(CmsLeg.builder().floorSchedule(STRIKE).index(INDEX).notional(NOTIONAL).payReceive(RECEIVE).paymentSchedule(SCHEDULE_EUR).build())); }