private CurrencyParameterSensitivity parameterSensitivity(FxOptionSensitivity point)
        {
            double       expiryTime    = point.Expiry;
            double       strike        = currencyPair.isInverse(point.CurrencyPair) ? 1d / point.Strike : point.Strike;
            double       forward       = currencyPair.isInverse(point.CurrencyPair) ? 1d / point.Forward : point.Forward;
            double       pointValue    = point.Sensitivity;
            DoubleMatrix bucketedSensi = smile.volatilityAndSensitivities(expiryTime, strike, forward).Sensitivities;

            double[]                  times     = smile.Expiries.toArray();
            int                       nTimes    = times.Length;
            IList <double>            sensiList = new List <double>();
            IList <ParameterMetadata> paramList = new List <ParameterMetadata>();

            for (int i = 0; i < nTimes; ++i)
            {
                DoubleArray deltas       = smile.VolatilityTerm.get(i).Delta;
                int         nDeltas      = deltas.size();
                int         nDeltasTotal = 2 * nDeltas + 1;
                double[]    deltasTotal  = new double[nDeltasTotal]; // absolute delta
                deltasTotal[nDeltas] = 0.5d;
                for (int j = 0; j < nDeltas; ++j)
                {
                    deltasTotal[j] = 1d - deltas.get(j);
                    deltasTotal[2 * nDeltas - j] = deltas.get(j);
                }
                for (int j = 0; j < nDeltasTotal; ++j)
                {
                    sensiList.Add(bucketedSensi.get(i, j) * pointValue);
                    DeltaStrike       absoluteDelta     = DeltaStrike.of(deltasTotal[j]);
                    ParameterMetadata parameterMetadata = FxVolatilitySurfaceYearFractionParameterMetadata.of(times[i], absoluteDelta, currencyPair);
                    paramList.Add(parameterMetadata);
                }
            }
            return(CurrencyParameterSensitivity.of(name, paramList, point.Currency, DoubleArray.copyOf(sensiList)));
        }
Exemple #2
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            FxVolatilitySurfaceYearFractionParameterMetadata test1 = FxVolatilitySurfaceYearFractionParameterMetadata.of(TIME_TO_EXPIRY, STRIKE, CURRENCY_PAIR);

            coverImmutableBean(test1);
            FxVolatilitySurfaceYearFractionParameterMetadata test2 = FxVolatilitySurfaceYearFractionParameterMetadata.of(3d, MoneynessStrike.of(1.1d), CurrencyPair.of(EUR, AUD));

            coverBeanEquals(test1, test2);
        }
Exemple #3
0
        public virtual void test_of_withStrikeType()
        {
            FxVolatilitySurfaceYearFractionParameterMetadata test = FxVolatilitySurfaceYearFractionParameterMetadata.of(TIME_TO_EXPIRY, STRIKE, CURRENCY_PAIR);

            assertEquals(test.CurrencyPair, CURRENCY_PAIR);
            assertEquals(test.Identifier, Pair.of(TIME_TO_EXPIRY, STRIKE));
            assertEquals(test.Label, Pair.of(TIME_TO_EXPIRY, STRIKE.Label).ToString());
            assertEquals(test.Strike, STRIKE);
            assertEquals(test.YearFraction, TIME_TO_EXPIRY);
        }
Exemple #4
0
        public virtual void test_of_withLabel()
        {
            Pair <double, Strike> pair = Pair.of(TIME_TO_EXPIRY, STRIKE1);
            string label = "(1.5, 1.35)";
            FxVolatilitySurfaceYearFractionParameterMetadata test = FxVolatilitySurfaceYearFractionParameterMetadata.of(TIME_TO_EXPIRY, STRIKE1, label, CURRENCY_PAIR);

            assertEquals(test.CurrencyPair, CURRENCY_PAIR);
            assertEquals(test.Identifier, pair);
            assertEquals(test.Label, label);
            assertEquals(test.Strike, STRIKE1);
            assertEquals(test.YearFraction, TIME_TO_EXPIRY);
        }
Exemple #5
0
 //-----------------------------------------------------------------------
 public override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         FxVolatilitySurfaceYearFractionParameterMetadata other = (FxVolatilitySurfaceYearFractionParameterMetadata)obj;
         return(JodaBeanUtils.equal(yearFraction, other.yearFraction) && JodaBeanUtils.equal(strike, other.strike) && JodaBeanUtils.equal(currencyPair, other.currencyPair) && JodaBeanUtils.equal(label, other.label));
     }
     return(false);
 }
