//-------------------------------------------------------------------------
        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);
        }
        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 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);
        }
Beispiel #5
0
 /// <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_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_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());
        }
Beispiel #9
0
 /// <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());
 }
Beispiel #10
0
 /// <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());
 }
Beispiel #11
0
 /// <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());
 }
Beispiel #12
0
 /// <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());
 }