BondSecurityDiscountingMethod { public MulticurveSensitivity dirtyPriceCurveSensitivity(final BondFixedSecurity bond, final IssuerProviderInterface issuerMulticurves) { ArgumentChecker.notNull(bond, "Bond"); ArgumentChecker.notNull(issuerMulticurves, "Issuer and multi-curves provider"); final MulticurveProviderInterface multicurves = issuerMulticurves.getMulticurveProvider(); final Currency ccy = bond.getCurrency(); final double notional = bond.getCoupon().getNthPayment(0).getNotional(); final MultipleCurrencyAmount pv = presentValue(bond, issuerMulticurves); final MultipleCurrencyMulticurveSensitivity sensiPv = presentValueCurveSensitivity(bond, issuerMulticurves); final double df = multicurves.getDiscountFactor(ccy, bond.getSettlementTime()); final Map<String, List<DoublesPair>> resultMap = new HashMap<>(); final List<DoublesPair> listDf = new ArrayList<>(); listDf.add(DoublesPair.of(bond.getSettlementTime(), bond.getSettlementTime() / df)); resultMap.put(multicurves.getName(ccy), listDf); MulticurveSensitivity result = MulticurveSensitivity.ofYieldDiscounting(resultMap); result = result.multipliedBy(pv.getAmount(ccy) / notional); result = result.plus(sensiPv.getSensitivity(ccy).multipliedBy(1 / (df * notional))); return result; } 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 dirtyPriceCurveSensitivity() { MulticurveSensitivity sensi = METHOD_BOND_SECURITY.dirtyPriceCurveSensitivity(BOND_FIXED_SECURITY_NO_ENTITY_1, ISSUER_SPECIFIC_MULTICURVES).cleaned(); sensi = sensi.cleaned(); final MultipleCurrencyAmount pv = METHOD_BOND_SECURITY.presentValue(BOND_FIXED_SECURITY_NO_ENTITY_1, ISSUER_SPECIFIC_MULTICURVES); final double dfSettle = ISSUER_SPECIFIC_MULTICURVES.getMulticurveProvider().getDiscountFactor(CUR, BOND_FIXED_SECURITY_NO_ENTITY_1.getSettlementTime()); final String DSC_CURVE_NAME = ISSUER_SPECIFIC_MULTICURVES.getMulticurveProvider().getName(CUR); final String ISS_CURVE_NAME = ISSUER_SPECIFIC_MULTICURVES.getName(BOND_FIXED_SECURITY_NO_ENTITY_1.getIssuerEntity()); assertEquals("Fixed coupon bond security: dirty price curve sensitivity: risk-less curve", BOND_FIXED_SECURITY_NO_ENTITY_1.getSettlementTime(), sensi.getYieldDiscountingSensitivities().get(DSC_CURVE_NAME) .get(0).first, TOLERANCE_PV_DELTA); assertEquals("Fixed coupon bond security: dirty price curve sensitivity: risk-less curve", BOND_FIXED_SECURITY_NO_ENTITY_1.getSettlementTime() / dfSettle * pv.getAmount(CUR) / NOTIONAL, sensi .getYieldDiscountingSensitivities().get(DSC_CURVE_NAME).get(0).second, TOLERANCE_PV_DELTA); final double dfCpn0 = ISSUER_SPECIFIC_MULTICURVES.getMulticurveProvider().getDiscountFactor(BOND_FIXED_SECURITY_NO_ENTITY_1.getCurrency(), BOND_FIXED_SECURITY_NO_ENTITY_1.getCoupon().getNthPayment(0).getPaymentTime()); assertEquals("Fixed coupon bond security: dirty price curve sensitivity: repo curve", BOND_FIXED_SECURITY_NO_ENTITY_1.getCoupon().getNthPayment(0).getPaymentTime(), sensi .getYieldDiscountingSensitivities() .get(ISS_CURVE_NAME).get(0).first, TOLERANCE_PV_DELTA); assertEquals("Fixed coupon bond security: dirty price curve sensitivity: repo curve", -BOND_FIXED_SECURITY_NO_ENTITY_1.getCoupon().getNthPayment(0).getPaymentTime() * BOND_FIXED_SECURITY_NO_ENTITY_1.getCoupon().getNthPayment(0).getAmount() * dfCpn0 / dfSettle / NOTIONAL, sensi.getYieldDiscountingSensitivities().get(ISS_CURVE_NAME).get(0).second, TOLERANCE_PV_DELTA); }