public virtual 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 virtual 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 virtual void blackVolatilityByExpiryLogMoneyness_surfaceName() { SurfaceMetadata test = Surfaces.blackVolatilityByExpiryLogMoneyness(SURFACE_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); }
//------------------------------------------------------------------------- public virtual 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); }
/// <summary> /// Creates metadata for a surface providing a SABR expiry-tenor parameter. /// <para> /// The x-values represent time to expiry year fractions as defined by the specified day count. /// The y-values represent tenor year fractions. /// /// </para> /// </summary> /// <param name="name"> the surface name </param> /// <param name="dayCount"> the day count </param> /// <param name="zType"> the z-value type, which must be one of the four SABR values </param> /// <returns> the surface metadata </returns> 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 System.ArgumentException("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 virtual 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); }
//------------------------------------------------------------------------- public virtual void test_withInfo() { DefaultSurfaceMetadata @base = DefaultSurfaceMetadata.of(SURFACE_NAME); assertThat(@base.findInfo(SurfaceInfoType.DAY_COUNT).Present).False; DefaultSurfaceMetadata test = @base.withInfo(SurfaceInfoType.DAY_COUNT, ACT_360); assertThat(@base.findInfo(SurfaceInfoType.DAY_COUNT).Present).False; assertThat(test.findInfo(SurfaceInfoType.DAY_COUNT).Present).True; }
public virtual void test_builder3() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.builder().surfaceName(SURFACE_NAME).parameterMetadata(ImmutableList.of(ParameterMetadata.empty())).clearParameterMetadata().build(); assertThat(test.SurfaceName).isEqualTo(SURFACE_NAME); assertThat(test.XValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.YValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.ZValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.ParameterMetadata.Present).False; }
public virtual void test_withParameterMetadata_clearWhenNonEmpty() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.of(SURFACE_NAME).withParameterMetadata(ImmutableList.of(ParameterMetadata.empty())).withParameterMetadata(null); assertThat(test.SurfaceName).isEqualTo(SURFACE_NAME); assertThat(test.XValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.YValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.ZValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.ParameterMetadata.Present).False; }
/// <summary> /// Restricted copy constructor. /// </summary> /// <param name="beanToCopy"> the bean to copy from </param> internal DefaultSurfaceMetadataBuilder(DefaultSurfaceMetadata beanToCopy) { this.surfaceName_Renamed = beanToCopy.SurfaceName; this.xValueType_Renamed = beanToCopy.XValueType; this.yValueType_Renamed = beanToCopy.YValueType; this.zValueType_Renamed = beanToCopy.ZValueType; //JAVA TO C# CONVERTER TODO TASK: There is no .NET Dictionary equivalent to the Java 'putAll' method: this.info.putAll(beanToCopy.Info); this.parameterMetadata_Renamed = beanToCopy.ParameterMetadata.orElse(null); }
public virtual void test_of_SurfaceName_noMetadata() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.of(SURFACE_NAME); assertThat(test.SurfaceName).isEqualTo(SURFACE_NAME); assertThat(test.XValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.YValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.ZValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.Info).isEqualTo(ImmutableMap.of()); assertThat(test.ParameterMetadata.Present).False; }
//------------------------------------------------------------------------- public virtual void test_withParameterMetadata() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.of(SURFACE_NAME).withParameterMetadata(ImmutableList.of(ParameterMetadata.empty())); assertThat(test.SurfaceName).isEqualTo(SURFACE_NAME); assertThat(test.XValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.YValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.ZValueType).isEqualTo(ValueType.UNKNOWN); assertThat(test.ParameterMetadata.Present).True; assertThat(test.ParameterMetadata.get()).containsExactly(ParameterMetadata.empty()); }
//------------------------------------------------------------------------- public virtual void coverage() { DeformedSurface test1 = DeformedSurface.of(METADATA, SURFACE_ORG, FUNCTION); coverImmutableBean(test1); Surface surface1 = InterpolatedNodalSurface.of(DefaultSurfaceMetadata.of("TestSurface1"), XVALUES, YVALUES, ZVALUES, INTERPOLATOR); DeformedSurface test2 = DeformedSurface.of(DefaultSurfaceMetadata.of("DeformedTestSurface1"), surface1, (DoublesPair x) => { return(ValueDerivatives.of(surface1.zValue(x), surface1.zValueParameterSensitivity(x).Sensitivity)); }); coverBeanEquals(test1, test2); }
public virtual void test_builder2() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.builder().surfaceName(SURFACE_NAME).xValueType(ValueType.YEAR_FRACTION).yValueType(ValueType.DISCOUNT_FACTOR).zValueType(ValueType.ZERO_RATE).dayCount(ACT_365F).addInfo(SurfaceInfoType.DAY_COUNT, null).addInfo(DESCRIPTION, "Hello").parameterMetadata(ImmutableList.of(ParameterMetadata.empty())).build(); assertThat(test.SurfaceName).isEqualTo(SURFACE_NAME); assertThat(test.XValueType).isEqualTo(ValueType.YEAR_FRACTION); assertThat(test.YValueType).isEqualTo(ValueType.DISCOUNT_FACTOR); assertThat(test.ZValueType).isEqualTo(ValueType.ZERO_RATE); assertThrowsIllegalArg(() => test.getInfo(SurfaceInfoType.DAY_COUNT)); assertThat(test.findInfo(SurfaceInfoType.DAY_COUNT)).Empty; assertThat(test.getInfo(DESCRIPTION)).isEqualTo("Hello"); assertThat(test.findInfo(DESCRIPTION)).isEqualTo(("Hello")); assertThat(test.findInfo(SurfaceInfoType.of("Rubbish"))).isEqualTo(null); assertThat(test.ParameterMetadata.Present).True; assertThat(test.ParameterMetadata.get()).containsExactly(ParameterMetadata.empty()); }
/// <summary> /// Creates metadata for a surface providing Black expiry-log moneyness volatility. /// <para> /// 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. /// /// </para> /// </summary> /// <param name="name"> the surface name </param> /// <param name="dayCount"> the day count </param> /// <returns> the surface metadata </returns> 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()); }
public virtual void test_serialization() { DefaultSurfaceMetadata test = DefaultSurfaceMetadata.of(SURFACE_NAME); assertSerialization(test); }
/// <summary> /// Creates a constant surface with a specific value. /// </summary> /// <param name="name"> the surface name </param> /// <param name="zValue"> the constant z-value </param> /// <returns> the surface </returns> public static ConstantSurface of(SurfaceName name, double zValue) { return(new ConstantSurface(DefaultSurfaceMetadata.of(name), zValue)); }
/// <summary> /// Creates metadata for a surface providing Normal expiry-tenor volatility. /// <para> /// 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. /// /// </para> /// </summary> /// <param name="name"> the surface name </param> /// <param name="dayCount"> the day count </param> /// <returns> the surface metadata </returns> 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()); }
/// <summary> /// Creates metadata for a surface providing Black expiry-strike volatility. /// <para> /// 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. /// /// </para> /// </summary> /// <param name="name"> the surface name </param> /// <param name="dayCount"> the day count </param> /// <returns> the surface metadata </returns> 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()); }
/// <summary> /// Creates metadata for a surface providing Normal expiry-simple moneyness volatility. /// <para> /// 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. /// /// </para> /// </summary> /// <param name="name"> the surface name </param> /// <param name="dayCount"> the day count </param> /// <param name="moneynessType"> the moneyness type, prices or rates </param> /// <returns> the surface metadata </returns> 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()); }