Esempio n. 1
0
        public virtual void test_pv01_calibrated()
        {
            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);
            MultiCurrencyAmount                   expectedPv01Cal         = pvParamSens.total().multipliedBy(1e-4);
            CurrencyParameterSensitivities        expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4);

            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.pv01CalibratedSum(RTRADE, LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)));
            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.pv01CalibratedBucketed(RTRADE, LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed)));
        }
Esempio n. 2
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData                    md       = FixedCouponBondTradeCalculationFunctionTest.marketData();
            LegalEntityDiscountingProvider        provider = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingFixedCouponBondTradePricer pricer   = DiscountingFixedCouponBondTradePricer.DEFAULT;
            CurrencyAmount      expectedPv = pricer.presentValue(RTRADE, provider);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider);
            CurrencyAmount      expectedCurrentCash      = pricer.currentCash(RTRADE, provider.ValuationDate);

            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.presentValue(RTRADE, LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.currencyExposure(RTRADE, LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(FixedCouponBondTradeCalculations.DEFAULT.currentCash(RTRADE, LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
Esempio n. 3
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));
        }