//-------------------------------------------------------------------------
        public virtual void test_yearFraction()
        {
            ResolvedFixedCouponBond      test   = sut();
            FixedCouponBondPaymentPeriod period = test.PeriodicPayments.get(0);

            assertEquals(test.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), period.YearFraction);
        }
Ejemplo n.º 2
0
        public virtual void test_of()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertEquals(test.Currency, USD);
            assertEquals(test.UnadjustedStartDate, START);
            assertEquals(test.StartDate, START_ADJUSTED);
            assertEquals(test.UnadjustedEndDate, END);
            assertEquals(test.EndDate, END_ADJUSTED);
            assertEquals(test.PaymentDate, END_ADJUSTED);
            assertEquals(test.DetachmentDate, DETACHMENT_DATE);
            assertEquals(test.FixedRate, FIXED_RATE);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.YearFraction, YEAR_FRACTION);
            assertEquals(test.hasExCouponPeriod(), true);

            // the object is not changed
            assertEquals(test.adjustPaymentDate(TemporalAdjusters.ofDateAdjuster(d => d.plusDays(2))), test);
            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            test.collectIndices(builder);
            assertEquals(test.Currency, USD);
            assertEquals(test.UnadjustedStartDate, START);
            assertEquals(test.StartDate, START_ADJUSTED);
            assertEquals(test.UnadjustedEndDate, END);
            assertEquals(test.EndDate, END_ADJUSTED);
            assertEquals(test.PaymentDate, END_ADJUSTED);
            assertEquals(test.DetachmentDate, DETACHMENT_DATE);
            assertEquals(test.FixedRate, FIXED_RATE);
            assertEquals(test.Notional, NOTIONAL);
            assertEquals(test.YearFraction, YEAR_FRACTION);
            assertEquals(test.hasExCouponPeriod(), true);
        }
Ejemplo n.º 3
0
        public virtual void test_resolve()
        {
            FixedCouponBond         @base    = sut();
            ResolvedFixedCouponBond resolved = @base.resolve(REF_DATA);

            assertEquals(resolved.LegalEntityId, LEGAL_ENTITY);
            assertEquals(resolved.SettlementDateOffset, DATE_OFFSET);
            assertEquals(resolved.YieldConvention, YIELD_CONVENTION);
            ImmutableList <FixedCouponBondPaymentPeriod> periodicPayments = resolved.PeriodicPayments;
            int expNum = 20;

            assertEquals(periodicPayments.size(), expNum);
            LocalDate unadjustedEnd = END_DATE;
            Schedule  unadjusted    = PERIOD_SCHEDULE.createSchedule(REF_DATA).toUnadjusted();

            for (int i = 0; i < expNum; ++i)
            {
                FixedCouponBondPaymentPeriod payment = periodicPayments.get(expNum - 1 - i);
                assertEquals(payment.Currency, EUR);
                assertEquals(payment.Notional, NOTIONAL);
                assertEquals(payment.FixedRate, FIXED_RATE);
                assertEquals(payment.UnadjustedEndDate, unadjustedEnd);
                assertEquals(payment.EndDate, BUSINESS_ADJUST.adjust(unadjustedEnd, REF_DATA));
                assertEquals(payment.PaymentDate, payment.EndDate);
                LocalDate unadjustedStart = unadjustedEnd.minusMonths(6);
                assertEquals(payment.UnadjustedStartDate, unadjustedStart);
                assertEquals(payment.StartDate, BUSINESS_ADJUST.adjust(unadjustedStart, REF_DATA));
                assertEquals(payment.YearFraction, unadjusted.getPeriod(expNum - 1 - i).yearFraction(DAY_COUNT, unadjusted));
                assertEquals(payment.DetachmentDate, EX_COUPON.adjust(payment.PaymentDate, REF_DATA));
                unadjustedEnd = unadjustedStart;
            }
            Payment expectedPayment = Payment.of(CurrencyAmount.of(EUR, NOTIONAL), BUSINESS_ADJUST.adjust(END_DATE, REF_DATA));

            assertEquals(resolved.NominalPayment, expectedPayment);
        }
