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

            assertThat(reqs.OutputCurrencies).containsExactly(EUR, USD);
            assertThat(reqs.ValueRequirements).isEqualTo(ImmutableSet.of(DISCOUNT_CURVE_EUR_ID, DISCOUNT_CURVE_USD_ID, VOL_ID));
            assertThat(reqs.TimeSeriesRequirements).Empty;
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(EUR);
        }
コード例 #2
0
        public virtual void test_simpleMeasures()
        {
            FxVanillaOptionTradeCalculationFunction function = new FxVanillaOptionTradeCalculationFunction();
            ScenarioMarketData md                               = marketData();
            RatesProvider      provider                         = RATES_LOOKUP.ratesProvider(md.scenario(0));
            BlackFxVanillaOptionTradePricer pricer              = BlackFxVanillaOptionTradePricer.DEFAULT;
            MultiCurrencyAmount             expectedPv          = pricer.presentValue(RTRADE, provider, VOLS);
            MultiCurrencyAmount             expectedCurrencyExp = pricer.currencyExposure(RTRADE, provider, VOLS);
            CurrencyAmount expectedCash                         = pricer.currentCash(RTRADE, VAL_DATE);

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

            assertThat(function.calculate(TRADE, measures, PARAMS, md, REF_DATA)).containsEntry(Measures.PRESENT_VALUE, Result.success(MultiCurrencyScenarioArray.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.RESOLVED_TARGET, Result.success(RTRADE));
        }
コード例 #3
0
        public virtual void test_pv01()
        {
            FxVanillaOptionTradeCalculationFunction function = new FxVanillaOptionTradeCalculationFunction();
            ScenarioMarketData md                               = marketData();
            RatesProvider      provider                         = RATES_LOOKUP.ratesProvider(md.scenario(0));
            BlackFxVanillaOptionTradePricer pricer              = BlackFxVanillaOptionTradePricer.DEFAULT;
            PointSensitivities             pvPointSens          = pricer.presentValueSensitivityRatesStickyStrike(RTRADE, provider, VOLS);
            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))));
        }