public static double bachelierBlackFormula(final Option.Type optionType,@Real final double strike,@Real final double forward,@StdDev final double stddev,final @DiscountFactor double discount){
  QL.require(stddev >= 0.0,"blackPrice must be non-negative");
  QL.require(discount > 0.0,"discount must be positive");
  final double d=(forward - strike) * optionType.ordinal(), h=d / stddev;
  if (stddev == 0.0)   return discount * Math.max(d,0.0);
  final CumulativeNormalDistribution phi=new CumulativeNormalDistribution();
  @NonNegative final double result=discount * stddev * phi.derivative(h) + d * phi.op(h);
  if (result >= 0.0)   return result;
  throw new ArithmeticException("negative value");
}

public static double bachelierBlackFormula ( final Option . Type optionType , @ Real final double strike , @ Real final double forward , @ StdDev final double stddev , final @ DiscountFactor double discount ) { QL . require ( stddev >= 0.0 , "blackPrice must be non-negative" ) ; QL . require ( discount > 0.0 , "discount must be positive" ) ; final double d = ( forward - strike ) * optionType . ordinal ( ) , h = d / stddev ; if ( stddev == 0.0 ) return discount * Math . max ( d , 0.0 ) ; final CumulativeNormalDistribution phi = new CumulativeNormalDistribution ( ) ; @ NonNegative final double result = discount * stddev * phi . derivative ( h ) + d * phi . op ( h ) ; if ( result >= 0.0 ) return result ; throw new ArithmeticException ( "negative value" ) ; }
black style formula when forward is normal rather than log - normal . this is essentially the model of bachelier .
