@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 dirty real price computation from the real yield in the "US I/L real" convention. */ public void dirtyRealPriceFromRealYieldTips1() { final double[] yield = new double[] {-0.01, 0.00, 0.01, 0.02, 0.03}; final int nbCoupon = BOND_SECURITY_TIPS_1.getCoupon().getNumberOfPayments(); final double[] dirtyRealPrice = new double[yield.length]; final double[] dirtyRealPriceExpected = new double[yield.length]; for (int loopyield = 0; loopyield < yield.length; loopyield++) { dirtyRealPrice[loopyield] = METHOD_BOND_INFLATION.dirtyPriceFromRealYield(BOND_SECURITY_TIPS_1, yield[loopyield]); final double factorOnPeriod = 1 + yield[loopyield] / BOND_SECURITY_TIPS_1.getCouponPerYear(); double pvAtFirstCoupon = 0; for (int loopcpn = 0; loopcpn < nbCoupon; loopcpn++) { pvAtFirstCoupon += ((CouponInflationGearing) BOND_SECURITY_TIPS_1.getCoupon().getNthPayment(loopcpn)) .getFactor() / BOND_SECURITY_TIPS_1.getCouponPerYear() / Math.pow(factorOnPeriod, loopcpn); } pvAtFirstCoupon += 1.0 / Math.pow(factorOnPeriod, nbCoupon - 1); dirtyRealPriceExpected[loopyield] = pvAtFirstCoupon / (1 + BOND_SECURITY_TIPS_1.getAccrualFactorToNextCoupon() * yield[loopyield] / BOND_SECURITY_TIPS_1.getCouponPerYear()); assertEquals( "Inflation Capital Indexed bond: yield " + loopyield, dirtyRealPriceExpected[loopyield], dirtyRealPrice[loopyield], 1.0E-8); } }
/** Tests the present value computation. */ public void presentValueTips1() { final InflationProviderDiscount marketUSGovt = new InflationProviderDiscount(); marketUSGovt.setCurve( BOND_SECURITY_TIPS_1.getCurrency(), MARKET.getCurve(BOND_SECURITY_TIPS_1.getIssuerEntity())); marketUSGovt.setCurve(PRICE_INDEX_USCPI, MARKET.getCurve(PRICE_INDEX_USCPI)); final MultiCurrencyAmount pvNominal = METHOD_INFLATION_ZC_INTERPOLATION.presentValue( (CouponInflationZeroCouponInterpolationGearing) BOND_SECURITY_TIPS_1.getNominal().getNthPayment(0), marketUSGovt); MultiCurrencyAmount pvCoupon = MultiCurrencyAmount.of(BOND_SECURITY_TIPS_1.getCurrency(), 0.0); for (int loopcpn = 0; loopcpn < BOND_SECURITY_TIPS_1.getCoupon().getNumberOfPayments(); loopcpn++) { pvCoupon = pvCoupon.plus( BOND_SECURITY_TIPS_1.getCoupon().getNthPayment(loopcpn).accept(PVDIC, marketUSGovt)); } final MultiCurrencyAmount pvExpected = pvNominal.plus(pvCoupon); final MultiCurrencyAmount pv = METHOD_BOND_INFLATION.presentValue(BOND_SECURITY_TIPS_1, MARKET); assertEquals( "Inflation Capital Indexed bond: present value", pvExpected.getAmount(BOND_SECURITY_TIPS_1.getCurrency()).getAmount(), pv.getAmount(BOND_SECURITY_TIPS_1.getCurrency()).getAmount(), 1.0E-2); }
/** Test the present value curves sensitivity. */ public void presentValueCurveSensitivityCAIN() { MulticurveProviderInterface multicurveDecorated = new MulticurveProviderDiscountingDecoratedIssuer( MARKET.getIssuerProvider(), BOND_SECURITY_CAIN.getCurrency(), BOND_SECURITY_CAIN.getIssuerEntity()); InflationProviderInterface creditDiscounting = new InflationProviderDecoratedMulticurve( MARKET.getInflationProvider(), multicurveDecorated); final MultipleCurrencyInflationSensitivity sensitivityNominal = BOND_SECURITY_CAIN.getNominal().accept(PVCSDC, creditDiscounting); final MultipleCurrencyInflationSensitivity sensitivityCoupon = BOND_SECURITY_CAIN.getCoupon().accept(PVCSDC, creditDiscounting); final MultipleCurrencyInflationSensitivity pvcisCalculated = sensitivityNominal.plus(sensitivityCoupon); final MultipleCurrencyInflationSensitivity pvcisMethod = METHOD_BOND_INFLATION.presentValueCurveSensitivity(BOND_SECURITY_CAIN, MARKET); AssertSensitivityObjects.assertEquals( "Bond capital indexed security: presentValueCurveSensitivity ", pvcisCalculated, pvcisMethod, TOLERANCE_PV_DELTA); }
/** 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); } }
/** Tests the clean real price from the dirty real price. */ public void cleanRealFromDirtyRealTips1() { final double dirtyReal = 1.01; final double cleanReal = METHOD_BOND_INFLATION.cleanRealPriceFromDirtyRealPrice(BOND_SECURITY_TIPS_1, dirtyReal); final double cleanRealExpected = dirtyReal - BOND_SECURITY_TIPS_1.getAccruedInterest() / NOTIONAL_TIPS_1; assertEquals( "Inflation Capital Indexed bond: clean from dirty", cleanRealExpected, cleanReal, 1.0E-8); }
/** Tests the present value computation. */ public void presentValueFromCleanPriceRealTips1() { final double cleanPriceReal = 1.05; Currency ccy = BOND_SECURITY_TIPS_1.getCurrency(); final MultiCurrencyAmount pv = METHOD_BOND_INFLATION.presentValueFromCleanRealPrice( BOND_SECURITY_TIPS_1, MARKET, cleanPriceReal); MultiCurrencyAmount pvPriceReal = BOND_SECURITY_TIPS_1.getSettlement().accept(PVDIIC, MARKET).multipliedBy(cleanPriceReal); MultiCurrencyAmount pvAccrued = BOND_SECURITY_TIPS_1 .getSettlement() .accept(PVDIC, MARKET) .multipliedBy(BOND_SECURITY_TIPS_1.getAccruedInterest()); MultiCurrencyAmount pvExpected = pvPriceReal.plus(pvAccrued); assertEquals( "Inflation Capital Indexed bond: present value from clean real price", pvExpected.getAmount(ccy).getAmount(), pv.getAmount(ccy).getAmount(), 1.0E-6); }
/** Tests the present value Method vs Calculator. */ public void presentValueMethodVsCalculator() { final MultiCurrencyAmount pvMethod = METHOD_BOND_INFLATION.presentValue(BOND_SECURITY_GILT_1, MARKET); final MultiCurrencyAmount pvCalculator = BOND_SECURITY_GILT_1.accept(PVDIIC, MARKET); assertEquals("Inflation Capital Indexed bond: present value", pvMethod, pvCalculator); }