Exemple #6
0
        public virtual void test_builder_incomplete()
        {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.joda.beans.BeanBuilder<? extends FxVolatilitySurfaceYearFractionParameterMetadata> builder1 = FxVolatilitySurfaceYearFractionParameterMetadata.meta().builder();
            BeanBuilder <FxVolatilitySurfaceYearFractionParameterMetadata> builder1 = FxVolatilitySurfaceYearFractionParameterMetadata.meta().builder();

            assertThrowsIllegalArg(() => builder1.build());
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.joda.beans.BeanBuilder<? extends FxVolatilitySurfaceYearFractionParameterMetadata> builder2 = FxVolatilitySurfaceYearFractionParameterMetadata.meta().builder();
            BeanBuilder <FxVolatilitySurfaceYearFractionParameterMetadata> builder2 = FxVolatilitySurfaceYearFractionParameterMetadata.meta().builder();

            builder2.set(FxVolatilitySurfaceYearFractionParameterMetadata.meta().yearFraction(), TIME_TO_EXPIRY);
            assertThrowsIllegalArg(() => builder2.build());
        }
Exemple #7
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 FxVolatilitySurfaceYearFractionParameterMetadata> builder = FxVolatilitySurfaceYearFractionParameterMetadata.meta().builder();
            BeanBuilder <FxVolatilitySurfaceYearFractionParameterMetadata> builder = FxVolatilitySurfaceYearFractionParameterMetadata.meta().builder();
            Pair <double, Strike> pair = Pair.of(TIME_TO_EXPIRY, STRIKE);

            builder.set(FxVolatilitySurfaceYearFractionParameterMetadata.meta().currencyPair(), CURRENCY_PAIR);
            builder.set(FxVolatilitySurfaceYearFractionParameterMetadata.meta().yearFraction(), TIME_TO_EXPIRY);
            builder.set(FxVolatilitySurfaceYearFractionParameterMetadata.meta().strike(), STRIKE);
            FxVolatilitySurfaceYearFractionParameterMetadata test = builder.build();

            assertEquals(test.CurrencyPair, CURRENCY_PAIR);
            assertEquals(test.Identifier, pair);
            assertEquals(test.Label, Pair.of(TIME_TO_EXPIRY, STRIKE.Label).ToString());
            assertEquals(test.Strike, STRIKE);
            assertEquals(test.YearFraction, TIME_TO_EXPIRY);
        }
Exemple #8
0
        public virtual void test_surfaceParameterSensitivity_inverse()
        {
            for (int i = 0; i < NB_EXPIRY; i++)
            {
                for (int j = 0; j < NB_STRIKE; ++j)
                {
                    double timeToExpiry = VOLS.relativeTime(TEST_EXPIRY[i]);
                    FxOptionSensitivity             sensi    = FxOptionSensitivity.of(VOLS.Name, CURRENCY_PAIR.inverse(), timeToExpiry, 1d / TEST_STRIKE[j], 1d / FORWARD[i], GBP, 1d);
                    CurrencyParameterSensitivity    computed = VOLS.parameterSensitivity(sensi).Sensitivities.get(0);
                    IEnumerator <ParameterMetadata> itr      = computed.ParameterMetadata.GetEnumerator();
                    foreach (double value in computed.Sensitivity.toArray())
                    {
//JAVA TO C# CONVERTER TODO TASK: Java iterators are only converted within the context of 'while' and 'for' loops:
                        FxVolatilitySurfaceYearFractionParameterMetadata meta = ((FxVolatilitySurfaceYearFractionParameterMetadata)itr.next());
                        double nodeExpiry = meta.YearFraction;
                        double nodeDelta  = meta.Strike.Value;
                        double expected   = nodeSensitivity(VOLS, CURRENCY_PAIR.inverse(), TEST_EXPIRY[i], 1d / TEST_STRIKE[j], 1d / FORWARD[i], nodeExpiry, nodeDelta);
                        assertEquals(value, expected, EPS);
                    }
                }
            }
        }
Exemple #9
0
        public virtual void test_serialization()
        {
            FxVolatilitySurfaceYearFractionParameterMetadata test = FxVolatilitySurfaceYearFractionParameterMetadata.of(TIME_TO_EXPIRY, STRIKE, CURRENCY_PAIR);

            assertSerialization(test);
        }