BondFixedTransactionDefinition extends BondTransactionDefinition<PaymentFixedDefinition, CouponFixedDefinition> { public double getAccruedInterestAtSettlement() { return _accruedInterestAtSettlement; } BondFixedTransactionDefinition(final BondFixedSecurityDefinition underlyingBond, final double quantity, 
      final ZonedDateTime settlementDate, final double cleanPrice); static BondFixedTransactionDefinition fromYield(final BondFixedSecurityDefinition underlyingBond, 
      final double quantity, final ZonedDateTime settlementDate, final double yield); double getAccruedInterestAtSettlement(); @Override BondFixedSecurityDefinition getUnderlyingBond(); @Override BondFixedTransaction toDerivative(final ZonedDateTime date); @Override V accept(final InstrumentDefinitionVisitor<U, V> visitor, final U data); @Override V accept(final InstrumentDefinitionVisitor<?, V> visitor); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void settlementExCoupon() { ZonedDateTime settleDate = DateUtils.getUTCDate(2011, 9, 2); BondFixedTransactionDefinition transaction = new BondFixedTransactionDefinition(BOND_UKT_500_20140907, QUANTITY, settleDate, PRICE_DIRTY); int cpnIndex = transaction.getCouponIndex(); CouponFixedDefinition cpn = BOND_UKT_500_20140907.getCoupons().getNthPayment(cpnIndex); double cpnAccrued = cpn.getAmount() / cpn.getNotional(); final int nbCoupon = BOND_UKT_500_20140907.getCoupons().getNumberOfPayments(); double accruedUndajusted = AccruedInterestCalculator.getAccruedInterest(BOND_UKT_500_20140907.getDayCount(), cpnIndex, nbCoupon, transaction.getPreviousAccrualDate(), settleDate, transaction.getNextAccrualDate(), cpn.getRate(), BOND_UKT_500_20140907.getCouponPerYear(), BOND_UKT_500_20140907.isEOM()); double accruedAtSettle = accruedUndajusted - cpnAccrued; double accruedComputed = transaction.getAccruedInterestAtSettlement(); assertTrue("BondFixedTransactionDefinition: ex-coupon accrued negative", accruedComputed < 0.0); assertEquals("BondFixedTransactionDefinition", accruedAtSettle, accruedComputed, TOLERANCE_ACCRUED); }
@Test public void settlementUKTAllDate() { ZonedDateTime settleDate = DateUtils.getUTCDate(2011, 8, 1); int nbSettle = 40; double[] accruedSettle = new double[nbSettle]; for (int loopsettle = 0; loopsettle < nbSettle; loopsettle++) { settleDate = ScheduleCalculator.getAdjustedDate(settleDate, 1, CALENDAR); BondFixedTransactionDefinition transaction = new BondFixedTransactionDefinition(BOND_UKT_500_20140907, QUANTITY, settleDate, PRICE_DIRTY); accruedSettle[loopsettle] = transaction.getAccruedInterestAtSettlement(); } int indexJump = 19; for (int loopref = 0; loopref < nbSettle - 1; loopref++) { if (loopref != indexJump) { assertTrue("Bond Fixed Security Definition to derivative - " + loopref, accruedSettle[loopref + 1] - accruedSettle[loopref] < 0.05 / 360 * 3); } } @SuppressWarnings("unused") int t = 0; }