Esempio n. 1
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            SimpleRatesProvider prov = createProvider(NOTIONAL_EXCHANGE_REC_GBP);

            DiscountingNotionalExchangePricer test = DiscountingNotionalExchangePricer.DEFAULT;
            double calculated = test.presentValue(NOTIONAL_EXCHANGE_REC_GBP, prov);

            assertEquals(calculated, NOTIONAL_EXCHANGE_REC_GBP.PaymentAmount.Amount * DISCOUNT_FACTOR, 0d);
        }
Esempio n. 2
0
        private IList <ZeroRateSensitivity> dscSensitivityFD(RatesProvider provider, NotionalExchange @event, double eps)
        {
            Currency      currency       = @event.Currency;
            LocalDate     paymentDate    = @event.PaymentDate;
            double        discountFactor = provider.discountFactor(currency, paymentDate);
            double        paymentTime    = DAY_COUNT.relativeYearFraction(VAL_DATE, paymentDate);
            RatesProvider provUp         = mock(typeof(RatesProvider));
            RatesProvider provDw         = mock(typeof(RatesProvider));

            when(provUp.ValuationDate).thenReturn(VAL_DATE);
            when(provUp.discountFactor(currency, paymentDate)).thenReturn(discountFactor * Math.Exp(-eps * paymentTime));
            when(provDw.ValuationDate).thenReturn(VAL_DATE);
            when(provDw.discountFactor(currency, paymentDate)).thenReturn(discountFactor * Math.Exp(eps * paymentTime));
            DiscountingNotionalExchangePricer pricer = DiscountingNotionalExchangePricer.DEFAULT;
            double pvUp = pricer.presentValue(@event, provUp);
            double pvDw = pricer.presentValue(@event, provDw);
            double res  = 0.5 * (pvUp - pvDw) / eps;
            IList <ZeroRateSensitivity> zeroRateSensi = new List <ZeroRateSensitivity>();

            zeroRateSensi.Add(ZeroRateSensitivity.of(currency, paymentTime, res));
            return(zeroRateSensi);
        }
Esempio n. 3
0
        //-------------------------------------------------------------------------
        public virtual void test_currencyExposure()
        {
            ImmutableRatesProvider            prov = ImmutableRatesProvider.builder(VAL_DATE).discountCurve(GBP, DISCOUNT_CURVE_GBP).build();
            DiscountingNotionalExchangePricer test = DiscountingNotionalExchangePricer.DEFAULT;
            MultiCurrencyAmount computed           = test.currencyExposure(NOTIONAL_EXCHANGE_REC_GBP, prov);
            PointSensitivities  point    = test.presentValueSensitivity(NOTIONAL_EXCHANGE_REC_GBP, prov).build();
            MultiCurrencyAmount expected = prov.currencyExposure(point).plus(CurrencyAmount.of(NOTIONAL_EXCHANGE_REC_GBP.Currency, test.presentValue(NOTIONAL_EXCHANGE_REC_GBP, prov)));

            assertEquals(computed, expected);
        }