3

I'm new to python, so the question might be easy, anyway, thanks for your patience:

As I was trying to call the newton-raphson method to calculate the implied volatility in Black-Scholes formula for call/put option pricing, First thing is, the newton method in scipy.optimize seems to calculate the function's zeros, but in Black-Scholes formula, I want the function's value to be the option price, not zero. (I'm new here about programming, so I'm not sure about some techniques.) Should I write another function to do the things like:

def f(sigma, price):
    return bsformula(S0,K,r,T,q,sigma) - price

then, while calling the newton method, it takes an args=() as one parameter in the function, I write like this:

value = newton(bsprice2, 0.5, args=price)

but get this error message:

File "BS.py", line 36, in bsimpvol
    value = newton(bsprice2, 0.5, args=float(price))
  File "/usr/lib/python2.7/dist-packages/scipy/optimize/zeros.py", line 143, in newton
    q0 = func(*((p0,) + args))
TypeError: can only concatenate tuple (not "float") to tuple

Could you tell me why is that? How to fix it? Much appreciated.

falsetru
  • 314,667
  • 49
  • 610
  • 551
StayFoolish
  • 285
  • 1
  • 9
  • 25

1 Answers1

-1

Newton-Raphson method is not a good one to calculate implied volatility, since the derivative ("vega") can be too small at certain points, which makes the method to hunt and never find a solution.

Use a bisection method, beginning with 0 and some volatility that is ridiculously high for your particular application/target market. You could use 1000%/year if you wish, it will only be a bit slower to find the solution if your typical volatility is 25%/year.

epx
  • 1,025
  • 9
  • 16