Exemple #1
0
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            FixedCouponBondTradeCalculationFunction <FixedCouponBondTrade> function = FixedCouponBondTradeCalculationFunction.TRADE;
            ISet <Measure>       measures = function.supportedMeasures();
            FunctionRequirements reqs     = function.requirements(TRADE, measures, PARAMS, REF_DATA);

            assertThat(reqs.OutputCurrencies).containsOnly(CURRENCY);
            assertThat(reqs.ValueRequirements).isEqualTo(ImmutableSet.of(REPO_CURVE_ID, ISSUER_CURVE_ID));
            assertThat(reqs.TimeSeriesRequirements).isEqualTo(ImmutableSet.of());
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(CURRENCY);
        }
Exemple #2
0
        public virtual void test_simpleMeasures()
        {
            FixedCouponBondTradeCalculationFunction <FixedCouponBondTrade> function = FixedCouponBondTradeCalculationFunction.TRADE;
            ScenarioMarketData                    md       = 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, VAL_DATE);

            ISet <Measure> measures = ImmutableSet.of(Measures.PRESENT_VALUE, Measures.CURRENCY_EXPOSURE, Measures.CURRENT_CASH, Measures.RESOLVED_TARGET);

            assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PRESENT_VALUE, Result.success(CurrencyScenarioArray.of(ImmutableList.of(expectedPv)))).containsEntry(Measures.CURRENCY_EXPOSURE, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)))).containsEntry(Measures.CURRENT_CASH, Result.success(CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)))).containsEntry(Measures.RESOLVED_TARGET, Result.success(RTRADE));
        }
Exemple #3
0
        public virtual void test_pv01_calibrated()
        {
            FixedCouponBondTradeCalculationFunction <FixedCouponBondTrade> function = FixedCouponBondTradeCalculationFunction.TRADE;
            ScenarioMarketData                    md                      = 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);

            ISet <Measure> measures = ImmutableSet.of(Measures.PV01_CALIBRATED_SUM, Measures.PV01_CALIBRATED_BUCKETED);

            assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PV01_CALIBRATED_SUM, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal)))).containsEntry(Measures.PV01_CALIBRATED_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed))));
        }
Exemple #4
0
        public virtual void test_pv01_quote()
        {
            FixedCouponBondTradeCalculationFunction <FixedCouponBondTrade> function = FixedCouponBondTradeCalculationFunction.TRADE;
            ScenarioMarketData                    md                      = 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();

            ISet <Measure> measures = ImmutableSet.of(Measures.PV01_MARKET_QUOTE_SUM, Measures.PV01_MARKET_QUOTE_BUCKETED);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Map<com.opengamma.strata.calc.Measure, com.opengamma.strata.collect.result.Result<?>> computed = function.calculate(TRADE, measures, PARAMS, md, REF_DATA);
            IDictionary <Measure, Result <object> > computed = function.calculate(TRADE, measures, PARAMS, md, REF_DATA);
            MultiCurrencyScenarioArray sumComputed           = (MultiCurrencyScenarioArray)computed[Measures.PV01_MARKET_QUOTE_SUM].Value;
            ScenarioArray <CurrencyParameterSensitivities> bucketedComputed = (ScenarioArray <CurrencyParameterSensitivities>)computed[Measures.PV01_MARKET_QUOTE_BUCKETED].Value;

            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));
        }