//-------------------------------------------------------------------------
        public virtual void test_presentValueSensitivityVolatility()
        {
            PointSensitivities pointCaplet   = PRICER.presentValueSensitivityModelParamsSabr(CAPLET_LONG, RATES, VOLS).build();
            PointSensitivities pointFloorlet = PRICER.presentValueSensitivityModelParamsSabr(FLOORLET_SHORT, RATES, VOLS).build();
            double             forward       = RATES.iborIndexRates(EUR_EURIBOR_3M).rate(RATE_COMP.Observation);
            double             expiry        = VOLS.relativeTime(CAPLET_LONG.FixingDateTime);
            ValueDerivatives   volSensi      = VOLS.Parameters.volatilityAdjoint(expiry, STRIKE, forward);
            double             df            = RATES.discountFactor(EUR, CAPLET_LONG.PaymentDate);
            double             vegaCaplet    = NOTIONAL * df * CAPLET_LONG.YearFraction * BlackFormulaRepository.vega(forward + SHIFT, STRIKE + SHIFT, expiry, volSensi.Value);
            double             vegaFloorlet  = -NOTIONAL *df *CAPLET_LONG.YearFraction *BlackFormulaRepository.vega(forward + SHIFT, STRIKE + SHIFT, expiry, volSensi.Value);

            assertSensitivity(pointCaplet, SabrParameterType.ALPHA, vegaCaplet * volSensi.getDerivative(2), TOL);
            assertSensitivity(pointCaplet, SabrParameterType.BETA, vegaCaplet * volSensi.getDerivative(3), TOL);
            assertSensitivity(pointCaplet, SabrParameterType.RHO, vegaCaplet * volSensi.getDerivative(4), TOL);
            assertSensitivity(pointCaplet, SabrParameterType.NU, vegaCaplet * volSensi.getDerivative(5), TOL);
            assertSensitivity(pointFloorlet, SabrParameterType.ALPHA, vegaFloorlet * volSensi.getDerivative(2), TOL);
            assertSensitivity(pointFloorlet, SabrParameterType.BETA, vegaFloorlet * volSensi.getDerivative(3), TOL);
            assertSensitivity(pointFloorlet, SabrParameterType.RHO, vegaFloorlet * volSensi.getDerivative(4), TOL);
            assertSensitivity(pointFloorlet, SabrParameterType.NU, vegaFloorlet * volSensi.getDerivative(5), TOL);
            PointSensitivities pointCapletVol = PRICER.presentValueSensitivityModelParamsVolatility(CAPLET_LONG, RATES, VOLS).build();
            // vol sensitivity in base class
            PointSensitivities            pointFloorletVol    = PRICER.presentValueSensitivityModelParamsVolatility(FLOORLET_SHORT, RATES, VOLS).build();
            IborCapletFloorletSensitivity pointCapletVolExp   = IborCapletFloorletSensitivity.of(VOLS.Name, expiry, STRIKE, forward, EUR, vegaCaplet);
            IborCapletFloorletSensitivity pointFloorletVolExp = IborCapletFloorletSensitivity.of(VOLS.Name, expiry, STRIKE, forward, EUR, vegaFloorlet);

            assertEquals(pointCapletVol.Sensitivities.get(0), pointCapletVolExp);
            assertEquals(pointFloorletVol.Sensitivities.get(0), pointFloorletVolExp);
        }
        // market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedFxNdfTrade trade, RatesProvider ratesProvider)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
