Пример #1
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            SwaptionSurfaceExpiryStrikeParameterMetadata test1 = SwaptionSurfaceExpiryStrikeParameterMetadata.of(TIME_TO_EXPIRY, STRIKE);

            coverImmutableBean(test1);
            SwaptionSurfaceExpiryStrikeParameterMetadata test2 = SwaptionSurfaceExpiryStrikeParameterMetadata.of(2.5d, 60d, "(2.5, 60)");

            coverBeanEquals(test1, test2);
        }
Пример #2
0
        public virtual void test_of_noLabel()
        {
            SwaptionSurfaceExpiryStrikeParameterMetadata test = SwaptionSurfaceExpiryStrikeParameterMetadata.of(TIME_TO_EXPIRY, STRIKE);

            assertEquals(test.Identifier, Pair.of(TIME_TO_EXPIRY, STRIKE));
            assertEquals(test.Label, Pair.of(TIME_TO_EXPIRY, STRIKE).ToString());
            assertEquals(test.Strike, STRIKE);
            assertEquals(test.YearFraction, TIME_TO_EXPIRY);
        }
Пример #3
0
        public virtual void test_of_withLabel()
        {
            string label = "(1.5Y, 0.25)";
            SwaptionSurfaceExpiryStrikeParameterMetadata test = SwaptionSurfaceExpiryStrikeParameterMetadata.of(TIME_TO_EXPIRY, STRIKE, label);

            assertEquals(test.Identifier, Pair.of(TIME_TO_EXPIRY, STRIKE));
            assertEquals(test.Label, label);
            assertEquals(test.Strike, STRIKE);
            assertEquals(test.YearFraction, TIME_TO_EXPIRY);
        }
        static NormalSwaptionExpiryStrikeVolatilitiesTest()
        {
            IList <SwaptionSurfaceExpiryStrikeParameterMetadata> list = new List <SwaptionSurfaceExpiryStrikeParameterMetadata>();
            int nData = TIME.size();

            for (int i = 0; i < nData; ++i)
            {
                SwaptionSurfaceExpiryStrikeParameterMetadata parameterMetadata = SwaptionSurfaceExpiryStrikeParameterMetadata.of(TIME.get(i), STRIKE.get(i));
                list.Add(parameterMetadata);
            }
            METADATA = Surfaces.normalVolatilityByExpiryStrike("GOVT1-SWAPTION-VOL", ACT_365F).withParameterMetadata(list);
        }
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         SwaptionSurfaceExpiryStrikeParameterMetadata other = (SwaptionSurfaceExpiryStrikeParameterMetadata)obj;
         return(JodaBeanUtils.equal(yearFraction, other.yearFraction) && JodaBeanUtils.equal(strike, other.strike) && JodaBeanUtils.equal(label, other.label));
     }
     return(false);
 }
Пример #6
0
        public virtual void test_builder_noLabel()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.joda.beans.BeanBuilder<? extends SwaptionSurfaceExpiryStrikeParameterMetadata> builder = SwaptionSurfaceExpiryStrikeParameterMetadata.meta().builder();
            BeanBuilder <SwaptionSurfaceExpiryStrikeParameterMetadata> builder = SwaptionSurfaceExpiryStrikeParameterMetadata.meta().builder();
            Pair <double, double> pair = Pair.of(TIME_TO_EXPIRY, STRIKE);

            builder.set(SwaptionSurfaceExpiryStrikeParameterMetadata.meta().yearFraction(), TIME_TO_EXPIRY);
            builder.set(SwaptionSurfaceExpiryStrikeParameterMetadata.meta().strike(), STRIKE);
            SwaptionSurfaceExpiryStrikeParameterMetadata test = builder.build();

            assertEquals(test.Identifier, pair);
            assertEquals(test.Label, pair.ToString());
            assertEquals(test.Strike, STRIKE);
            assertEquals(test.YearFraction, TIME_TO_EXPIRY);
        }
        public virtual void test_volatility_sensitivity()
        {
            double eps   = 1.0e-6;
            int    nData = TIME.size();

            for (int i = 0; i < NB_TEST; i++)
            {
                double expiryTime = VOLS.relativeTime(TEST_OPTION_EXPIRY[i]);
                SwaptionSensitivity            point      = SwaptionSensitivity.of(VOLS.Name, expiryTime, TEST_TENOR, TEST_STRIKE[i], TEST_FORWARD, GBP, TEST_SENSITIVITY[i]);
                CurrencyParameterSensitivities sensActual = VOLS.parameterSensitivity(point);
                CurrencyParameterSensitivity   sensi      = sensActual.getSensitivity(SURFACE.Name, GBP);
                DoubleArray computed = sensi.Sensitivity;

                IDictionary <DoublesPair, double> map = new Dictionary <DoublesPair, double>();
                for (int j = 0; j < nData; ++j)
                {
                    DoubleArray volDataUp            = VOL.subArray(0, nData).with(j, VOL.get(j) + eps);
                    DoubleArray volDataDw            = VOL.subArray(0, nData).with(j, VOL.get(j) - eps);
                    InterpolatedNodalSurface paramUp = InterpolatedNodalSurface.of(METADATA, TIME, STRIKE, volDataUp, INTERPOLATOR_2D);
                    InterpolatedNodalSurface paramDw = InterpolatedNodalSurface.of(METADATA, TIME, STRIKE, volDataDw, INTERPOLATOR_2D);
                    NormalSwaptionExpiryStrikeVolatilities provUp = NormalSwaptionExpiryStrikeVolatilities.of(CONVENTION, VAL_DATE_TIME, paramUp);
                    NormalSwaptionExpiryStrikeVolatilities provDw = NormalSwaptionExpiryStrikeVolatilities.of(CONVENTION, VAL_DATE_TIME, paramDw);
                    double volUp = provUp.volatility(TEST_OPTION_EXPIRY[i], TEST_TENOR, TEST_STRIKE[i], TEST_FORWARD);
                    double volDw = provDw.volatility(TEST_OPTION_EXPIRY[i], TEST_TENOR, TEST_STRIKE[i], TEST_FORWARD);
                    double fd    = 0.5 * (volUp - volDw) / eps;
                    map[DoublesPair.of(TIME.get(j), STRIKE.get(j))] = fd;
                }
                IList <ParameterMetadata> list = sensi.ParameterMetadata;
                assertEquals(computed.size(), nData);
                for (int j = 0; j < list.Count; ++j)
                {
                    SwaptionSurfaceExpiryStrikeParameterMetadata metadata = (SwaptionSurfaceExpiryStrikeParameterMetadata)list[i];
                    double expected = map[DoublesPair.of(metadata.YearFraction, metadata.Strike)];
                    assertEquals(computed.get(i), expected, eps);
                }
            }
        }
Пример #8
0
        public virtual void test_serialization()
        {
            SwaptionSurfaceExpiryStrikeParameterMetadata test = SwaptionSurfaceExpiryStrikeParameterMetadata.of(TIME_TO_EXPIRY, STRIKE);

            assertSerialization(test);
        }