@Test(enabled = false) /** Tests the clean, dirty and yield vs external hard-coded values. */ public void priceYieldExternalValues1() { final double m1 = 1000000; // Notional of the external figures. final ZonedDateTime pricingDate20110817 = DateUtils.getUTCDate(2011, 8, 16); // Spot 18-Aug-2011 final InflationIssuerProviderDiscount market = MulticurveProviderDiscountDataSets.createMarket1(pricingDate20110817); final double cleanRealPrice = 1.00; final BondCapitalIndexedSecurity<Coupon> bond_110817 = BOND_SECURITY_TIPS_1_DEFINITION.toDerivative(pricingDate20110817, US_CPI); final double referenceIndexExpected = 225.83129; final MultiCurrencyAmount netAmountSettle = bond_110817.getSettlement().accept(NADIC, market.getInflationProvider()); final double referenceIndexComputed = netAmountSettle.getAmount(bond_110817.getCurrency()).getAmount() * BOND_SECURITY_TIPS_1_DEFINITION.getIndexStartValue() / bond_110817.getSettlement().getNotional(); assertEquals( "Inflation Capital Indexed bond: index", referenceIndexExpected, referenceIndexComputed, 1.0E-5); final double indexRatioExpected = 1.13782; final MultiCurrencyAmount indexRatioCalculated = bond_110817.getSettlement().accept(NADIC, market.getInflationProvider()); assertEquals( "Inflation Capital Indexed bond: indexRatio", indexRatioExpected, indexRatioCalculated.getAmount(PRICE_INDEX_USCPI.getCurrency()).getAmount() / NOTIONAL_TIPS_1, 1.0E-5); final double yieldExpected = 1.999644 / 100.0; final double dirtyRealPriceComputed = METHOD_BOND_INFLATION.dirtyRealPriceFromCleanRealPrice(bond_110817, cleanRealPrice); final double yieldComputed = METHOD_BOND_INFLATION.yieldRealFromDirtyRealPrice(bond_110817, dirtyRealPriceComputed); assertEquals("Inflation Capital Indexed bond: yield ", yieldExpected, yieldComputed, 1.0E-8); final double accruedExpected = 2102.49; final double accruedRealExpected = accruedExpected / m1 / indexRatioExpected; final double accruedReal = bond_110817.getAccruedInterest(); assertEquals( "Inflation Capital Indexed bond: accrued", accruedRealExpected, accruedReal / NOTIONAL_TIPS_1, 1.0E-8); final double netAmountExpected = 1139922.49; // For 1m; uses the rounding rules. final double netAmount2 = indexRatioExpected * m1 * cleanRealPrice + accruedExpected; assertEquals( "Inflation Capital Indexed bond: net amount", netAmountExpected, netAmount2, 1.0E-2); final MultiCurrencyAmount netAmount = METHOD_BOND_INFLATION.netAmount(bond_110817, market, cleanRealPrice); assertEquals( "Inflation Capital Indexed bond: net amount", netAmountExpected, netAmount.getAmount(PRICE_INDEX_USCPI.getCurrency()).getAmount() * m1 / NOTIONAL_TIPS_1, 2.0E+0); // The difference is due to rounding. }
/** Tests the clean real price from the dirty real price. */ public void yieldRealFromDirtyRealTips1() { final double[] yield = new double[] {-0.01, 0.00, 0.01, 0.02, 0.03}; final double[] dirtyRealPrice = new double[yield.length]; final double[] yieldComputed = new double[yield.length]; for (int loopyield = 0; loopyield < yield.length; loopyield++) { dirtyRealPrice[loopyield] = METHOD_BOND_INFLATION.dirtyPriceFromRealYield(BOND_SECURITY_TIPS_1, yield[loopyield]); yieldComputed[loopyield] = METHOD_BOND_INFLATION.yieldRealFromDirtyRealPrice( BOND_SECURITY_TIPS_1, dirtyRealPrice[loopyield]); assertEquals( "Inflation Capital Indexed bond: yield " + loopyield, yield[loopyield], yieldComputed[loopyield], 1.0E-8); } }