示例#3
0
        // market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01RatesMarketQuoteBucketed(ResolvedIborCapFloorTrade trade, RatesProvider ratesProvider, IborCapletFloorletVolatilities volatilities)
        {
            PointSensitivities             pointSensitivity     = this.pointSensitivity(trade, ratesProvider, volatilities);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
示例#4
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            IborRateSensitivity @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            PointSensitivities  test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
示例#5
0
        // market quote sum PV01 for one scenario
        internal MultiCurrencyAmount pv01MarketQuoteSum(ResolvedTermDepositTrade trade, RatesProvider ratesProvider)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).total().multipliedBy(ONE_BASIS_POINT));
        }
        //-------------------------------------------------------------------------
        public virtual void present_value_vol_sensitivity_premium_forward()
        {
            PointSensitivities vegaTrade   = PRICER_TRADE.presentValueSensitivityModelParamsSabr(SWAPTION_PREFWD_LONG_REC, RATE_PROVIDER, VOLS);
            PointSensitivities vegaProduct = PRICER_PRODUCT.presentValueSensitivityModelParamsSabr(SWAPTION_LONG_REC, RATE_PROVIDER, VOLS).build();

            assertEquals(vegaTrade, vegaProduct);
        }
示例#7
0
        //-------------------------------------------------------------------------
        public virtual void present_value_black_vol_sensitivity_premium_forward()
        {
            PointSensitivities  vegaTrade   = PRICER_TRADE.presentValueSensitivityModelParamsVolatility(SWAPTION_PREFWD_LONG_REC, RATE_PROVIDER, VOLS);
            SwaptionSensitivity vegaProduct = PRICER_PRODUCT.presentValueSensitivityModelParamsVolatility(SWAPTION_LONG_REC, RATE_PROVIDER, VOLS);

            assertEquals(vegaTrade.Sensitivities.get(0).Sensitivity, vegaProduct.Sensitivity, NOTIONAL * TOL);
        }
示例#8
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            InflationRateSensitivity @base = InflationRateSensitivity.of(GB_HICP_OBS, 3.5);
            PointSensitivities       test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
        public virtual void test_presentValueSensitivity_ended()
        {
            ResolvedFxSingle   fwd      = ResolvedFxSingle.of(CurrencyAmount.of(USD, NOMINAL_USD), FxRate.of(USD, KRW, FX_RATE), PAYMENT_DATE_PAST);
            PointSensitivities computed = PRICER.presentValueSensitivity(fwd, PROVIDER);

            assertEquals(computed, PointSensitivities.empty());
        }
示例#10
0
        // calibrated sum PV01 for one scenario
        internal MultiCurrencyAmount pv01CalibratedSum(ResolvedBondFutureOptionTrade trade, LegalEntityDiscountingProvider discountingProvider, BondFutureVolatilities volatilities)
        {
            BlackBondFutureVolatilities normalVols       = checkBlackVols(volatilities);
            PointSensitivities          pointSensitivity = tradePricer.presentValueSensitivityRates(trade, discountingProvider, normalVols);

            return(discountingProvider.parameterSensitivity(pointSensitivity).total().multipliedBy(ONE_BASIS_POINT));
        }
示例#11
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            SwaptionSensitivity @base = SwaptionSensitivity.of(NAME, EXPIRY, TENOR, STRIKE, FORWARD, GBP, 32d);
            PointSensitivities  test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
示例#12
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValueSensitivity()
        {
            PointSensitivities ptsTrade   = PRICER_TRADE.presentValueSensitivity(RDEPOSIT_TRADE, IMM_PROV);
            PointSensitivities ptsProduct = PRICER_PRODUCT.presentValueSensitivity(RDEPOSIT_PRODUCT, IMM_PROV);

            assertTrue(ptsTrade.equalWithTolerance(ptsProduct, TOLERANCE_PV_DELTA));
        }
示例#13
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            FxIndexSensitivity @base = FxIndexSensitivity.of(GBP_USD_WM_OBS, USD, GBP, SENSITIVITY_VALUE);
            PointSensitivities test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
示例#14
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            IborCapletFloorletSabrSensitivity @base = IborCapletFloorletSabrSensitivity.of(NAME, EXPIRY, SabrParameterType.ALPHA, GBP, 32d);
            PointSensitivities test = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
