Exemple #1
0
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            SwaptionTradeCalculationFunction function = new SwaptionTradeCalculationFunction();
            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(DISCOUNT_CURVE_ID, FORWARD_CURVE_ID, VOL_ID));
            assertThat(reqs.TimeSeriesRequirements).isEqualTo(ImmutableSet.of(IndexQuoteId.of(INDEX)));
            assertThat(function.naturalCurrency(TRADE, REF_DATA)).isEqualTo(CURRENCY);
        }
Exemple #2
0
        public virtual void test_simpleMeasures()
        {
            SwaptionTradeCalculationFunction function = new SwaptionTradeCalculationFunction();
            ScenarioMarketData        md         = marketData();
            RatesProvider             provider   = RATES_LOOKUP.ratesProvider(md.scenario(0));
            NormalSwaptionTradePricer pricer     = NormalSwaptionTradePricer.DEFAULT;
            ResolvedSwaptionTrade     resolved   = TRADE.resolve(REF_DATA);
            CurrencyAmount            expectedPv = pricer.presentValue(resolved, provider, NORMAL_VOL_SWAPTION_PROVIDER_USD);

            ISet <Measure> measures = ImmutableSet.of(Measures.PRESENT_VALUE, 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.RESOLVED_TARGET, Result.success(RTRADE));
        }