コード例 #1
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)));
        }
コード例 #2
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData         md                = SwapTradeCalculationFunctionTest.marketData();
            RatesProvider              provider          = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingSwapTradePricer pricer            = DiscountingSwapTradePricer.DEFAULT;
            MultiCurrencyAmount        expectedPv        = pricer.presentValue(RTRADE, provider);
            ExplainMap          expectedExplainPv        = pricer.explainPresentValue(RTRADE, provider);
            double              expectedParRate          = pricer.parRate(RTRADE, provider);
            double              expectedParSpread        = pricer.parSpread(RTRADE, provider);
            CashFlows           expectedCashFlows        = pricer.cashFlows(RTRADE, provider);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider);
            MultiCurrencyAmount expectedCurrentCash      = pricer.currentCash(RTRADE, provider);

            assertEquals(SwapTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(SwapTradeCalculations.DEFAULT.explainPresentValue(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedExplainPv)));
            assertEquals(SwapTradeCalculations.DEFAULT.parRate(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParRate)));
            assertEquals(SwapTradeCalculations.DEFAULT.parSpread(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParSpread)));
            assertEquals(SwapTradeCalculations.DEFAULT.cashFlows(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedCashFlows)));
            assertEquals(SwapTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(SwapTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }