// calculates the cash flow of the events composing the leg in the currency of the swap leg internal virtual CashFlows cashFlowEventsInternal(ResolvedSwapLeg leg, RatesProvider provider) { ImmutableList.Builder <CashFlow> builder = ImmutableList.builder(); foreach (SwapPaymentEvent @event in leg.PaymentEvents) { if ([email protected](provider.ValuationDate)) { double forecastValue = paymentEventPricer.forecastValue(@event, provider); if (forecastValue != 0d) { Currency currency = @event.Currency; LocalDate paymentDate = @event.PaymentDate; double discountFactor = provider.discountFactor(currency, paymentDate); CashFlow singleCashFlow = CashFlow.ofForecastValue(paymentDate, currency, forecastValue, discountFactor); builder.add(singleCashFlow); } } } return(CashFlows.of(builder.build())); }
//------------------------------------------------------------------------- public virtual void test_cashFlow_provider() { CashFlow expected = CashFlow.ofForecastValue(PAYMENT_DATE, USD, NOTIONAL_USD, DF); assertEquals(PRICER.cashFlows(PAYMENT, PROVIDER), CashFlows.of(expected)); }