//-------------------------------------------------------------------------
        public virtual void test_dirtyPriceFromCurves()
        {
            double         computed   = PRICER.dirtyPriceFromCurves(PRODUCT, PROVIDER, REF_DATA);
            CurrencyAmount pv         = PRICER.presentValue(PRODUCT, PROVIDER);
            LocalDate      settlement = DATE_OFFSET.adjust(VAL_DATE, REF_DATA);
            double         df         = DSC_FACTORS_REPO.discountFactor(settlement);

            assertEquals(computed, pv.Amount / df / NOTIONAL);
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Calculates the price of the bond future product.
        /// <para>
        /// The price of the product is the price on the valuation date.
        /// </para>
        /// <para>
        /// Strata uses <i>decimal prices</i> for bond futures. This is coherent with the pricing of <seealso cref="FixedCouponBond"/>.
        /// For example, a price of 99.32% is represented in Strata by 0.9932.
        ///
        /// </para>
        /// </summary>
        /// <param name="future">  the future </param>
        /// <param name="discountingProvider">  the discounting provider </param>
        /// <returns> the price of the product, in decimal form </returns>
        public double price(ResolvedBondFuture future, LegalEntityDiscountingProvider discountingProvider)
        {
            ImmutableList <ResolvedFixedCouponBond> basket = future.DeliveryBasket;
            int size = basket.size();

            double[] priceBonds = new double[size];
            for (int i = 0; i < size; ++i)
            {
                ResolvedFixedCouponBond bond = basket.get(i);
                double dirtyPrice            = bondPricer.dirtyPriceFromCurves(bond, discountingProvider, future.LastDeliveryDate);
                priceBonds[i] = bondPricer.cleanPriceFromDirtyPrice(bond, future.LastDeliveryDate, dirtyPrice) / future.ConversionFactors.get(i);
            }
            return(Doubles.min(priceBonds));
        }
Exemple #3
0
        //-------------------------------------------------------------------------
        public virtual void test_price()
        {
            double computed   = FUTURE_PRICER.price(FUTURE_PRODUCT, PROVIDER);
            double dirtyPrice = BOND_PRICER.dirtyPriceFromCurves(BOND, PROVIDER, FUTURE_PRODUCT.LastDeliveryDate);
            double expected   = BOND_PRICER.cleanPriceFromDirtyPrice(BOND, FUTURE_PRODUCT.LastDeliveryDate, dirtyPrice) / CONVERSION_FACTOR[0];

            assertEquals(computed, expected, TOL);
        }