//-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the future cash flow of the FRA product.
        /// <para>
        /// There is only one cash flow on the payment date for the FRA product.
        /// The expected currency amount of the cash flow is the same as <seealso cref="#forecastValue(ResolvedFra, RatesProvider)"/>.
        ///
        /// </para>
        /// </summary>
        /// <param name="fra">  the product </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the cash flows </returns>
        public virtual CashFlows cashFlows(ResolvedFra fra, RatesProvider provider)
        {
            LocalDate paymentDate   = fra.PaymentDate;
            double    forecastValue = forecastValue0(fra, provider);
            double    df            = provider.discountFactor(fra.Currency, paymentDate);
            CashFlow  cashFlow      = CashFlow.ofForecastValue(paymentDate, fra.Currency, forecastValue, df);

            return(CashFlows.of(cashFlow));
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the future cash flow of the payment.
        /// <para>
        /// The cash flow is returned, empty if the payment has already occurred.
        ///
        /// </para>
        /// </summary>
        /// <param name="payment">  the payment </param>
        /// <param name="provider">  the provider </param>
        /// <returns> the cash flow, empty if the payment has occurred </returns>
        public virtual CashFlows cashFlows(Payment payment, BaseProvider provider)
        {
            if (provider.ValuationDate.isAfter(payment.Date))
            {
                return(CashFlows.NONE);
            }
            double   df   = provider.discountFactor(payment.Currency, payment.Date);
            CashFlow flow = CashFlow.ofForecastValue(payment.Date, payment.Currency, payment.Amount, df);

            return(CashFlows.of(flow));
        }
Пример #3
0
        //-------------------------------------------------------------------------
        public virtual void test_cashFlow_provider()
        {
            CashFlow expected = CashFlow.ofForecastValue(PAYMENT_DATE, USD, NOTIONAL_USD, DF);

            assertEquals(PRICER.cashFlows(TRADE, PROVIDER), CashFlows.of(expected));
        }