コード例 #1
0
 @Test
 public void test() {
   final CouponIborDefinition[] coupons = new CouponIborDefinition[PAYMENT_DATES.length];
   final double sign = IS_PAYER ? -1.0 : 1.0;
   // First coupon uses settlement date
   CouponFixedDefinition coupon =
       new CouponFixedDefinition(
           CUR,
           PAYMENT_DATES[0],
           SETTLEMENT_DATE,
           PAYMENT_DATES[0],
           DAY_COUNT.getDayCountFraction(SETTLEMENT_DATE, PAYMENT_DATES[0]),
           sign * NOTIONAL,
           0.0);
   ZonedDateTime fixingDate =
       ScheduleCalculator.getAdjustedDate(
           SETTLEMENT_DATE, BUSINESS_DAY, CALENDAR, -SETTLEMENT_DAYS);
   coupons[0] = CouponIborDefinition.from(coupon, fixingDate, INDEX);
   for (int loopcpn = 1; loopcpn < PAYMENT_DATES.length; loopcpn++) {
     coupon =
         new CouponFixedDefinition(
             CUR,
             PAYMENT_DATES[loopcpn],
             PAYMENT_DATES[loopcpn - 1],
             PAYMENT_DATES[loopcpn],
             DAY_COUNT.getDayCountFraction(PAYMENT_DATES[loopcpn - 1], PAYMENT_DATES[loopcpn]),
             sign * NOTIONAL,
             0.0);
     fixingDate =
         ScheduleCalculator.getAdjustedDate(
             PAYMENT_DATES[loopcpn - 1], BUSINESS_DAY, CALENDAR, -SETTLEMENT_DAYS);
     coupons[loopcpn] = CouponIborDefinition.from(coupon, fixingDate, INDEX);
   }
   final AnnuityCouponIborDefinition iborAnnuity = new AnnuityCouponIborDefinition(coupons);
   //    assertEquals(iborAnnuity.getPayments(), coupons);
   assertEquals(iborAnnuity.isPayer(), IS_PAYER);
   for (int loopcpn = 0; loopcpn < PAYMENT_DATES.length; loopcpn++) {
     assertEquals(iborAnnuity.getNthPayment(loopcpn), coupons[loopcpn]);
     assertEquals(iborAnnuity.getPayments()[loopcpn], coupons[loopcpn]);
   }
   final AnnuityCouponIborDefinition iborAnnuity2 =
       AnnuityCouponIborDefinition.from(SETTLEMENT_DATE, ANNUITY_TENOR, NOTIONAL, INDEX, IS_PAYER);
   assertEquals(iborAnnuity, iborAnnuity2);
 }
コード例 #2
0
 @Test
 public void testStaticConstruction() {
   AnnuityCouponIborDefinition definition1 =
       AnnuityCouponIborDefinition.from(SETTLEMENT_DATE, ANNUITY_TENOR, NOTIONAL, INDEX, IS_PAYER);
   AnnuityCouponIborDefinition definition2 =
       AnnuityCouponIborDefinition.from(SETTLEMENT_DATE, MATURITY_DATE, NOTIONAL, INDEX, IS_PAYER);
   assertEquals(definition1, definition2);
   assertEquals(IS_PAYER, definition1.isPayer());
   definition2 =
       AnnuityCouponIborDefinition.from(
           SETTLEMENT_DATE, ANNUITY_TENOR, NOTIONAL, INDEX, !IS_PAYER);
   assertFalse(definition1.equals(definition2));
   definition2 =
       AnnuityCouponIborDefinition.from(
           SETTLEMENT_DATE, MATURITY_DATE, NOTIONAL, INDEX, !IS_PAYER);
   assertFalse(definition1.equals(definition2));
   definition1 =
       AnnuityCouponIborDefinition.fromAccrualUnadjusted(
           SETTLEMENT_DATE, MATURITY_DATE, NOTIONAL, INDEX, IS_PAYER);
   definition2 =
       AnnuityCouponIborDefinition.fromAccrualUnadjusted(
           SETTLEMENT_DATE, MATURITY_DATE, NOTIONAL, INDEX, !IS_PAYER);
   assertFalse(definition1.equals(definition2));
 }