BondSecurityDiscountingMethod { public double cleanPriceFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves) { final double dirtyPrice = dirtyPriceFromCurves(bond, issuerMulticurves); return cleanPriceFromDirtyPrice(bond, dirtyPrice); } private  BondSecurityDiscountingMethod(); static BondSecurityDiscountingMethod getInstance(); MultipleCurrencyAmount presentValue(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyAmount presentValueFromCleanPrice(final BondSecurity<? extends Payment, ? extends Coupon> bond, final MulticurveProviderInterface multicurves, final double cleanPrice); MultipleCurrencyAmount presentValueFromYield(final BondSecurity<? extends Payment, ? extends Coupon> bond, final MulticurveProviderInterface multicurves, final double yield); MultipleCurrencyAmount presentValueFromZSpread(final BondSecurity<? extends Payment, ? extends Coupon> bond,
      final IssuerProviderInterface issuerMulticurves, final double zSpread); MultipleCurrencyAmount presentValueFromZSpread(BondSecurity<? extends Payment, ? extends Coupon> bond,
      IssuerProviderInterface issuerMulticurves, double zSpread, boolean periodic, int periodPerYear); double presentValueZSpreadSensitivity(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves, final double zSpread); double dirtyPriceFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves); double dirtyPriceFromCleanPrice(final BondFixedSecurity bond, final double cleanPrice); double dirtyPriceFromYield(final BondFixedSecurity bond, final double yield); MulticurveSensitivity dirtyPriceCurveSensitivity(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves); double cleanPriceFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves); double cleanPriceFromDirtyPrice(final BondFixedSecurity bond, final double dirtyPrice); double cleanPriceFromYield(final BondFixedSecurity bond, final double yield); double yieldFromDirtyPrice(final BondFixedSecurity bond, final double dirtyPrice); double yieldFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves); double yieldFromCleanPrice(final BondFixedSecurity bond, final double cleanPrice); double modifiedDurationFromYield(final BondFixedSecurity bond, final double yield); double modifiedDurationFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves); double modifiedDurationFromDirtyPrice(final BondFixedSecurity bond, final double dirtyPrice); double modifiedDurationFromCleanPrice(final BondFixedSecurity bond, final double cleanPrice); double macaulayDurationFromYield(final BondFixedSecurity bond, final double yield); double macaulayDurationFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves); double macaulayDurationFromCleanPrice(final BondFixedSecurity bond, final double cleanPrice); double macaulayDurationFromDirtyPrice(final BondFixedSecurity bond, final double dirtyPrice); double convexityFromYield(final BondFixedSecurity bond, final double yield); double convexityFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves); double convexityFromDirtyPrice(final BondFixedSecurity bond, final double dirtyPrice); double convexityFromCleanPrice(final BondFixedSecurity bond, final double cleanPrice); double zSpreadFromCurvesAndPV(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves, final MultipleCurrencyAmount pv); double zSpreadFromCurvesAndPV(final BondSecurity<? extends Payment, ? extends Coupon> bond,
      final IssuerProviderInterface issuerMulticurves, final MultipleCurrencyAmount pv, final boolean periodic,
      final int periodPerYear); double presentValueZSpreadSensitivityFromCurvesAndPV(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves,
      final MultipleCurrencyAmount pv); double zSpreadFromCurvesAndClean(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves, final double cleanPrice); double zSpreadFromCurvesAndClean(BondSecurity<? extends Payment, ? extends Coupon> bond,
      IssuerProviderInterface issuerMulticurves, double cleanPrice, boolean periodic, int periodPerYear); double zSpreadFromCurvesAndYield(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves, final double yield); double zSpreadFromCurvesAndYield(BondSecurity<? extends Payment, ? extends Coupon> bond,
      IssuerProviderInterface issuerMulticurves, double yield, boolean periodic, int periodPerYear); double presentValueZSpreadSensitivityFromCurvesAndClean(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves,
      final double cleanPrice); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves); StringAmount presentValueParallelCurveSensitivity(final BondSecurity<? extends Payment, ? extends Coupon> bond, final IssuerProviderInterface issuerMulticurves); double accruedInterestFromYield(final BondFixedSecurity bond, final double yield); double accruedInterestFromDirtyPrice(final BondFixedSecurity bond, final double dirtyPrice); double accruedInterestFromCleanPrice(final BondFixedSecurity bond, final double cleanPrice); double accruedInterestFromCurves(final BondFixedSecurity bond, final IssuerProviderInterface curves);  }
@Test public void cleanPriceSmoothness() { final int nbDateForward = 150; final ZonedDateTime[] forwardDate = new ZonedDateTime[nbDateForward]; forwardDate[0] = ScheduleCalculator.getAdjustedDate(REFERENCE_DATE_2, SETTLEMENT_DAYS, CALENDAR); final long[] jumpDays = new long[nbDateForward - 1]; for (int loopdate = 1; loopdate < nbDateForward; loopdate++) { forwardDate[loopdate] = ScheduleCalculator.getAdjustedDate(forwardDate[loopdate - 1], 1, CALENDAR); jumpDays[loopdate - 1] = forwardDate[loopdate].getLong(JulianFields.MODIFIED_JULIAN_DAY) - forwardDate[loopdate - 1].getLong(JulianFields.MODIFIED_JULIAN_DAY); } final double[] cleanPriceForward = new double[nbDateForward]; for (int loopdate = 0; loopdate < nbDateForward; loopdate++) { final BondFixedSecurity bondForward = BOND_FIXED_SECURITY_DEFINITION_NO_ENTITY.toDerivative(REFERENCE_DATE_2, forwardDate[loopdate]); cleanPriceForward[loopdate] = METHOD_BOND_SECURITY.cleanPriceFromCurves(bondForward, ISSUER_SPECIFIC_MULTICURVES); } final double couponJump = 1.59276E-05; for (int loopdate = 1; loopdate < nbDateForward; loopdate++) { assertEquals("Fixed coupon bond security: clean price smoothness " + loopdate, cleanPriceForward[loopdate] - (loopdate == 87 ? couponJump : 0.0), cleanPriceForward[loopdate - 1] - jumpDays[loopdate - 1] * (0.03425 / 365.0), 3.0E-5); } }