//-------------------------------------------------------------------------
        /// <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));
        }
        //-------------------------------------------------------------------------
        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)));
        }
Пример #4
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            ScenarioMarketData         md                = SwapTradeCalculationFunctionTest.marketData();
            RatesProvider              provider          = RATES_LOOKUP.marketDataView(md.scenario(0)).ratesProvider();
            DiscountingSwapTradePricer pricer            = DiscountingSwapTradePricer.DEFAULT;
            MultiCurrencyAmount        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);
            MultiCurrencyAmount expectedCurrentCash      = pricer.currentCash(RTRADE, provider);

            assertEquals(SwapTradeCalculations.DEFAULT.presentValue(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedPv)));
            assertEquals(SwapTradeCalculations.DEFAULT.explainPresentValue(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedExplainPv)));
            assertEquals(SwapTradeCalculations.DEFAULT.parRate(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParRate)));
            assertEquals(SwapTradeCalculations.DEFAULT.parSpread(RTRADE, RATES_LOOKUP, md), DoubleScenarioArray.of(ImmutableList.of(expectedParSpread)));
            assertEquals(SwapTradeCalculations.DEFAULT.cashFlows(RTRADE, RATES_LOOKUP, md), ScenarioArray.of(ImmutableList.of(expectedCashFlows)));
            assertEquals(SwapTradeCalculations.DEFAULT.currencyExposure(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrencyExposure)));
            assertEquals(SwapTradeCalculations.DEFAULT.currentCash(RTRADE, RATES_LOOKUP, md), MultiCurrencyScenarioArray.of(ImmutableList.of(expectedCurrentCash)));
        }
Пример #5
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));
        }