Exemple #1
0
        //-------------------------------------------------------------------------
        public virtual void test_requirementsAndCurrency()
        {
            CmsTradeCalculationFunction function = new CmsTradeCalculationFunction();
            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, SWAPTION_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()
        {
            CmsTradeCalculationFunction function = new CmsTradeCalculationFunction();
            ScenarioMarketData          md       = marketData();
            RatesProvider provider = RATES_LOOKUP.ratesProvider(md.scenario(0));
            SabrExtrapolationReplicationCmsTradePricer pricer = new SabrExtrapolationReplicationCmsTradePricer(new SabrExtrapolationReplicationCmsProductPricer(new SabrExtrapolationReplicationCmsLegPricer(SabrExtrapolationReplicationCmsPeriodPricer.of(CUT_OFF_STRIKE, MU))));
            ResolvedCmsTrade    resolved   = TRADE.resolve(REF_DATA);
            MultiCurrencyAmount expectedPv = pricer.presentValue(resolved, provider, VOLS);

            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(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)))).containsEntry(Measures.RESOLVED_TARGET, Result.success(TRADE.resolve(REF_DATA)));
        }