public void implied_volatility_round_trip() {
CurrencyAmount pvLongRec =
PRICER_SWAPTION_NORMAL.presentValue(SWAPTION_LONG_REC, MULTI_USD, NORMAL_VOLS_USD_STD);
double impliedLongRecComputed = PRICER_SWAPTION_NORMAL.impliedVolatilityFromPresentValue(
SWAPTION_LONG_REC, MULTI_USD, ACT_365F, pvLongRec.getAmount());
double impliedLongRecInterpolated =
PRICER_SWAPTION_NORMAL.impliedVolatility(SWAPTION_LONG_REC, MULTI_USD, NORMAL_VOLS_USD_STD);
assertEquals(impliedLongRecComputed, impliedLongRecInterpolated, TOLERANCE_RATE);
CurrencyAmount pvShortRec =
PRICER_SWAPTION_NORMAL.presentValue(SWAPTION_SHORT_REC, MULTI_USD, NORMAL_VOLS_USD_STD);
double impliedShortRecComputed = PRICER_SWAPTION_NORMAL.impliedVolatilityFromPresentValue(
SWAPTION_SHORT_REC, MULTI_USD, ACT_365F, pvShortRec.getAmount());
double impliedShortRecInterpolated =
PRICER_SWAPTION_NORMAL.impliedVolatility(SWAPTION_SHORT_REC, MULTI_USD, NORMAL_VOLS_USD_STD);
assertEquals(impliedShortRecComputed, impliedShortRecInterpolated, TOLERANCE_RATE);
CurrencyAmount pvLongPay =
PRICER_SWAPTION_NORMAL.presentValue(SWAPTION_LONG_PAY, MULTI_USD, NORMAL_VOLS_USD_STD);
double impliedLongPayComputed = PRICER_SWAPTION_NORMAL.impliedVolatilityFromPresentValue(
SWAPTION_LONG_PAY, MULTI_USD, ACT_365F, pvLongPay.getAmount());
double impliedLongPayInterpolated =
PRICER_SWAPTION_NORMAL.impliedVolatility(SWAPTION_LONG_PAY, MULTI_USD, NORMAL_VOLS_USD_STD);
assertEquals(impliedLongPayComputed, impliedLongPayInterpolated, TOLERANCE_RATE);
}