public virtual void test_pv01() { ScenarioMarketData md = BulletPaymentTradeCalculationFunctionTest.marketData(); RatesProvider provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider(); DiscountingPaymentPricer pricer = DiscountingPaymentPricer.DEFAULT; Payment payment = RTRADE.Product.Payment; PointSensitivities pvPointSens = pricer.presentValueSensitivity(payment, provider).build(); CurrencyParameterSensitivities pvParamSens = provider.parameterSensitivity(pvPointSens); MultiCurrencyAmount expectedPv01Cal = pvParamSens.total().multipliedBy(1e-4); CurrencyParameterSensitivities expectedPv01CalBucketed = pvParamSens.multipliedBy(1e-4); assertEquals(BulletPaymentTradeCalculations.DEFAULT.pv01CalibratedSum(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv01Cal))); assertEquals(BulletPaymentTradeCalculations.DEFAULT.pv01CalibratedBucketed(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedPv01CalBucketed))); }
//------------------------------------------------------------------------- public virtual void test_presentValue() { ScenarioMarketData md = BulletPaymentTradeCalculationFunctionTest.marketData(); RatesProvider provider = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider(); DiscountingPaymentPricer pricer = DiscountingPaymentPricer.DEFAULT; Payment payment = RTRADE.Product.Payment; CurrencyAmount expectedPv = pricer.presentValue(payment, provider); CashFlows expectedCashFlows = pricer.cashFlows(payment, provider); MultiCurrencyAmount expectedCurrencyExposure = pricer.currencyExposure(payment, provider); CurrencyAmount expectedCurrentCash = pricer.currentCash(payment, provider); assertEquals(BulletPaymentTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedPv))); assertEquals(BulletPaymentTradeCalculations.DEFAULT.cashFlows(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedCashFlows))); assertEquals(BulletPaymentTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure))); assertEquals(BulletPaymentTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), CurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash))); }