コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            FxNdfTradeCalculationFunction function = new FxNdfTradeCalculationFunction();
            ISet <Measure>       measures          = function.supportedMeasures();
            FunctionRequirements reqs = function.requirements(TRADE, measures, PARAMS, REF_DATA);

            assertThat(reqs.OutputCurrencies).containsExactly(GBP, USD);
            assertThat(reqs.ValueRequirements).isEqualTo(ImmutableSet.of(DISCOUNT_CURVE_GBP_ID, DISCOUNT_CURVE_USD_ID));
            assertThat(reqs.TimeSeriesRequirements).Empty;
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(GBP);
        }
コード例 #2
0
        public virtual void test_simpleMeasures()
        {
            FxNdfTradeCalculationFunction function = new FxNdfTradeCalculationFunction();
            ScenarioMarketData            md       = marketData();
            RatesProvider provider                  = RATES_LOOKUP.ratesProvider(md.scenario(0));
            DiscountingFxNdfTradePricer pricer      = DiscountingFxNdfTradePricer.DEFAULT;
            CurrencyAmount      expectedPv          = pricer.presentValue(RTRADE, provider);
            MultiCurrencyAmount expectedCurrencyExp = pricer.currencyExposure(RTRADE, provider);
            CurrencyAmount      expectedCash        = pricer.currentCash(RTRADE, provider);
            FxRate expectedForwardFx                = pricer.forwardFxRate(RTRADE, provider);

            ISet <Measure> measures = ImmutableSet.of(Measures.PRESENT_VALUE, Measures.CURRENCY_EXPOSURE, Measures.CURRENT_CASH, Measures.FORWARD_FX_RATE, 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(expectedCurrencyExp)))).containsEntry(Measures.CURRENT_CASH, Result.success(CurrencyScenarioArray.of(ImmutableList.of(expectedCash)))).containsEntry(Measures.FORWARD_FX_RATE, Result.success(ScenarioArray.of(ImmutableList.of(expectedForwardFx)))).containsEntry(Measures.RESOLVED_TARGET, Result.success(RTRADE));
        }
コード例 #3
0
        public virtual void test_pv01()
        {
            FxNdfTradeCalculationFunction function = new FxNdfTradeCalculationFunction();
            ScenarioMarketData            md       = marketData();
            RatesProvider provider = RATES_LOOKUP.ratesProvider(md.scenario(0));
            DiscountingFxNdfTradePricer    pricer               = DiscountingFxNdfTradePricer.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))));
        }