/** 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 /** Tests the present value. */ public void presentValueNoNotional() { final MultipleCurrencyAmount pv = METHOD.presentValue(ZERO_COUPON_CAP, BLACK_INFLATION); final double timeToMaturity = ZERO_COUPON_CAP.getReferenceEndTime() - ZERO_COUPON_CAP.getLastKnownFixingTime(); final double df = MARKET .getCurve(ZERO_COUPON_CAP.getCurrency()) .getDiscountFactor(ZERO_COUPON_CAP.getPaymentTime()); final double finalIndex = MARKET.getCurve(PRICE_INDEX_EUR).getPriceIndex(ZERO_COUPON_CAP.getReferenceEndTime()); final double forward = finalIndex / INDEX_1MAY_2008; final EuropeanVanillaOption option = new EuropeanVanillaOption( Math.pow(1 + ZERO_COUPON_CAP.getStrike(), ZERO_COUPON_CAP.getMaturity()), timeToMaturity, ZERO_COUPON_CAP.isCap()); final double volatility = BLACK_INFLATION .getBlackParameters() .getVolatility(ZERO_COUPON_CAP.getReferenceEndTime(), ZERO_COUPON_CAP.getStrike()); final BlackFunctionData dataBlack = new BlackFunctionData(forward, 1.0, volatility); final Function1D<BlackFunctionData, Double> func = BLACK_FUNCTION.getPriceFunction(option); final double pvExpected = df * func.evaluate(dataBlack) * ZERO_COUPON_CAP.getNotional() * ZERO_COUPON_CAP.getPaymentYearFraction(); assertEquals( "Zero-coupon inflation DiscountingMethod: Present value", pvExpected, pv.getAmount(ZERO_COUPON_CAP.getCurrency()), TOLERANCE_PV); }