コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            DsfTradeCalculationFunction <DsfTrade> function = DsfTradeCalculationFunction.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_KEY, DISCOUNT_CURVE_ID, FORWARD_CURVE_ID));
            assertThat(reqs.TimeSeriesRequirements).isEqualTo(ImmutableSet.of(IndexQuoteId.of(INDEX)));
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(CURRENCY);
        }
コード例 #2
0
        public virtual void test_simpleMeasures()
        {
            DsfTradeCalculationFunction <DsfTrade> function = DsfTradeCalculationFunction.TRADE;
            ScenarioMarketData        md                 = marketData();
            RatesProvider             provider           = RATES_LOOKUP.ratesProvider(md.scenario(0));
            DiscountingDsfTradePricer pricer             = DiscountingDsfTradePricer.DEFAULT;
            double              expectedPrice            = pricer.price(RTRADE, provider);
            CurrencyAmount      expectedPv               = pricer.presentValue(RTRADE, provider, REF_PRICE);
            MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider, REF_PRICE);

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

            assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.UNIT_PRICE, Result.success(DoubleScenarioArray.of(ImmutableList.of(expectedPrice)))).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));
        }
コード例 #3
0
        public virtual void test_pv01()
        {
            DsfTradeCalculationFunction <DsfTrade> function = DsfTradeCalculationFunction.TRADE;
            ScenarioMarketData             md                   = marketData();
            RatesProvider                  provider             = RATES_LOOKUP.ratesProvider(md.scenario(0));
            DiscountingDsfTradePricer      pricer               = DiscountingDsfTradePricer.DEFAULT;
            PointSensitivities             pvPointSens          = pricer.presentValueSensitivity(RTRADE, provider);
            CurrencyParameterSensitivities pvParamSens          = provider.parameterSensitivity(pvPointSens);
            MultiCurrencyAmount            expectedPv01         = pvParamSens.total().multipliedBy(1e-4);
            CurrencyParameterSensitivities expectedBucketedPv01 = 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(expectedPv01)))).containsEntry(Measures.PV01_CALIBRATED_BUCKETED, Result.success(ScenarioArray.of(ImmutableList.of(expectedBucketedPv01))));
        }