示例#15
0
        public virtual void test_parRateSensitivity()
        {
            PointSensitivities computedSpread = PRICER.parSpreadSensitivity(RTERM_DEPOSIT, IMM_PROV);
            PointSensitivities computedRate   = PRICER.parRateSensitivity(RTERM_DEPOSIT, IMM_PROV);

            assertTrue(computedSpread.equalWithTolerance(computedRate, NOTIONAL * EPS_FD));
        }
示例#16
0
        // calculates calibrated bucketed IR01 for one scenario
        internal CurrencyParameterSensitivity ir01CalibratedBucketed(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            PointSensitivities           pointSensitivity = tradePricer.presentValueOnSettleSensitivity(trade, ratesProvider, refData);
            CurrencyParameterSensitivity irSensitivity    = ratesProvider.singleDiscountCurveParameterSensitivity(pointSensitivity, trade.Product.Currency);

            return(irSensitivity.multipliedBy(ONE_BASIS_POINT));
        }
示例#17
0
        //-------------------------------------------------------------------------
        public virtual void present_value_normal_vol_sensitivity_premium_forward()
        {
            PointSensitivities  vegaTrade   = PRICER_TRADE.presentValueSensitivityModelParamsVolatility(SWAPTION_PREFWD_LONG_REC, MULTI_USD, NORMAL_VOLS_USD);
            SwaptionSensitivity vegaProduct = PRICER_PRODUCT.presentValueSensitivityModelParamsVolatility(SWAPTION_LONG_REC, MULTI_USD, NORMAL_VOLS_USD);

            assertEquals(vegaTrade.Sensitivities.get(0).Sensitivity, vegaProduct.Sensitivity, TOLERANCE_PV_VEGA);
        }
示例#18
0
        // calculates market quote bucketed PV01 for one scenario
        internal CurrencyParameterSensitivities pv01MarketQuoteBucketed(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider, refData);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).multipliedBy(ONE_BASIS_POINT));
        }
示例#19
0
        // market quote sum PV01 for one scenario
        internal MultiCurrencyAmount pv01RatesMarketQuoteSum(ResolvedSwaptionTrade trade, RatesProvider ratesProvider, SwaptionVolatilities volatilities)
        {
            PointSensitivities             pointSensitivity     = this.pointSensitivity(trade, ratesProvider, volatilities);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);

            return(MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider).total().multipliedBy(ONE_BASIS_POINT));
        }
示例#20
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            CreditCurveZeroRateSensitivity @base = CreditCurveZeroRateSensitivity.of(LEGAL_ENTITY, GBP, YEAR_FRACTION, 32d);
            PointSensitivities             test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
        /// <summary>
        /// Calculates the price sensitivity of the Ibor future option product
        /// based on the price of the underlying future.
        /// <para>
        /// The price sensitivity of the product is the sensitivity of the price to the underlying curves.
        /// The volatility is unchanged for a fixed strike in the sensitivity computation, hence the "StickyStrike" name.
        ///
        /// </para>
        /// </summary>
        /// <param name="futureOption">  the option product </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="volatilities">  the volatilities </param>
        /// <param name="futurePrice">  the price of the underlying future, in decimal form </param>
        /// <returns> the price curve sensitivity of the product </returns>
        public virtual PointSensitivities priceSensitivityRatesStickyStrike(ResolvedIborFutureOption futureOption, RatesProvider ratesProvider, NormalIborFutureOptionVolatilities volatilities, double futurePrice)
        {
            double             delta = deltaStickyStrike(futureOption, ratesProvider, volatilities, futurePrice);
            PointSensitivities futurePriceSensitivity = futurePricer.priceSensitivity(futureOption.UnderlyingFuture, ratesProvider);

            return(futurePriceSensitivity.multipliedBy(delta));
        }
示例#22
0
        public virtual void test_presentValueSensitivityBlackVolatility()
        {
            PointSensitivities pvSensiTrade   = PRICER_TRADE.presentValueSensitivityModelParamsVolatility(OPTION_TRADE, RATES_PROVIDER, VOLS);
            PointSensitivities pvSensiProduct = PRICER_PRODUCT.presentValueSensitivityModelParamsVolatility(OPTION_PRODUCT, RATES_PROVIDER, VOLS).build();

            assertEquals(pvSensiTrade, pvSensiProduct);
        }
