public virtual void test_resolve() { BusinessDayAdjustment bussAdj = BusinessDayAdjustment.of(FOLLOWING, SAT_SUN); ResolvedCds test = PRODUCT_STD.resolve(REF_DATA); int nDates = 44; LocalDate[] dates = new LocalDate[nDates]; for (int i = 0; i < nDates; ++i) { dates[i] = START_DATE.plusMonths(3 * i); } IList <CreditCouponPaymentPeriod> payments = new List <CreditCouponPaymentPeriod>(nDates - 1); for (int i = 0; i < nDates - 2; ++i) { LocalDate start = i == 0 ? dates[i] : bussAdj.adjust(dates[i], REF_DATA); LocalDate end = bussAdj.adjust(dates[i + 1], REF_DATA); payments.Add(CreditCouponPaymentPeriod.builder().startDate(start).endDate(end).unadjustedStartDate(dates[i]).unadjustedEndDate(dates[i + 1]).effectiveStartDate(start.minusDays(1)).effectiveEndDate(end.minusDays(1)).paymentDate(end).currency(USD).notional(NOTIONAL).fixedRate(COUPON).yearFraction(ACT_360.relativeYearFraction(start, end)).build()); } LocalDate start = bussAdj.adjust(dates[nDates - 2], REF_DATA); LocalDate end = dates[nDates - 1]; payments.Add(CreditCouponPaymentPeriod.builder().startDate(start).endDate(end.plusDays(1)).unadjustedStartDate(dates[nDates - 2]).unadjustedEndDate(end).effectiveStartDate(start.minusDays(1)).effectiveEndDate(end).paymentDate(bussAdj.adjust(end, REF_DATA)).currency(USD).notional(NOTIONAL).fixedRate(COUPON).yearFraction(ACT_360.relativeYearFraction(start, end.plusDays(1))).build()); ResolvedCds expected = ResolvedCds.builder().buySell(BUY).legalEntityId(LEGAL_ENTITY).dayCount(ACT_360).paymentOnDefault(ACCRUED_PREMIUM).paymentPeriods(payments).protectionStart(BEGINNING).protectionEndDate(END_DATE).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); assertEquals(test, expected); }
//------------------------------------------------------------------------- public virtual void coverage() { CreditCouponPaymentPeriod test1 = CreditCouponPaymentPeriod.builder().currency(USD).notional(NOTIONAL).startDate(START_DATE).endDate(END_DATE).effectiveStartDate(EFF_START_DATE).effectiveEndDate(EFF_END_DATE).paymentDate(END_DATE).fixedRate(COUPON).yearFraction(YEAR_FRACTION).build(); coverImmutableBean(test1); CreditCouponPaymentPeriod test2 = CreditCouponPaymentPeriod.builder().currency(Currency.JPY).notional(5.0e6).startDate(START_DATE.minusDays(7)).endDate(END_DATE.minusDays(7)).effectiveStartDate(EFF_START_DATE.minusDays(7)).effectiveEndDate(EFF_END_DATE.minusDays(7)).paymentDate(END_DATE.minusDays(7)).fixedRate(0.01).yearFraction(0.25).build(); coverBeanEquals(test1, test2); }
public virtual void test_contains() { CreditCouponPaymentPeriod test = CreditCouponPaymentPeriod.builder().currency(USD).notional(NOTIONAL).startDate(START_DATE).endDate(END_DATE).effectiveStartDate(EFF_START_DATE).effectiveEndDate(EFF_END_DATE).paymentDate(END_DATE).fixedRate(COUPON).yearFraction(YEAR_FRACTION).build(); assertTrue(test.contains(START_DATE)); assertTrue(test.contains(START_DATE.plusMonths(1))); assertFalse(test.contains(END_DATE)); assertFalse(test.contains(START_DATE.minusDays(1))); }
public virtual void test_builder() { CreditCouponPaymentPeriod test = CreditCouponPaymentPeriod.builder().currency(USD).notional(NOTIONAL).startDate(START_DATE).endDate(END_DATE).effectiveStartDate(EFF_START_DATE).effectiveEndDate(EFF_END_DATE).paymentDate(END_DATE).fixedRate(COUPON).yearFraction(YEAR_FRACTION).build(); assertEquals(test.Currency, USD); assertEquals(test.EffectiveStartDate, EFF_START_DATE); assertEquals(test.EffectiveEndDate, EFF_END_DATE); assertEquals(test.StartDate, START_DATE); assertEquals(test.EndDate, END_DATE); assertEquals(test.FixedRate, COUPON); assertEquals(test.Notional, NOTIONAL); assertEquals(test.PaymentDate, END_DATE); assertEquals(test.YearFraction, YEAR_FRACTION); }
static ResolvedCdsIndexTest() { int nDates = 44; LocalDate[] dates = new LocalDate[nDates]; for (int i = 0; i < nDates; ++i) { dates[i] = START_DATE.plusMonths(3 * i); } for (int i = 0; i < nDates - 2; ++i) { LocalDate start = i == 0 ? dates[i] : BUSS_ADJ.adjust(dates[i], REF_DATA); LocalDate end = BUSS_ADJ.adjust(dates[i + 1], REF_DATA); PAYMENTS.Add(CreditCouponPaymentPeriod.builder().startDate(start).endDate(end).effectiveStartDate(start.minusDays(1)).effectiveEndDate(end.minusDays(1)).paymentDate(end).currency(USD).notional(NOTIONAL).fixedRate(COUPON).yearFraction(ACT_360.relativeYearFraction(start, end)).build()); } LocalDate start = BUSS_ADJ.adjust(dates[nDates - 2], REF_DATA); LocalDate end = dates[nDates - 1]; PAYMENTS.Add(CreditCouponPaymentPeriod.builder().startDate(start).endDate(end.plusDays(1)).effectiveStartDate(start.minusDays(1)).effectiveEndDate(end).paymentDate(BUSS_ADJ.adjust(end, REF_DATA)).currency(USD).notional(NOTIONAL).fixedRate(COUPON).yearFraction(ACT_360.relativeYearFraction(start, end.plusDays(1))).build()); }
public virtual void test_serialization() { CreditCouponPaymentPeriod test = CreditCouponPaymentPeriod.builder().currency(USD).notional(NOTIONAL).startDate(START_DATE).endDate(END_DATE).effectiveStartDate(EFF_START_DATE).effectiveEndDate(EFF_END_DATE).paymentDate(END_DATE).fixedRate(COUPON).yearFraction(YEAR_FRACTION).build(); assertSerialization(test); }