Example #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the FX swap product.
        /// <para>
        /// This discounts each payment on each leg in its own currency.
        ///
        /// </para>
        /// </summary>
        /// <param name="swap">  the product </param>
        /// <param name="provider">  the rates provider </param>
        /// <returns> the present value in the two natural currencies </returns>
        public virtual MultiCurrencyAmount presentValue(ResolvedFxSwap swap, RatesProvider provider)
        {
            MultiCurrencyAmount farPv  = fxPricer.presentValue(swap.FarLeg, provider);
            MultiCurrencyAmount nearPv = fxPricer.presentValue(swap.NearLeg, provider);

            return(nearPv.plus(farPv));
        }
        public virtual void test_presentValue()
        {
            MultiCurrencyAmount computed = PRICER.presentValue(FWD, PROVIDER);
            double expected1             = NOMINAL_USD * PROVIDER.discountFactor(USD, PAYMENT_DATE);
            double expected2             = -NOMINAL_USD *FX_RATE *PROVIDER.discountFactor(KRW, PAYMENT_DATE);

            assertEquals(computed.getAmount(USD).Amount, expected1, NOMINAL_USD * TOL);
            assertEquals(computed.getAmount(KRW).Amount, expected2, NOMINAL_USD * TOL);
        }
        // Checks that the NDF present value is coherent with the standard FX forward present value.
        public virtual void test_presentValueVsForex()
        {
            CurrencyAmount      pvNDF = PRICER.presentValue(NDF, PROVIDER);
            MultiCurrencyAmount pvFX  = PRICER_FX.presentValue(FOREX, PROVIDER);

            assertEquals(pvNDF.Amount, pvFX.getAmount(USD).Amount + pvFX.getAmount(KRW).Amount *FX_MATRIX.fxRate(KRW, USD), NOMINAL_USD * TOL);
        }
 //-------------------------------------------------------------------------
 public virtual void test_presentValue()
 {
     assertEquals(TRADE_PRICER.presentValue(TRADE, PROVIDER), PRODUCT_PRICER.presentValue(PRODUCT, PROVIDER));
 }
Example #5
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Calculates the present value of the trade.
 /// <para>
 /// The present value of the trade is the value on the valuation date.
 /// The present value is returned in the settlement currency.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="provider">  the rates provider </param>
 /// <returns> the present value of the trade in the settlement currency </returns>
 public virtual MultiCurrencyAmount presentValue(ResolvedFxSingleTrade trade, RatesProvider provider)
 {
     return(productPricer.presentValue(trade.Product, provider));
 }