/** * Creates metadata for a surface providing Black expiry-strike volatility. * <p> * The x-values represent time to expiry year fractions as defined by the specified day count. * The y-values represent strike * The z-values represent Black volatility. * * @param name the surface name * @param dayCount the day count * @return the surface metadata */ public static SurfaceMetadata blackVolatilityByExpiryStrike(String name, DayCount dayCount) { return blackVolatilityByExpiryStrike(SurfaceName.of(name), dayCount); }
@Override public SurfaceMetadata createMetadata(RawOptionData capFloorData) { SurfaceMetadata metadata; if (capFloorData.getDataType().equals(BLACK_VOLATILITY)) { metadata = Surfaces.blackVolatilityByExpiryStrike(name.getName(), dayCount); } else if (capFloorData.getDataType().equals(NORMAL_VOLATILITY)) { metadata = Surfaces.normalVolatilityByExpiryStrike(name.getName(), dayCount); } else { throw new IllegalArgumentException("Data type not supported"); } return metadata; }
/** * Creates metadata for a surface providing Black expiry-tenor volatility. * <p> * The x-values represent time to expiry year fractions as defined by the specified day count. * The y-values represent tenor year fractions. * The z-values represent Black volatility. * * @param name the surface name * @param dayCount the day count * @return the surface metadata */ public static SurfaceMetadata blackVolatilityByExpiryTenor(String name, DayCount dayCount) { return blackVolatilityByExpiryTenor(SurfaceName.of(name), dayCount); }
/** * Creates metadata for a surface providing Normal expiry-strike volatility. * <p> * The x-values represent time to expiry year fractions as defined by the specified day count. * The y-values represent strike * The z-values represent Normal volatility. * * @param name the surface name * @param dayCount the day count * @return the surface metadata */ public static SurfaceMetadata normalVolatilityByExpiryStrike(String name, DayCount dayCount) { return normalVolatilityByExpiryStrike(SurfaceName.of(name), dayCount); }
/** * Creates metadata for a surface providing a SABR expiry-tenor parameter. * <p> * The x-values represent time to expiry year fractions as defined by the specified day count. * The y-values represent tenor year fractions. * * @param name the surface name * @param dayCount the day count * @param zType the z-value type, which must be one of the four SABR values * @return the surface metadata */ public static SurfaceMetadata sabrParameterByExpiryTenor( String name, DayCount dayCount, ValueType zType) { return sabrParameterByExpiryTenor(SurfaceName.of(name), dayCount, zType); }
/** * 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); }
/** * Creates metadata for a surface providing Normal expiry-tenor volatility. * <p> * The x-values represent time to expiry year fractions as defined by the specified day count. * The y-values represent tenor year fractions. * The z-values represent Normal volatility. * * @param name the surface name * @param dayCount the day count * @return the surface metadata */ public static SurfaceMetadata normalVolatilityByExpiryTenor(String name, DayCount dayCount) { return normalVolatilityByExpiryTenor(SurfaceName.of(name), dayCount); }
/** * Creates metadata for a surface providing Black expiry-log moneyness volatility. * <p> * The x-values represent time to expiry year fractions as defined by the specified day count. * The y-values represent log-moneyness * The z-values represent Black volatility. * * @param name the surface name * @param dayCount the day count * @return the surface metadata */ public static SurfaceMetadata blackVolatilityByExpiryLogMoneyness(String name, DayCount dayCount) { return blackVolatilityByExpiryLogMoneyness(SurfaceName.of(name), dayCount); }
public void normalVolatilityByExpiryStrike_string() { SurfaceMetadata test = Surfaces.normalVolatilityByExpiryStrike(NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.STRIKE) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
public void sabrParameterByExpiryTenor_surfaceName() { SurfaceMetadata test = Surfaces.sabrParameterByExpiryTenor(SURFACE_NAME, ACT_360, ValueType.SABR_BETA); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(ValueType.SABR_BETA) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
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 normalVolatilityByExpiryTenor_surfaceName() { SurfaceMetadata test = Surfaces.normalVolatilityByExpiryTenor(SURFACE_NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
public void blackVolatilityByExpiryLogMoneyness_string() { SurfaceMetadata test = Surfaces.blackVolatilityByExpiryLogMoneyness(NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.LOG_MONEYNESS) .zValueType(ValueType.BLACK_VOLATILITY) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
DoubleArray strikeShifted = DoubleArray.of(nTotal, n -> strikeList.get(n) + shiftCurve.yValue(timeList.get(n))); if (capFloorData.getDataType().equals(NORMAL_VOLATILITY)) { // correct initial surface metadata = Surfaces.blackVolatilityByExpiryStrike(bsDefinition.getName().getName(), bsDefinition.getDayCount()) .withParameterMetadata(metadata.getParameterMetadata().get()); initialVol = DoubleArray.of(nTotal, n -> volList.get(n) /
@Override public SurfaceMetadata createMetadata(RawOptionData capFloorData) { SurfaceMetadata metadata; if (capFloorData.getDataType().equals(BLACK_VOLATILITY)) { metadata = Surfaces.blackVolatilityByExpiryStrike(name.getName(), dayCount); } else if (capFloorData.getDataType().equals(NORMAL_VOLATILITY)) { metadata = Surfaces.normalVolatilityByExpiryStrike(name.getName(), dayCount); } else { throw new IllegalArgumentException("Data type not supported"); } return metadata; }
public void normalVolatilityByExpiryStrike_surfaceName() { SurfaceMetadata test = Surfaces.normalVolatilityByExpiryStrike(SURFACE_NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.STRIKE) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
public void blackVolatilityByExpiryTenor_string() { SurfaceMetadata test = Surfaces.blackVolatilityByExpiryTenor(NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(ValueType.BLACK_VOLATILITY) .dayCount(ACT_360) .build(); assertEquals(test, expected); }
public void sabrParameterByExpiryTenor_string() { SurfaceMetadata test = Surfaces.sabrParameterByExpiryTenor(NAME, ACT_360, ValueType.SABR_BETA); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(ValueType.SABR_BETA) .dayCount(ACT_360) .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 normalVolatilityByExpiryTenor_string() { SurfaceMetadata test = Surfaces.normalVolatilityByExpiryTenor(NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(ACT_360) .build(); assertEquals(test, expected); }