示例#1
0
        //-------------------------------------------------------------------------
        public virtual void test_presentValue()
        {
            double         currentPrice         = 0.995;
            double         referencePrice       = 0.9925;
            double         currentPriceIndex    = PRICER_PRODUCT.marginIndex(FUTURE_TRADE.Product, currentPrice);
            double         referencePriceIndex  = PRICER_PRODUCT.marginIndex(FUTURE_TRADE.Product, referencePrice);
            double         presentValueExpected = (currentPriceIndex - referencePriceIndex) * FUTURE_TRADE.Quantity;
            CurrencyAmount presentValueComputed = PRICER_TRADE.presentValue(FUTURE_TRADE, currentPrice, referencePrice);

            assertEquals(presentValueComputed.Amount, presentValueExpected, TOLERANCE_PV);
        }
示例#2
0
        public virtual void test_presentValue_on_trade_date()
        {
            IborIndexRates      mockIbor = mock(typeof(IborIndexRates));
            SimpleRatesProvider prov     = new SimpleRatesProvider();

            prov.IborRates     = mockIbor;
            prov.ValuationDate = FUTURE_TRADE.TradedPrice.get().TradeDate;
            when(mockIbor.rate(FUTURE.IborRate.Observation)).thenReturn(RATE);

            double lastClosingPrice = 1.025;
            DiscountingIborFutureTradePricer pricerFn = DiscountingIborFutureTradePricer.DEFAULT;
            double         expected = ((1.0 - RATE) - FUTURE_TRADE.TradedPrice.get().Price) * FUTURE.AccrualFactor * FUTURE.Notional * FUTURE_TRADE.Quantity;
            CurrencyAmount computed = pricerFn.presentValue(FUTURE_TRADE, prov, lastClosingPrice);

            assertEquals(computed.Amount, expected, TOLERANCE_PV);
            assertEquals(computed.Currency, FUTURE.Currency);
        }