/** * Creates metadata for a surface providing Normal expiry-simple moneyness volatility. * <p> * The x-values represent time to expiry year fractions as defined by the specified day count. * The y-values represent simple moneyness. * The z-values represent Normal volatility. * * @param name the surface name * @param dayCount the day count * @param moneynessType the moneyness type, prices or rates * @return the surface metadata */ public static SurfaceMetadata normalVolatilityByExpirySimpleMoneyness( String name, DayCount dayCount, MoneynessType moneynessType) { return normalVolatilityByExpirySimpleMoneyness(SurfaceName.of(name), dayCount, moneynessType); }
public void normalVolatilityByExpirySimpleMoneyness_string() { SurfaceMetadata test = Surfaces.normalVolatilityByExpirySimpleMoneyness(NAME, ACT_360, MoneynessType.PRICE); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.SIMPLE_MONEYNESS) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(ACT_360) .addInfo(SurfaceInfoType.MONEYNESS_TYPE, MoneynessType.PRICE) .build(); assertEquals(test, expected); }
public void normalVolatilityByExpirySimpleMoneyness_surfaceName() { SurfaceMetadata test = Surfaces.normalVolatilityByExpirySimpleMoneyness(SURFACE_NAME, ACT_360, MoneynessType.PRICE); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.SIMPLE_MONEYNESS) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(ACT_360) .addInfo(SurfaceInfoType.MONEYNESS_TYPE, MoneynessType.PRICE) .build(); assertEquals(test, expected); }
public void test_parameterSensitivity() { double expiry = ACT_365F.relativeYearFraction(VAL_DATE, LocalDate.of(2015, 8, 14)); LocalDate fixing = LocalDate.of(2016, 9, 14); double strikePrice = 1.0025; double futurePrice = 0.9975; double sensitivity = 123456; IborFutureOptionSensitivity point = IborFutureOptionSensitivity.of( VOL_SIMPLE_MONEY_RATE.getName(), expiry, fixing, strikePrice, futurePrice, EUR, sensitivity); CurrencyParameterSensitivities ps = VOL_SIMPLE_MONEY_RATE.parameterSensitivity(point); double shift = 1.0E-6; double v0 = VOL_SIMPLE_MONEY_RATE.volatility(expiry, fixing, strikePrice, futurePrice); for (int i = 0; i < NORMAL_VOL_RATES.size(); i++) { DoubleArray v = NORMAL_VOL_RATES.with(i, NORMAL_VOL_RATES.get(i) + shift); InterpolatedNodalSurface param = InterpolatedNodalSurface.of( Surfaces.normalVolatilityByExpirySimpleMoneyness("Rate", ACT_365F, MoneynessType.RATES), TIMES, MONEYNESS_RATES, v, INTERPOLATOR_2D); NormalIborFutureOptionExpirySimpleMoneynessVolatilities vol = NormalIborFutureOptionExpirySimpleMoneynessVolatilities.of(EUR_EURIBOR_3M, VAL_DATE_TIME, param); double vP = vol.volatility(expiry, fixing, strikePrice, futurePrice); double s = ps.getSensitivity(PARAMETERS_RATE.getName(), EUR).getSensitivity().get(i); assertEquals(s, (vP - v0) / shift * sensitivity, TOLERANCE_DELTA); } }