/**
  * Computes the gross basis of the bonds in the underlying basket from their clean prices.
  *
  * @param future The future security.
  * @param cleanPrices The clean prices (at standard bond market spot date) of the bond in the
  *     basket.
  * @param futurePrice The future price.
  * @return The gross basis for each bond in the basket.
  */
 public double[] grossBasisFromPrices(
     final BondFuture future, final double[] cleanPrices, final double futurePrice) {
   ArgumentChecker.notNull(future, "Future");
   final int nbBasket = future.getDeliveryBasket().length;
   ArgumentChecker.isTrue(cleanPrices.length == nbBasket, "Number of clean prices");
   final double[] grossBasis = new double[nbBasket];
   for (int loopbasket = 0; loopbasket < future.getDeliveryBasket().length; loopbasket++) {
     grossBasis[loopbasket] =
         cleanPrices[loopbasket] - futurePrice * future.getConversionFactor()[loopbasket];
   }
   return grossBasis;
 }
 /**
  * Computes the net basis of associated to the cheapest to deliver bonds in the underlying basket
  * from the curves and the future price.
  *
  * @param future The future security.
  * @param issuerMulticurves The issuer and multi-curves provider.
  * @param futurePrice The future price.
  * @return The net basis.
  */
 public double netBasisCheapest(
     final BondFuture future,
     final IssuerProviderInterface issuerMulticurves,
     final double futurePrice) {
   ArgumentChecker.notNull(future, "Future");
   ArgumentChecker.notNull(issuerMulticurves, "Issuer and multi-curves provider");
   final int nbBasket = future.getDeliveryBasket().length;
   final double[] netBasis = new double[nbBasket];
   for (int loopbasket = 0; loopbasket < future.getDeliveryBasket().length; loopbasket++) {
     netBasis[loopbasket] =
         BOND_METHOD.cleanPriceFromCurves(
                 future.getDeliveryBasket()[loopbasket], issuerMulticurves)
             - futurePrice * future.getConversionFactor()[loopbasket];
   }
   return MIN_FUNCTION.evaluate(netBasis);
 }
 /**
  * Computes the future price from the curves used to price the underlying bonds and the net basis.
  *
  * @param future The future security.
  * @param issuerMulticurves The issuer and multi-curves provider.
  * @param netBasis The net basis associated to the future.
  * @return The future price.
  */
 public double priceFromNetBasis(
     final BondFuture future,
     final IssuerProviderInterface issuerMulticurves,
     final double netBasis) {
   ArgumentChecker.notNull(future, "Future");
   ArgumentChecker.notNull(issuerMulticurves, "Issuer and multi-curves provider");
   final double[] priceFromBond = new double[future.getDeliveryBasket().length];
   for (int loopbasket = 0; loopbasket < future.getDeliveryBasket().length; loopbasket++) {
     priceFromBond[loopbasket] =
         (BOND_METHOD.cleanPriceFromCurves(
                     future.getDeliveryBasket()[loopbasket], issuerMulticurves)
                 - netBasis)
             / future.getConversionFactor()[loopbasket];
   }
   final double priceFuture = MIN_FUNCTION.evaluate(priceFromBond);
   return priceFuture;
 }
 /**
  * Computes the gross basis of the bonds in the underlying basket from the curves.
  *
  * @param future The future security.
  * @param issuerMulticurves The issuer and multi-curves provider.
  * @param futurePrice The future price.
  * @return The gross basis for each bond in the basket.
  */
 public double[] grossBasisFromCurves(
     final BondFuture future,
     final IssuerProviderInterface issuerMulticurves,
     final double futurePrice) {
   ArgumentChecker.notNull(future, "Future");
   ArgumentChecker.notNull(issuerMulticurves, "Issuer and multi-curves provider");
   final int nbBasket = future.getDeliveryBasket().length;
   final double[] grossBasis = new double[nbBasket];
   final double[] cleanPrices = new double[nbBasket];
   for (int loopbasket = 0; loopbasket < future.getDeliveryBasket().length; loopbasket++) {
     cleanPrices[loopbasket] =
         BOND_METHOD.cleanPriceFromCurves(
             future.getDeliveryBasket()[loopbasket], issuerMulticurves);
     grossBasis[loopbasket] =
         cleanPrices[loopbasket] - futurePrice * future.getConversionFactor()[loopbasket];
   }
   return grossBasis;
 }
 /**
  * Computes the future price curve sensitivity.
  *
  * @param future The future security.
  * @param issuerMulticurves The issuer and multi-curves provider.
  * @return The curve sensitivity.
  */
 public MulticurveSensitivity priceCurveSensitivity(
     final BondFuture future, final IssuerProviderInterface issuerMulticurves) {
   ArgumentChecker.notNull(future, "Future");
   ArgumentChecker.notNull(issuerMulticurves, "Issuer and multi-curves provider");
   final double[] priceFromBond = new double[future.getDeliveryBasket().length];
   int indexCTD = 0;
   double priceMin = 2.0;
   for (int loopbasket = 0; loopbasket < future.getDeliveryBasket().length; loopbasket++) {
     priceFromBond[loopbasket] =
         (BOND_METHOD.cleanPriceFromCurves(
                 future.getDeliveryBasket()[loopbasket], issuerMulticurves))
             / future.getConversionFactor()[loopbasket];
     if (priceFromBond[loopbasket] < priceMin) {
       priceMin = priceFromBond[loopbasket];
       indexCTD = loopbasket;
     }
   }
   MulticurveSensitivity result =
       BOND_METHOD.dirtyPriceCurveSensitivity(
           future.getDeliveryBasket()[indexCTD], issuerMulticurves);
   return result.multipliedBy(1.0 / future.getConversionFactor()[indexCTD]);
 }