//-------------------------------------------------------------------------
        public virtual void test_cloned()
        {
            BondFutureOptionSensitivity @base = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity test  = @base.cloned();

            assertSame(test, @base);
        }
        //-------------------------------------------------------------------------
        public virtual void test_compareKey()
        {
            BondFutureOptionSensitivity a1    = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity a2    = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity b     = BondFutureOptionSensitivity.of(BondFutureVolatilitiesName.of("FOO-BOND-FUT"), OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity c     = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY + 1, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity d     = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, date(2015, 9, 28), STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity e     = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, 0.995, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity f     = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, 0.975, GBP, SENSITIVITY);
            BondFutureOptionSensitivity g     = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, USD, SENSITIVITY);
            ZeroRateSensitivity         other = ZeroRateSensitivity.of(GBP, 2d, 32d);

            assertEquals(a1.compareKey(a2), 0);
            assertEquals(a1.compareKey(b) > 0, true);
            assertEquals(b.compareKey(a1) < 0, true);
            assertEquals(a1.compareKey(c) < 0, true);
            assertEquals(c.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(d) < 0, true);
            assertEquals(d.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(e) < 0, true);
            assertEquals(e.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(f) > 0, true);
            assertEquals(f.compareKey(a1) < 0, true);
            assertEquals(a1.compareKey(g) < 0, true);
            assertEquals(g.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(other) < 0, true);
            assertEquals(other.compareKey(a1) > 0, true);
        }
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            BondFutureOptionSensitivity @base = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            PointSensitivities          test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
Ejemplo n.º 4
0
        public virtual void test_volatility_sensitivity()
        {
            double eps   = 1.0e-6;
            int    nData = TIME.size();

            for (int i = 0; i < NB_TEST; i++)
            {
                double expiry = VOLS.relativeTime(TEST_OPTION_EXPIRY[i]);
                BondFutureOptionSensitivity  point      = BondFutureOptionSensitivity.of(VOLS.Name, expiry, TEST_FUTURE_EXPIRY[i], TEST_STRIKE_PRICE[i], TEST_FUTURE_PRICE[i], USD, TEST_SENSITIVITY[i]);
                CurrencyParameterSensitivity sensActual = VOLS.parameterSensitivity(point).Sensitivities.get(0);
                double[] computed = sensActual.Sensitivity.toArray();
                for (int j = 0; j < nData; j++)
                {
                    DoubleArray volDataUp            = VOL.with(j, VOL.get(j) + eps);
                    DoubleArray volDataDw            = VOL.with(j, VOL.get(j) - eps);
                    InterpolatedNodalSurface paramUp = InterpolatedNodalSurface.of(METADATA, TIME, MONEYNESS, volDataUp, INTERPOLATOR_2D);
                    InterpolatedNodalSurface paramDw = InterpolatedNodalSurface.of(METADATA, TIME, MONEYNESS, volDataDw, INTERPOLATOR_2D);
                    BlackBondFutureExpiryLogMoneynessVolatilities provUp = BlackBondFutureExpiryLogMoneynessVolatilities.of(VAL_DATE_TIME, paramUp);
                    BlackBondFutureExpiryLogMoneynessVolatilities provDw = BlackBondFutureExpiryLogMoneynessVolatilities.of(VAL_DATE_TIME, paramDw);
                    double volUp = provUp.volatility(expiry, TEST_FUTURE_EXPIRY[i], TEST_STRIKE_PRICE[i], TEST_FUTURE_PRICE[i]);
                    double volDw = provDw.volatility(expiry, TEST_FUTURE_EXPIRY[i], TEST_STRIKE_PRICE[i], TEST_FUTURE_PRICE[i]);
                    double fd    = 0.5 * (volUp - volDw) / eps;
                    assertEquals(computed[j], fd, eps);
                }
            }
        }
        //-------------------------------------------------------------------------
        public virtual void test_withSensitivity()
        {
            BondFutureOptionSensitivity @base    = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            BondFutureOptionSensitivity expected = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, 20d);
            BondFutureOptionSensitivity test     = @base.withSensitivity(20d);

            assertEquals(test, expected);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            BondFutureOptionSensitivity test1 = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);

            coverImmutableBean(test1);
            BondFutureOptionSensitivity test2 = BondFutureOptionSensitivity.of(BondFutureVolatilitiesName.of("FOO-BOND-FUT"), OPTION_EXPIRY + 1, date(2015, 9, 28), 0.985, 0.995, USD, SENSITIVITY);

            coverBeanEquals(test1, test2);
        }
        //-------------------------------------------------------------------------
        public virtual void test_withCurrency()
        {
            BondFutureOptionSensitivity @base = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);

            assertSame(@base.withCurrency(GBP), @base);
            BondFutureOptionSensitivity expected = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, USD, SENSITIVITY);
            BondFutureOptionSensitivity test     = @base.withCurrency(USD);

            assertEquals(test, expected);
        }
        /// <summary>
        /// Calculates the price sensitivity to the Black volatility used for the pricing of the bond future option
        /// based on the price of the underlying future.
        /// </summary>
        /// <param name="futureOption">  the option product </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <param name="volatilities">  the volatilities </param>
        /// <param name="futurePrice">  the underlying future price </param>
        /// <returns> the sensitivity </returns>
        public BondFutureOptionSensitivity priceSensitivityModelParamsVolatility(ResolvedBondFutureOption futureOption, LegalEntityDiscountingProvider discountingProvider, BlackBondFutureVolatilities volatilities, double futurePrice)
        {
            ArgChecker.isTrue(futureOption.PremiumStyle.Equals(FutureOptionPremiumStyle.DAILY_MARGIN), "Premium style should be DAILY_MARGIN");
            double             strike       = futureOption.StrikePrice;
            ResolvedBondFuture future       = futureOption.UnderlyingFuture;
            double             volatility   = volatilities.volatility(futureOption.Expiry, future.LastTradeDate, strike, futurePrice);
            double             timeToExpiry = volatilities.relativeTime(futureOption.Expiry);
            double             vega         = BlackFormulaRepository.vega(futurePrice, strike, timeToExpiry, volatility);

            return(BondFutureOptionSensitivity.of(volatilities.Name, timeToExpiry, future.LastTradeDate, strike, futurePrice, future.Currency, vega));
        }
        public virtual void test_of()
        {
            BondFutureOptionSensitivity test = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);

            assertEquals(test.VolatilitiesName, NAME);
            assertEquals(test.Currency, GBP);
            assertEquals(test.Expiry, OPTION_EXPIRY);
            assertEquals(test.FutureExpiryDate, FUTURE_EXPIRY);
            assertEquals(test.StrikePrice, STRIKE_PRICE);
            assertEquals(test.FuturePrice, FUTURE_PRICE);
            assertEquals(test.Sensitivity, SENSITIVITY);
        }
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            BondFutureOptionSensitivity @base = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);
            double   rate   = 1.5d;
            FxMatrix matrix = FxMatrix.of(CurrencyPair.of(GBP, USD), rate);
            BondFutureOptionSensitivity test1    = (BondFutureOptionSensitivity)@base.convertedTo(USD, matrix);
            BondFutureOptionSensitivity expected = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, USD, SENSITIVITY * rate);

            assertEquals(test1, expected);
            BondFutureOptionSensitivity test2 = (BondFutureOptionSensitivity)@base.convertedTo(GBP, matrix);

            assertEquals(test2, @base);
        }
        public virtual void test_serialization()
        {
            BondFutureOptionSensitivity test = BondFutureOptionSensitivity.of(NAME, OPTION_EXPIRY, FUTURE_EXPIRY, STRIKE_PRICE, FUTURE_PRICE, GBP, SENSITIVITY);

            assertSerialization(test);
        }