//------------------------------------------------------------------------- public virtual void test_yearFraction() { ResolvedFixedCouponBond test = sut(); FixedCouponBondPaymentPeriod period = test.PeriodicPayments.get(0); assertEquals(test.yearFraction(period.UnadjustedStartDate, period.UnadjustedEndDate), period.YearFraction); }
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); }