Beispiel #1
0
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            BondFutureTradeCalculationFunction <BondFutureTrade> function = BondFutureTradeCalculationFunction.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(QUOTE_ID, REPO_CURVE_ID, ISSUER_CURVE_ID));
            assertThat(reqs.TimeSeriesRequirements).isEqualTo(ImmutableSet.of());
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(CURRENCY);
        }
Beispiel #2
0
        public virtual void test_simpleMeasures()
        {
            BondFutureTradeCalculationFunction <BondFutureTrade> function = BondFutureTradeCalculationFunction.TRADE;
            ScenarioMarketData               md          = marketData();
            LegalEntityDiscountingProvider   provider    = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingBondFutureTradePricer pricer      = DiscountingBondFutureTradePricer.DEFAULT;
            CurrencyAmount      expectedPv               = pricer.presentValue(RTRADE, provider, SETTLE_PRICE);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider, SETTLE_PRICE);

            ISet <Measure> measures = ImmutableSet.of(Measures.PRESENT_VALUE, Measures.CURRENCY_EXPOSURE, 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.RESOLVED_TARGET, Result.success(RTRADE));
        }
Beispiel #3
0
        public virtual void test_pv01_calibrated()
        {
            BondFutureTradeCalculationFunction <BondFutureTrade> function = BondFutureTradeCalculationFunction.TRADE;
            ScenarioMarketData               md                      = marketData();
            LegalEntityDiscountingProvider   provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingBondFutureTradePricer pricer                  = DiscountingBondFutureTradePricer.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))));
        }
Beispiel #4
0
        public virtual void test_pv01_quote()
        {
            BondFutureTradeCalculationFunction <BondFutureTrade> function = BondFutureTradeCalculationFunction.TRADE;
            ScenarioMarketData               md                      = marketData();
            LegalEntityDiscountingProvider   provider                = LOOKUP.marketDataView(md.scenario(0)).discountingProvider();
            DiscountingBondFutureTradePricer pricer                  = DiscountingBondFutureTradePricer.DEFAULT;
            PointSensitivities               pvPointSens             = pricer.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities   pvParamSens             = provider.parameterSensitivity(pvPointSens);
            CurrencyParameterSensitivities   expectedPv01CalBucketed = MQ_CALC.sensitivity(pvParamSens.multipliedBy(1e-4), provider);
            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(USD));
            assertTrue(DoubleMath.fuzzyEquals(sumComputed.get(0).getAmount(USD).Amount, expectedPv01Cal.getAmount(USD).Amount, 1.0e-10));
            assertEquals(bucketedComputed.ScenarioCount, 1);
            assertTrue(bucketedComputed.get(0).equalWithTolerance(expectedPv01CalBucketed, 1.0e-10));
        }