public void test_presentValue() { Currency ccy1 = TRADE.getProduct().getNonDeliverableCurrency(); Currency ccy2 = TRADE.getProduct().getSettlementCurrency(); LocalDate valDate = TRADE.getProduct().getPaymentDate().plusDays(7); FunctionConfig<FxNdfTrade> config = FxNdfFunctionGroups.discounting().functionConfig(TRADE, Measure.PRESENT_VALUE).get(); CalculationSingleFunction<FxNdfTrade, ?> function = config.createFunction(); FunctionRequirements reqs = function.requirements(TRADE); assertThat(reqs.getOutputCurrencies()).containsOnly(ccy1, ccy2); assertThat(reqs.getSingleValueRequirements()) .isEqualTo(ImmutableSet.of(DiscountCurveKey.of(ccy1), DiscountCurveKey.of(ccy2))); assertThat(reqs.getTimeSeriesRequirements()).isEqualTo(ImmutableSet.of()); assertThat(function.defaultReportingCurrency(TRADE)).hasValue(GBP); DiscountFactors df1 = SimpleDiscountFactors.of( ccy1, valDate, ConstantNodalCurve.of(Curves.discountFactors("Test", ACT_360), 0.99)); DiscountFactors df2 = SimpleDiscountFactors.of( ccy2, valDate, ConstantNodalCurve.of(Curves.discountFactors("Test", ACT_360), 0.99)); TestMarketDataMap md = new TestMarketDataMap( valDate, ImmutableMap.of(DiscountCurveKey.of(ccy1), df1, DiscountCurveKey.of(ccy2), df2), ImmutableMap.of()); assertThat(function.execute(TRADE, md)) .isEqualTo(FxConvertibleList.of(ImmutableList.of(CurrencyAmount.zero(GBP)))); }
public void test_discounting() { FunctionGroup<FxNdfTrade> test = FxNdfFunctionGroups.discounting(); assertThat(test.configuredMeasures(TRADE)) .contains( Measure.PRESENT_VALUE, Measure.PV01, Measure.BUCKETED_PV01, Measure.CURRENCY_EXPOSURE, Measure.FORWARD_FX_RATE); }