//-------------------------------------------------------------------------
        /// <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));
        }
        /// <param name="function"> The function, not null </param>
        /// <param name="x0"> The starting point, not null </param>
        protected internal virtual void checkInputs(System.Func <DoubleArray, DoubleArray> function, DoubleArray x0)
        {
            ArgChecker.notNull(function, "function");
            ArgChecker.notNull(x0, "x0");
            int n = x0.size();

            for (int i = 0; i < n; i++)
            {
                if (!Doubles.isFinite(x0.get(i)))
                {
                    throw new System.ArgumentException("Invalid start position x0 = " + x0.ToString());
                }
            }
            DoubleArray y = function(x0);
            int         m = y.size();

            for (int i = 0; i < m; i++)
            {
                if (!Doubles.isFinite(y.get(i)))
                {
                    throw new System.ArgumentException("Invalid start position f(x0) = " + y.ToString());
                }
            }
        }