示例#23
0
        // calibrated sum PV01 for one scenario
        internal MultiCurrencyAmount pv01CalibratedSum(ResolvedIborFutureOptionTrade trade, RatesProvider ratesProvider, IborFutureOptionVolatilities volatilities)
        {
            NormalIborFutureOptionVolatilities normalVols = checkNormalVols(volatilities);
            PointSensitivities pointSensitivity           = tradePricer.presentValueSensitivityRates(trade, ratesProvider, normalVols);

            return(ratesProvider.parameterSensitivity(pointSensitivity).total().multipliedBy(ONE_BASIS_POINT));
        }
示例#24
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            IborFutureOptionSensitivity @base = IborFutureOptionSensitivity.of(NAME, 12d, date(2015, 8, 28), 0.98, 0.99, GBP, 32d);
            PointSensitivities          test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
示例#25
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            ZeroRateSensitivity @base = ZeroRateSensitivity.of(GBP, YEARFRAC, 32d);
            PointSensitivities  test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
        /// <summary>
        /// Calculates the price sensitivity of the bond future option product based on the price of the underlying future.
        /// <para>
        /// The price sensitivity of the product is the sensitivity of the price to the underlying curves.
        /// The volatility is unchanged for a fixed strike in the sensitivity computation, hence the "StickyStrike" name.
        ///
        /// </para>
        /// </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 price of the underlying future </param>
        /// <returns> the price curve sensitivity of the product </returns>
        public PointSensitivities priceSensitivityRatesStickyStrike(ResolvedBondFutureOption futureOption, LegalEntityDiscountingProvider discountingProvider, BlackBondFutureVolatilities volatilities, double futurePrice)
        {
            double             delta = deltaStickyStrike(futureOption, discountingProvider, volatilities, futurePrice);
            PointSensitivities futurePriceSensitivity = futurePricer.priceSensitivity(futureOption.UnderlyingFuture, discountingProvider);

            return(futurePriceSensitivity.multipliedBy(delta));
        }
        public virtual void test_build()
        {
            FxOptionSensitivity @base = FxOptionSensitivity.of(NAME, PAIR, EXPIRY, STRIKE, FORWARD, GBP, SENSI_VALUE);
            PointSensitivities  test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
        //-------------------------------------------------------------------------
        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));
        }
示例#29
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value sensitivity to the implied volatility of the swaption trade.
        /// </summary>
        /// <param name="trade">  the swaption trade </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="swaptionVolatilities">  the volatilities </param>
        /// <returns> the point sensitivity to the implied volatility </returns>
        public virtual PointSensitivities presentValueSensitivityModelParamsVolatility(ResolvedSwaptionTrade trade, RatesProvider ratesProvider, SabrSwaptionVolatilities swaptionVolatilities)
        {
            ResolvedSwaption    product   = trade.Product;
            SwaptionSensitivity pointSens = isCash(product) ? cashParYieldPricer.presentValueSensitivityModelParamsVolatility(product, ratesProvider, swaptionVolatilities) : physicalPricer.presentValueSensitivityModelParamsVolatility(product, ratesProvider, swaptionVolatilities);

            return(PointSensitivities.of(pointSens));
        }
        public virtual void test_presentValueSensitivity_ended()
        {
            ResolvedFxSwap     product  = ResolvedFxSwap.ofForwardPoints(CurrencyAmount.of(USD, NOMINAL_USD), KRW, FX_RATE, FX_FWD_POINTS, PAYMENT_DATE_LONG_PAST, PAYMENT_DATE_PAST);
            PointSensitivities computed = PRICER.presentValueSensitivity(product, PROVIDER);

            assertEquals(computed, PointSensitivities.empty());
        }