/** * 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(SurfaceName name, DayCount dayCount) { return DefaultSurfaceMetadata.builder() .surfaceName(name) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(dayCount) .build(); }
@Override public DefaultSurfaceMetadata withParameterMetadata(List<? extends ParameterMetadata> parameterMetadata) { if (parameterMetadata == null) { return this.parameterMetadata != null ? toBuilder().clearParameterMetadata().build() : this; } return toBuilder().parameterMetadata(parameterMetadata).build(); }
public void test_builder3() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .parameterMetadata(ImmutableList.of(ParameterMetadata.empty())) .clearParameterMetadata() .build(); assertThat(test.getSurfaceName()).isEqualTo(SURFACE_NAME); assertThat(test.getXValueType()).isEqualTo(ValueType.UNKNOWN); assertThat(test.getYValueType()).isEqualTo(ValueType.UNKNOWN); assertThat(test.getZValueType()).isEqualTo(ValueType.UNKNOWN); assertThat(test.getParameterMetadata().isPresent()).isFalse(); }
/** * Sets the day count. * <p> * This stores the day count in the additional information map using the * key {@link SurfaceInfoType#DAY_COUNT}. * <p> * This is stored in the additional information map using {@code Map.put} semantics, * removing the key if the day count is null. * * @param dayCount the day count, may be null * @return this, for chaining */ public DefaultSurfaceMetadataBuilder dayCount(DayCount dayCount) { return addInfo(SurfaceInfoType.DAY_COUNT, 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(SurfaceName name, DayCount dayCount) { return DefaultSurfaceMetadata.builder() .surfaceName(name) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.LOG_MONEYNESS) .zValueType(ValueType.BLACK_VOLATILITY) .dayCount(dayCount) .build(); }
/** * 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(SurfaceName name, DayCount dayCount) { return DefaultSurfaceMetadata.builder() .surfaceName(name) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(ValueType.BLACK_VOLATILITY) .dayCount(dayCount) .build(); }
/** * 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(SurfaceName name, DayCount dayCount) { return DefaultSurfaceMetadata.builder() .surfaceName(name) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.STRIKE) .zValueType(ValueType.BLACK_VOLATILITY) .dayCount(dayCount) .build(); }
/** * 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(SurfaceName name, DayCount dayCount) { return DefaultSurfaceMetadata.builder() .surfaceName(name) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.STRIKE) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(dayCount) .build(); }
/** * 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( SurfaceName name, DayCount dayCount, MoneynessType moneynessType) { return DefaultSurfaceMetadata.builder() .surfaceName(name) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.SIMPLE_MONEYNESS) .zValueType(ValueType.NORMAL_VOLATILITY) .dayCount(dayCount) .addInfo(SurfaceInfoType.MONEYNESS_TYPE, moneynessType) .build(); }
/** * 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( SurfaceName name, DayCount dayCount, ValueType zType) { if (!zType.equals(ValueType.SABR_ALPHA) && !zType.equals(ValueType.SABR_BETA) && !zType.equals(ValueType.SABR_RHO) && !zType.equals(ValueType.SABR_NU)) { throw new IllegalArgumentException("SABR z-value type must be SabrAlpha, SabrBeta, SabrRho or SabrNu"); } return DefaultSurfaceMetadata.builder() .surfaceName(name) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.YEAR_FRACTION) .zValueType(zType) .dayCount(dayCount) .build(); }
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 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 blackVolatilityByExpiryStrike_string() { SurfaceMetadata test = Surfaces.blackVolatilityByExpiryStrike(NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.STRIKE) .zValueType(ValueType.BLACK_VOLATILITY) .dayCount(ACT_360) .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 blackVolatilityByExpiryStrike_surfaceName() { SurfaceMetadata test = Surfaces.blackVolatilityByExpiryStrike(SURFACE_NAME, ACT_360); SurfaceMetadata expected = DefaultSurfaceMetadata.builder() .surfaceName(SURFACE_NAME) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.STRIKE) .zValueType(ValueType.BLACK_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 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 blackVolatilityByExpiryTenor_surfaceName() { SurfaceMetadata test = Surfaces.blackVolatilityByExpiryTenor(SURFACE_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 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); }