@Override public LocalDate getEndDate() { return getUnadjustedEndDate(); }
public void test_findPeriod() { ResolvedFixedCouponBond test = sut(); ImmutableList<FixedCouponBondPaymentPeriod> payments = test.getPeriodicPayments(); assertEquals(test.findPeriod(test.getUnadjustedStartDate()), Optional.of(payments.get(0))); assertEquals(test.findPeriod(test.getUnadjustedEndDate().minusDays(1)), Optional.of(payments.get(payments.size() - 1))); assertEquals(test.findPeriod(LocalDate.MIN), Optional.empty()); assertEquals(test.findPeriod(LocalDate.MAX), Optional.empty()); }
public void test_getters() { ResolvedFixedCouponBond test = sut(); ImmutableList<FixedCouponBondPaymentPeriod> payments = test.getPeriodicPayments(); assertEquals(test.getStartDate(), payments.get(0).getStartDate()); assertEquals(test.getEndDate(), payments.get(payments.size() - 1).getEndDate()); assertEquals(test.getUnadjustedStartDate(), payments.get(0).getUnadjustedStartDate()); assertEquals(test.getUnadjustedEndDate(), payments.get(payments.size() - 1).getUnadjustedEndDate()); assertEquals(test.hasExCouponPeriod(), true); }
@Override public double yearFraction(LocalDate firstDate, LocalDate secondDate, ScheduleInfo scheduleInfo) { assertEquals(scheduleInfo.getStartDate(), base.getUnadjustedStartDate()); assertEquals(scheduleInfo.getEndDate(), base.getUnadjustedEndDate()); assertEquals(scheduleInfo.getPeriodEndDate(firstDate), period.getUnadjustedEndDate()); assertEquals(scheduleInfo.getFrequency(), base.getFrequency()); assertEquals(scheduleInfo.isEndOfMonthConvention(), eom.get()); return 0.5; }
ArgChecker.inOrderOrEqual(getUnadjustedStartDate(), startDate, "bond.unadjustedStartDate", "startDate"); ArgChecker.inOrderOrEqual(startDate, endDate, "startDate", "endDate"); ArgChecker.inOrderOrEqual(endDate, getUnadjustedEndDate(), "endDate", "bond.unadjustedEndDate");
/** * Calculates the yield of the fixed coupon bond product from dirty price. * <p> * The dirty price must be fractional. * If the analytic formula is not available, the yield is computed by solving * a root-finding problem with {@link #dirtyPriceFromYield(ResolvedFixedCouponBond, LocalDate, double)}. * The result is also expressed in fraction. * * @param bond the product * @param settlementDate the settlement date * @param dirtyPrice the dirty price * @return the yield of the product */ public double yieldFromDirtyPrice(ResolvedFixedCouponBond bond, LocalDate settlementDate, double dirtyPrice) { if (bond.getYieldConvention().equals(JP_SIMPLE)) { double cleanPrice = cleanPriceFromDirtyPrice(bond, settlementDate, dirtyPrice); LocalDate maturityDate = bond.getUnadjustedEndDate(); double maturity = bond.getDayCount().relativeYearFraction(settlementDate, maturityDate); return (bond.getFixedRate() + (1d - cleanPrice) / maturity) / cleanPrice; } final Function<Double, Double> priceResidual = new Function<Double, Double>() { @Override public Double apply(final Double y) { return dirtyPriceFromYield(bond, settlementDate, y) - dirtyPrice; } }; double[] range = ROOT_BRACKETER.getBracketedPoints(priceResidual, 0.00, 0.20); double yield = ROOT_FINDER.getRoot(priceResidual, range[0], range[1]); return yield; }
LocalDate maturityDate = bond.getUnadjustedEndDate(); if (settlementDate.isAfter(maturityDate)) { return 0d;
LocalDate maturityDate = bond.getUnadjustedEndDate(); if (settlementDate.isAfter(maturityDate)) { return 0d;
LocalDate maturityDate = bond.getUnadjustedEndDate(); if (settlementDate.isAfter(maturityDate)) { return 0d;