/** * Sets the surface name. * * @param surfaceName the surface name * @return this, for chaining */ public DefaultSurfaceMetadataBuilder surfaceName(String surfaceName) { this.surfaceName = SurfaceName.of(surfaceName); return this; }
/** * Creates a constant surface with a specific value. * * @param name the surface name * @param zValue the constant z-value * @return the surface */ public static ConstantSurface of(String name, double zValue) { return of(SurfaceName.of(name), zValue); }
/** * Creates the metadata. * <p> * No information will be available for the x-values, y-values, z-values or parameters. * * @param name the surface name * @return the metadata */ public static DefaultSurfaceMetadata of(String name) { return of(SurfaceName.of(name)); }
/** * 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); }
/** * 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-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); }
/** * 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 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 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); }
public void test_findData() { assertEquals(VOLS.findData(SURFACE.getName()), Optional.of(SURFACE)); assertEquals(VOLS.findData(SurfaceName.of("Rubbish")), Optional.empty()); }
public void test_findData() { assertEquals(VOLS.findData(SURFACE.getName()), Optional.of(SURFACE)); assertEquals(VOLS.findData(SurfaceName.of("Rubbish")), Optional.empty()); }
public void test_findData() { assertEquals(VOLS.findData(SURFACE.getName()), Optional.of(SURFACE)); assertEquals(VOLS.findData(SurfaceName.of("Rubbish")), Optional.empty()); }
public void test_findData() { assertEquals(VOLS.findData(SURFACE.getName()), Optional.of(SURFACE)); assertEquals(VOLS.findData(SurfaceName.of("Rubbish")), Optional.empty()); }
@Override public InterpolatedNodalSurface localVolatilityFromImpliedVolatility( Surface impliedVolatilitySurface, double spot, Function<Double, Double> interestRate, Function<Double, Double> dividendRate) { Function<DoublesPair, Double> surface = new Function<DoublesPair, Double>() { @Override public Double apply(DoublesPair tk) { return impliedVolatilitySurface.zValue(tk); } }; ImmutableList<double[]> localVolData = calibrate(surface, spot, interestRate, dividendRate).getFirst(); SurfaceMetadata metadata = DefaultSurfaceMetadata.builder() .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.STRIKE) .zValueType(ValueType.LOCAL_VOLATILITY) .surfaceName(SurfaceName.of("localVol_" + impliedVolatilitySurface.getName())) .build(); return InterpolatedNodalSurface.ofUnsorted( metadata, DoubleArray.ofUnsafe(localVolData.get(0)), DoubleArray.ofUnsafe(localVolData.get(1)), DoubleArray.ofUnsafe(localVolData.get(2)), interpolator); }
public void test_findData() { SabrParametersSwaptionVolatilities test = SabrParametersSwaptionVolatilities.of(NAME, CONV, DATE_TIME, PARAM); assertEquals(test.findData(PARAM.getAlphaSurface().getName()), Optional.of(PARAM.getAlphaSurface())); assertEquals(test.findData(PARAM.getBetaSurface().getName()), Optional.of(PARAM.getBetaSurface())); assertEquals(test.findData(PARAM.getRhoSurface().getName()), Optional.of(PARAM.getRhoSurface())); assertEquals(test.findData(PARAM.getNuSurface().getName()), Optional.of(PARAM.getNuSurface())); assertEquals(test.findData(PARAM.getShiftSurface().getName()), Optional.of(PARAM.getShiftSurface())); assertEquals(test.findData(SurfaceName.of("Rubbish")), Optional.empty()); }
public void test_findData() { SabrParametersIborCapletFloorletVolatilities test = SabrParametersIborCapletFloorletVolatilities.of(NAME, EUR_EURIBOR_3M, DATE_TIME, PARAM); assertEquals(test.findData(PARAM.getAlphaCurve().getName()), Optional.of(PARAM.getAlphaCurve())); assertEquals(test.findData(PARAM.getBetaCurve().getName()), Optional.of(PARAM.getBetaCurve())); assertEquals(test.findData(PARAM.getRhoCurve().getName()), Optional.of(PARAM.getRhoCurve())); assertEquals(test.findData(PARAM.getNuCurve().getName()), Optional.of(PARAM.getNuCurve())); assertEquals(test.findData(PARAM.getShiftCurve().getName()), Optional.of(PARAM.getShiftCurve())); assertEquals(test.findData(SurfaceName.of("Rubbish")), Optional.empty()); }
assertEquals(PARAMETERS.getNuSurface(), NU_SURFACE); assertEquals(PARAMETERS.getSabrVolatilityFormula(), FORMULA); assertEquals(PARAMETERS.getShiftSurface().getName(), SurfaceName.of("Zero shift")); double expiry = 2.0; double tenor = 3.0;
public void coverage() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.of(SURFACE_NAME); coverImmutableBean(test); DefaultSurfaceMetadata test2 = DefaultSurfaceMetadata.builder() .surfaceName(SurfaceName.of("Test")) .xValueType(ValueType.YEAR_FRACTION) .yValueType(ValueType.DISCOUNT_FACTOR) .zValueType(ValueType.ZERO_RATE) .dayCount(ACT_365F) .parameterMetadata(ParameterMetadata.empty()) .build(); coverBeanEquals(test, test2); }