Ejemplo n.º 4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FixedCouponBondPaymentPeriod test1 = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            coverImmutableBean(test1);
            FixedCouponBondPaymentPeriod test2 = FixedCouponBondPaymentPeriod.builder().currency(GBP).startDate(LocalDate.of(2014, 3, 4)).unadjustedStartDate(LocalDate.of(2014, 3, 2)).endDate(LocalDate.of(2015, 3, 4)).unadjustedEndDate(LocalDate.of(2015, 3, 3)).notional(1.0e8).fixedRate(0.005).yearFraction(1d).build();

            coverBeanEquals(test1, test2);
        }
Ejemplo n.º 5
0
        //-------------------------------------------------------------------------
        public virtual void test_contains()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertEquals(test.contains(START.minusDays(1)), false);
            assertEquals(test.contains(START), true);
            assertEquals(test.contains(START.plusDays(1)), true);
            assertEquals(test.contains(END.minusDays(1)), true);
            assertEquals(test.contains(END), false);
        }
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FixedCouponBondPaymentPeriod other = (FixedCouponBondPaymentPeriod)obj;
         return(JodaBeanUtils.equal(currency, other.currency) && JodaBeanUtils.equal(notional, other.notional) && JodaBeanUtils.equal(startDate, other.startDate) && JodaBeanUtils.equal(endDate, other.endDate) && JodaBeanUtils.equal(unadjustedStartDate, other.unadjustedStartDate) && JodaBeanUtils.equal(unadjustedEndDate, other.unadjustedEndDate) && JodaBeanUtils.equal(detachmentDate, other.detachmentDate) && JodaBeanUtils.equal(fixedRate, other.fixedRate) && JodaBeanUtils.equal(yearFraction, other.yearFraction));
     }
     return(false);
 }
        public virtual void test_yearFraction_scheduleInfo()
        {
            ResolvedFixedCouponBond      @base  = sut();
            FixedCouponBondPaymentPeriod period = @base.PeriodicPayments.get(0);
            AtomicBoolean           eom         = new AtomicBoolean(false);
            DayCount                dc          = new DayCountAnonymousInnerClass(this, @base, period, eom);
            ResolvedFixedCouponBond test        = @base.toBuilder().dayCount(dc).build();

            assertEquals(test.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), 0.5);
            // test with EOM=true
            ResolvedFixedCouponBond test2 = test.toBuilder().rollConvention(RollConventions.EOM).build();

            eom.set(true);
            assertEquals(test2.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), 0.5);
        }
Ejemplo n.º 8
0
 public virtual void test_of_wrongDates()
 {
     assertThrowsIllegalArg(() => FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(LocalDate.of(2015, 2, 3)).unadjustedEndDate(LocalDate.of(2015, 2, 2)).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build());
     assertThrowsIllegalArg(() => FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(LocalDate.of(2015, 8, 3)).unadjustedStartDate(LocalDate.of(2015, 8, 2)).endDate(LocalDate.of(2015, 8, 3)).unadjustedEndDate(LocalDate.of(2015, 8, 3)).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build());
     assertThrowsIllegalArg(() => FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(LocalDate.of(2015, 8, 6)).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build());
 }
Ejemplo n.º 9
0
        public virtual void test_of_noExCoupon()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(END_ADJUSTED).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertEquals(test.hasExCouponPeriod(), false);
        }
Ejemplo n.º 10
0
        public virtual void test_serialization()
        {
            FixedCouponBondPaymentPeriod test = FixedCouponBondPaymentPeriod.builder().currency(USD).startDate(START_ADJUSTED).unadjustedStartDate(START).endDate(END_ADJUSTED).unadjustedEndDate(END).detachmentDate(DETACHMENT_DATE).notional(NOTIONAL).fixedRate(FIXED_RATE).yearFraction(YEAR_FRACTION).build();

            assertSerialization(test);
        }