BondFutureDiscountingMethod extends BondFutureMethod { 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; } private  BondFutureDiscountingMethod(); static BondFutureDiscountingMethod getInstance(); double price(final BondFuture future, final IssuerProviderInterface issuerMulticurves); double priceFromNetBasis(final BondFuture future, final IssuerProviderInterface issuerMulticurves, final double netBasis); MultipleCurrencyAmount presentValue(final BondFuture future, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyAmount presentValueFromNetBasis(final BondFuture future, final IssuerProviderInterface issuerMulticurves, final double netBasis); MulticurveSensitivity priceCurveSensitivity(final BondFuture future, final IssuerProviderInterface issuerMulticurves); MultipleCurrencyMulticurveSensitivity presentValueCurveSensitivity(final BondFuture future, final IssuerProviderInterface issuerMulticurves); double[] grossBasisFromPrices(final BondFuture future, final double[] cleanPrices, final double futurePrice); double[] grossBasisFromCurves(final BondFuture future, final IssuerProviderInterface issuerMulticurves, final double futurePrice); double[] netBasisAllBonds(final BondFuture future, final IssuerProviderInterface issuerMulticurves, final double futurePrice); double netBasisCheapest(final BondFuture future, final IssuerProviderInterface issuerMulticurves, final double futurePrice);  }
@Test public void cheapestToDeliver() { final double yieldTest = 0.01345; final double priceTest = 1.03414063; final double mdTest = 4.271; final double grossBasisTest = 20.718; final double futurePriceTest = 1.19984375; final double[] priceCTD = new double[NB_BOND]; final double[] mdCTD = new double[NB_BOND]; final double[] yieldCTD = new double[NB_BOND]; for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) { priceCTD[loopbasket] = priceTest; mdCTD[loopbasket] = METHOD_BOND.modifiedDurationFromYield(STANDARD[loopbasket], yieldTest); yieldCTD[loopbasket] = METHOD_BOND.yieldFromCleanPrice(STANDARD[loopbasket], priceTest); } final double[] grossBasis = METHOD_FUT_DSC.grossBasisFromPrices(BOND_FUTURE, priceCTD, futurePriceTest); final int ctdIndex = 1; assertEquals("Bond future security: CTD - yield from price", yieldTest, yieldCTD[ctdIndex], 1.0E-4); assertEquals("Bond future security: CTD - modified duration from yield", mdTest, mdCTD[ctdIndex], 1.0E-3); assertEquals("Bond future security: CTD - gross basis from price", grossBasisTest / 100.0 / 32.0, grossBasis[ctdIndex], 1.0E-7); }
@Test public void grossBasis() { final double futurePriceTest = 1.19984375; final double[] pricesTest = new double[] {0.86, 0.885, 0.88, 0.8825, 0.885, 0.8725, 0.86}; final double[] pricesCurves = new double[NB_BOND]; for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) { pricesCurves[loopbasket] = METHOD_BOND.cleanPriceFromCurves(BOND_FUTURE.getDeliveryBasket()[loopbasket], ISSUER_MULTICURVES); } final double[] basisComputedTest = METHOD_FUT_DSC.grossBasisFromPrices(BOND_FUTURE, pricesTest, futurePriceTest); final double[] basisComputedCurves = METHOD_FUT_DSC.grossBasisFromPrices(BOND_FUTURE, pricesCurves, futurePriceTest); final double[] basisExpectedTest = new double[NB_BOND]; final double[] basisExpectedCurves = new double[NB_BOND]; for (int loopbasket = 0; loopbasket < NB_BOND; loopbasket++) { basisExpectedTest[loopbasket] = (pricesTest[loopbasket] - futurePriceTest * CONVERSION_FACTOR[loopbasket]); basisExpectedCurves[loopbasket] = (pricesCurves[loopbasket] - futurePriceTest * CONVERSION_FACTOR[loopbasket]); assertEquals("Gross basis from prices", basisExpectedTest[loopbasket], basisComputedTest[loopbasket], 1.0E-10); assertEquals("Gross basis from curves", basisExpectedCurves[loopbasket], basisComputedCurves[loopbasket], 1.0E-10); } }