Пример #1
0
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the present value of the Ibor future trade from the current price.
        /// <para>
        /// The present value of the product is the value on the valuation date.
        /// </para>
        /// <para>
        /// The calculation is performed against a reference price. The reference price
        /// must be the last settlement price used for margining, except on the trade date,
        /// when it must be the trade price.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="currentPrice">  the current price, in decimal form </param>
        /// <param name="referencePrice">  the reference price to margin against, typically the last settlement price, in decimal form </param>
        /// <returns> the present value </returns>
        internal virtual CurrencyAmount presentValue(ResolvedIborFutureTrade trade, double currentPrice, double referencePrice)
        {
            ResolvedIborFuture future         = trade.Product;
            double             priceIndex     = productPricer.marginIndex(future, currentPrice);
            double             referenceIndex = productPricer.marginIndex(future, referencePrice);
            double             pv             = (priceIndex - referenceIndex) * trade.Quantity;

            return(CurrencyAmount.of(future.Currency, pv));
        }
Пример #2
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);
        }
Пример #3
0
        //-------------------------------------------------------------------------
        public virtual void test_marginIndex()
        {
            double notional            = FUTURE.Notional;
            double accrualFactor       = FUTURE.AccrualFactor;
            double price               = 0.99;
            double marginIndexExpected = price * notional * accrualFactor;
            double marginIndexComputed = PRICER.marginIndex(FUTURE, price);

            assertEquals(marginIndexComputed, marginIndexExpected);
        }