@Override public Double evaluate(final Double x) { double[] bond = new double[_nbBonds]; for (int loopb = 0; loopb < _nbBonds; loopb++) { for (int loopcf = 0; loopcf < _discountedCashFlow[loopb].length; loopcf++) { bond[loopb] += _discountedCashFlow[loopb][loopcf] * Math.exp(-(x + _alpha[loopb][loopcf]) * (x + _alpha[loopb][loopcf]) / 2.0); } } return MIN_FUNCTION.evaluate(bond); }
/** * 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; }