BondFuturesSecurityDiscountingMethod extends FuturesSecurityIssuerMethod { public double[] netBasisAllBonds(final BondFuturesSecurity futures, final IssuerProviderInterface issuerMulticurves, final double futurePrice) { ArgumentChecker.notNull(futures, "Future"); ArgumentChecker.notNull(issuerMulticurves, "Issuer and multi-curves provider"); final int nbBasket = futures.getDeliveryBasketAtDeliveryDate().length; final double[] netBasis = new double[nbBasket]; for (int loopbasket = 0; loopbasket < futures.getDeliveryBasketAtDeliveryDate().length; loopbasket++) { final double cleanPrice = BOND_METHOD.cleanPriceFromCurves(futures.getDeliveryBasketAtDeliveryDate()[loopbasket], issuerMulticurves); netBasis[loopbasket] = cleanPrice - futurePrice * futures.getConversionFactor()[loopbasket]; } return netBasis; } private  BondFuturesSecurityDiscountingMethod(); static BondFuturesSecurityDiscountingMethod getInstance(); double priceFromNetBasis(final BondFuturesSecurity futures, final IssuerProviderInterface issuerMulticurves, final double netBasis); double[] grossBasisFromPrices(final BondFuturesSecurity futures, final double[] cleanPrices, final double futurePrice); double[] grossBasisFromCurves(final BondFuturesSecurity futures, final IssuerProviderInterface issuerMulticurves, final double futurePrice); double[] netBasisAllBonds(final BondFuturesSecurity futures, final IssuerProviderInterface issuerMulticurves, final double futurePrice); double netBasisCheapest(final BondFuturesSecurity futures, final IssuerProviderInterface issuerMulticurves, final double futurePrice);  }
@Test public void netBasisAllBonds() { final double priceFuture = METHOD_FUT_SEC_DSC.price(BOND_FUTURE, ISSUER_MULTICURVES); final double[] netBasisComputed = METHOD_FUT_SEC_DSC.netBasisAllBonds(BOND_FUTURE, ISSUER_MULTICURVES, priceFuture); final double[] netBasisExpected = new double[NB_BOND]; for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) { final double bondDirtyPriceForward = METHOD_BOND_SEC.dirtyPriceFromCurves(BOND_FUTURE.getDeliveryBasketAtDeliveryDate()[loopbasket], ISSUER_MULTICURVES); netBasisExpected[loopbasket] = bondDirtyPriceForward - (priceFuture * CONVERSION_FACTOR[loopbasket] + BOND_FUTURE.getDeliveryBasketAtDeliveryDate()[loopbasket].getAccruedInterest()); assertEquals("Bond future security Discounting Method: netBasis", netBasisExpected[loopbasket], netBasisComputed[loopbasket], 1.0E-10); } final Min minFunction = new Min(); final double netBasisMin = minFunction.evaluate(netBasisComputed); final double priceFutureFromNetBasis = METHOD_FUT_SEC_DSC.priceFromNetBasis(BOND_FUTURE, ISSUER_MULTICURVES, netBasisMin); assertEquals("Bond future security Discounting Method: netBasis", priceFuture, priceFutureFromNetBasis, 1.0E-10); }