Exemplo n.º 1
0
        // calculates market quote sum PV01 for one scenario
        internal MultiCurrencyAmount pv01MarketQuoteSum(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueSensitivity(trade, ratesProvider, refData);
            CurrencyParameterSensitivities parameterSensitivity = ratesProvider.parameterSensitivity(pointSensitivity);
            CurrencyParameterSensitivities quoteSensitivity     = MARKET_QUOTE_SENS.sensitivity(parameterSensitivity, ratesProvider);

            return(quoteSensitivity.total().multipliedBy(ONE_BASIS_POINT));
        }
Exemplo n.º 2
0
        // calculates market quote parallel IR01 for one scenario
        internal MultiCurrencyAmount ir01MarketQuoteParallel(ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            PointSensitivities             pointSensitivity     = tradePricer.presentValueOnSettleSensitivity(trade, ratesProvider, refData);
            CurrencyParameterSensitivity   parameterSensitivity = ratesProvider.singleDiscountCurveParameterSensitivity(pointSensitivity, trade.Product.Currency);
            CurrencyParameterSensitivities irSensitivity        = MARKET_QUOTE_SENS.sensitivity(CurrencyParameterSensitivities.of(parameterSensitivity), ratesProvider);

            return(irSensitivity.total().multipliedBy(ONE_BASIS_POINT));
        }
        public virtual void test_pv01_quote()
        {
            PointSensitivities             pvPointSens          = TRADE_PRICER.presentValueSensitivity(RESOLVED_TRADE, RATES_PROVIDER);
            CurrencyParameterSensitivities pvParamSens          = RATES_PROVIDER.parameterSensitivity(pvPointSens);
            CurrencyParameterSensitivities expectedPv01Bucketed = MQ_CALC.sensitivity(pvParamSens, RATES_PROVIDER).multipliedBy(ONE_BP);
            MultiCurrencyAmount            expectedPv01Sum      = expectedPv01Bucketed.total();

            assertEquals(CALC.pv01MarketQuoteSum(RESOLVED_TRADE, RATES_LOOKUP, MARKET_DATA), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Sum)));
            assertEquals(CALC.pv01MarketQuoteSum(RESOLVED_TRADE, RATES_PROVIDER), expectedPv01Sum);
            assertEquals(CALC.pv01MarketQuoteBucketed(RESOLVED_TRADE, RATES_LOOKUP, MARKET_DATA), ScenarioArray.of(ImmutableList.of(expectedPv01Bucketed)));
            assertEquals(CALC.pv01MarketQuoteBucketed(RESOLVED_TRADE, RATES_PROVIDER), expectedPv01Bucketed);
        }
        public virtual void test_pv01_calibrated()
        {
            PointSensitivities             pvPointSens             = TRADE_PRICER.presentValueSensitivity(RESOLVED_TRADE, RATES_PROVIDER);
            CurrencyParameterSensitivities pvParamSens             = RATES_PROVIDER.parameterSensitivity(pvPointSens);
            MultiCurrencyAmount            expectedPv01Cal         = pvParamSens.total().multipliedBy(ONE_BP);
            CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(ONE_BP);

            assertEquals(CALC.pv01CalibratedSum(RESOLVED_TRADE, RATES_LOOKUP, MARKET_DATA), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(CALC.pv01CalibratedSum(RESOLVED_TRADE, RATES_PROVIDER), expectedPv01Cal);
            assertEquals(CALC.pv01CalibratedBucketed(RESOLVED_TRADE, RATES_LOOKUP, MARKET_DATA), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
            assertEquals(CALC.pv01CalibratedBucketed(RESOLVED_TRADE, RATES_PROVIDER), expectedPv01CalBucketed);
        }
Exemplo n.º 5
0
        public virtual void test_pv01()
        {
            ScenarioMarketData md       = FxSingleBarrierOptionTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            BlackFxSingleBarrierOptionTradePricer pricer           = BlackFxSingleBarrierOptionTradePricer.DEFAULT;
            PointSensitivities             pvPointSens             = pricer.presentValueSensitivityRatesStickyStrike(RTRADE, provider, VOLS);
            CurrencyParameterSensitivities pvParamSens             = provider.parameterSensitivity(pvPointSens);
            MultiCurrencyAmount            expectedPv01Cal         = pvParamSens.total().multipliedBy(1e-4);
            CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4);

            assertEquals(FxSingleBarrierOptionTradeCalculations.DEFAULT.pv01RatesCalibratedSum(RTRADE, RATES_LOOKUP, FX_OPTION_LOOKUP, md, BLACK), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(FxSingleBarrierOptionTradeCalculations.DEFAULT.pv01RatesCalibratedBucketed(RTRADE, RATES_LOOKUP, FX_OPTION_LOOKUP, md, BLACK), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
Exemplo n.º 6
0
        public virtual void test_pv01()
        {
            ScenarioMarketData             md                      = SwapTradeCalculationFunctionTest.marketData();
            RatesProvider                  provider                = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingSwapTradePricer     pricer                  = DiscountingSwapTradePricer.DEFAULT;
            PointSensitivities             pvPointSens             = pricer.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities pvParamSens             = provider.parameterSensitivity(pvPointSens);
            MultiCurrencyAmount            expectedPv01Cal         = pvParamSens.total().multipliedBy(1e-4);
            CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4);

            assertEquals(SwapTradeCalculations.DEFAULT.pv01CalibratedSum(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(SwapTradeCalculations.DEFAULT.pv01CalibratedBucketed(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
Exemplo n.º 7
0
        public virtual void test_pv01_quote()
        {
            ScenarioMarketData             md                      = BillTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            PointSensitivities             pvPointSens             = PRICER.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities pvParamSens             = provider.parameterSensitivity(pvPointSens);
            CurrencyParameterSensitivities expectedPv01CalBucketed = MQ_CALC.sensitivity(pvParamSens, provider).multipliedBy(1e-4);
            MultiCurrencyAmount            expectedPv01Cal         = expectedPv01CalBucketed.total();

            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteSum(RTRADE, LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteBucketed(RTRADE, LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteSum(RTRADE, provider), expectedPv01Cal);
            assertEquals(BillTradeCalculations.DEFAULT.pv01MarketQuoteBucketed(RTRADE, provider), expectedPv01CalBucketed);
        }
Exemplo n.º 8
0
        public virtual void test_pv01()
        {
            ScenarioMarketData md       = CmsTradeCalculationFunctionTest.marketData();
            RatesProvider      provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            SabrExtrapolationReplicationCmsTradePricer pricer      = new SabrExtrapolationReplicationCmsTradePricer(new SabrExtrapolationReplicationCmsProductPricer(new SabrExtrapolationReplicationCmsLegPricer(SabrExtrapolationReplicationCmsPeriodPricer.of(CMS_MODEL.CutOffStrike, CMS_MODEL.Mu))));
            PointSensitivities             pvPointSens             = pricer.presentValueSensitivityRates(RTRADE, provider, VOLS);
            CurrencyParameterSensitivities pvParamSens             = provider.parameterSensitivity(pvPointSens);
            MultiCurrencyAmount            expectedPv01Cal         = pvParamSens.total().multipliedBy(1e-4);
            CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4);

            CmsTradeCalculations calcs = CmsTradeCalculations.of(CMS_MODEL);

            assertEquals(calcs.pv01RatesCalibratedSum(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(calcs.pv01RatesCalibratedBucketed(RTRADE, RATES_LOOKUP, SWAPTION_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
Exemplo n.º 9
0
        public virtual void test_pv01_quote()
        {
            ScenarioMarketData                    md                      = FixedCouponBondTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider        provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingFixedCouponBondTradePricer pricer                  = DiscountingFixedCouponBondTradePricer.DEFAULT;
            PointSensitivities                    pvPointSens             = pricer.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities        pvParamSens             = provider.parameterSensitivity(pvPointSens);
            CurrencyParameterSensitivities        expectedPv01CalBucketed = MQ_CALC.sensitivity(pvParamSens, provider).multipliedBy(1e-4);
            MultiCurrencyAmount                   expectedPv01Cal         = expectedPv01CalBucketed.total();

            MultiCurrencyScenarioArray sumComputed = FixedCouponBondTradeCalculations.DEFAULT.pv01MarketQuoteSum(RTRADE, LOOKUP, md);
            ScenarioArray <CurrencyParameterSensitivities> bucketedComputed = FixedCouponBondTradeCalculations.DEFAULT.pv01MarketQuoteBucketed(RTRADE, LOOKUP, md);

            assertEquals(sumComputed.ScenarioCount, 1);
            assertEquals(sumComputed.get(0).Currencies, ImmutableSet.of(GBP));
            assertTrue(DoubleMath.fuzzyEquals(sumComputed.get(0).getAmount(GBP).Amount, expectedPv01Cal.getAmount(GBP).Amount, 1.0e-10));
            assertEquals(bucketedComputed.ScenarioCount, 1);
            assertTrue(bucketedComputed.get(0).equalWithTolerance(expectedPv01CalBucketed, 1.0e-10));
        }
        // calibrated sum PV01 for one scenario
        internal MultiCurrencyAmount pv01RatesCalibratedSum(ResolvedFxVanillaOptionTrade trade, RatesProvider ratesProvider, FxOptionVolatilities volatilities, FxVanillaOptionMethod method)
        {
            CurrencyParameterSensitivities paramSens = pointSensitivity(trade, ratesProvider, volatilities, method);

            return(paramSens.total().multipliedBy(ONE_BASIS_POINT));
        }