public static double blackFormulaImpliedStdDevApproximation(final Option.Type optionType,@Real double strike,@Real double forward,@Real final double blackPrice,@DiscountFactor final double discount,@Real final double displacement){
  QL.require(strike >= 0.0,"strike must be non-negative");
  QL.require(forward > 0.0,"forward must be positive");
  QL.require(displacement >= 0.0,"displacement must be non-negative");
  QL.require(blackPrice >= 0.0,"blackPrice must be non-negative");
  QL.require(discount > 0.0,"discount must be positive");
  double stddev;
  forward=forward + displacement;
  strike=strike + displacement;
  if (Closeness.isClose(strike,forward))   stddev=blackPrice / discount * Math.sqrt(2.0 * Math.PI) / forward;
 else {
    final double moneynessDelta=optionType.toInteger() * (forward - strike);
    final double moneynessDelta_2=moneynessDelta / 2.0;
    double temp=blackPrice / discount - moneynessDelta_2;
    final double moneynessDelta_PI=moneynessDelta * moneynessDelta / Math.PI;
    double temp2=temp * temp - moneynessDelta_PI;
    if (temp2 < 0.0)     temp2=0.0;
    temp2=Math.sqrt(temp2);
    temp+=temp2;
    temp*=Math.sqrt(2.0 * Math.PI);
    stddev=temp / (forward + strike);
  }
  if (stddev >= 0.0)   return stddev;
  throw new ArithmeticException("a negative value was calculated");
}

public static double blackFormulaImpliedStdDevApproximation ( final Option . Type optionType , @ Real double strike , @ Real double forward , @ Real final double blackPrice , @ DiscountFactor final double discount , @ Real final double displacement ) { QL . require ( strike >= 0.0 , "strike must be non-negative" ) ; QL . require ( forward > 0.0 , "forward must be positive" ) ; QL . require ( displacement >= 0.0 , "displacement must be non-negative" ) ; QL . require ( blackPrice >= 0.0 , "blackPrice must be non-negative" ) ; QL . require ( discount > 0.0 , "discount must be positive" ) ; double stddev ; forward = forward + displacement ; strike = strike + displacement ; if ( Closeness . isClose ( strike , forward ) ) stddev = blackPrice / discount * Math . sqrt ( 2.0 * Math . PI ) / forward ; else { final double moneynessDelta = optionType . toInteger ( ) * ( forward - strike ) ; final double moneynessDelta_2 = moneynessDelta / 2.0 ; double temp = blackPrice / discount - moneynessDelta_2 ; final double moneynessDelta_PI = moneynessDelta * moneynessDelta / Math . PI ; double temp2 = temp * temp - moneynessDelta_PI ; if ( temp2 < 0.0 ) temp2 = 0.0 ; temp2 = Math . sqrt ( temp2 ) ; temp += temp2 ; temp *= Math . sqrt ( 2.0 * Math . PI ) ; stddev = temp / ( forward + strike ) ; } if ( stddev >= 0.0 ) return stddev ; throw new ArithmeticException ( "a negative value was calculated" ) ; }
approximated black 1976 implied standard deviation , i . e . volatility * sqrt ( timetomaturity ) . < p > it is calculated using brenner and subrahmanyan ( 1988 ) and feinstein ( 1988 ) approximation for at - the - money forward option , with the extended moneyness approximation by corrado and miller ( 1996 )
