@Test /** Tests the present value curve sensitivity. */ public void presentValueCurveSensitivity() { double spread = 0.0001; // Relative spread. double strikeM = STRIKE * (1 - spread); double strikeP = STRIKE * (1 + spread); Forex forexM = new Forex( FOREX.getPaymentCurrency1().withAmount(1.0), FOREX.getPaymentCurrency2().withAmount(-strikeM)); Forex forexP = new Forex( FOREX.getPaymentCurrency1().withAmount(1.0), FOREX.getPaymentCurrency2().withAmount(-strikeP)); ForexOptionVanilla vanillaM = new ForexOptionVanilla(forexM, FOREX_CALL_OPTION.getExpirationTime(), IS_CALL, IS_LONG); ForexOptionVanilla vanillaP = new ForexOptionVanilla(forexP, FOREX_CALL_OPTION.getExpirationTime(), IS_CALL, IS_LONG); MultipleCurrencyInterestRateCurveSensitivity pvcsP = METHOD_VANILLA_BLACK.presentValueCurveSensitivity(vanillaP, SMILE_BUNDLE); MultipleCurrencyInterestRateCurveSensitivity pvcsM = METHOD_VANILLA_BLACK.presentValueCurveSensitivity(vanillaM, SMILE_BUNDLE); MultipleCurrencyInterestRateCurveSensitivity pvcsExpected = pvcsM .plus(pvcsP.multipliedBy(-1.0)) .multipliedBy( 1.0 / (strikeP - strikeM) * Math.abs(FOREX.getPaymentCurrency2().getAmount())); MultipleCurrencyInterestRateCurveSensitivity pvcsComputed = METHOD_DIGITAL_SPREAD.presentValueCurveSensitivity(FOREX_CALL_OPTION, SMILE_BUNDLE); assertTrue( "Forex Digital option: call spread method - present value", MultipleCurrencyInterestRateCurveSensitivity.compare( pvcsExpected, pvcsComputed, TOLERANCE_DELTA)); }
@Test /** Tests the present value curve sensitivity. Method vs Calculator. */ public void presentValueCurveSensitivityMethodVCalculator() { MultipleCurrencyInterestRateCurveSensitivity pvcsMethod = METHOD_DIGITAL_SPREAD.presentValueCurveSensitivity(FOREX_CALL_OPTION, SMILE_BUNDLE); PresentValueCurveSensitivityCallSpreadBlackForexCalculator calculator = new PresentValueCurveSensitivityCallSpreadBlackForexCalculator(STANDARD_SPREAD); MultipleCurrencyInterestRateCurveSensitivity pvcsCalculator = calculator.visit(FOREX_CALL_OPTION, SMILE_BUNDLE); assertTrue( "Forex Digital option: call spread method - present value", MultipleCurrencyInterestRateCurveSensitivity.compare( pvcsMethod, pvcsCalculator, TOLERANCE_DELTA)); }