public virtual void test_simpleMeasures() { FraTradeCalculationFunction function = new FraTradeCalculationFunction(); ScenarioMarketData md = marketData(); RatesProvider provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider(); DiscountingFraTradePricer pricer = DiscountingFraTradePricer.DEFAULT; CurrencyAmount expectedPv = pricer.presentValue(RTRADE, provider); ExplainMap expectedExplainPv = pricer.explainPresentValue(RTRADE, provider); double expectedParRate = pricer.parRate(RTRADE, provider); double expectedParSpread = pricer.parSpread(RTRADE, provider); CashFlows expectedCashFlows = pricer.cashFlows(RTRADE, provider); MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(RTRADE, provider); CurrencyAmount expectedCurrentCash = pricer.currentCash(RTRADE, provider); ISet <Measure> measures = ImmutableSet.of(Measures.PRESENT_VALUE, Measures.EXPLAIN_PRESENT_VALUE, Measures.PAR_RATE, Measures.PAR_SPREAD, Measures.CASH_FLOWS, Measures.CURRENCY_EXPOSURE, Measures.CURRENT_CASH, 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.EXPLAIN_PRESENT_VALUE, Result.success(ScenarioArray.of(ImmutableList.of(expectedExplainPv)))).containsEntry(Measures.PAR_RATE, Result.success(DoubleScenarioArray.of(ImmutableList.of(expectedParRate)))).containsEntry(Measures.PAR_SPREAD, Result.success(DoubleScenarioArray.of(ImmutableList.of(expectedParSpread)))).containsEntry(Measures.CASH_FLOWS, Result.success(ScenarioArray.of(ImmutableList.of(expectedCashFlows)))).containsEntry(Measures.CURRENCY_EXPOSURE, Result.success(MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)))).containsEntry(Measures.CURRENT_CASH, Result.success(CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)))).containsEntry(Measures.RESOLVED_TARGET, Result.success(RTRADE)); }
// par rate for one scenario internal double parRate(ResolvedFraTrade trade, RatesProvider ratesProvider) { return(tradePricer.parRate(trade, ratesProvider)); }