python - TypeError: can only concatenate tuple (not "float") to tuple -
i'm new python, question might easy, anyway, patience:
as trying call newton-raphson method calculate implied volatility in black-scholes formula call/put option pricing, first thing is, newton method in scipy.optimize seems calculate function's zeros, in black-scholes formula, want function's value option price, not zero. (i'm new here programming, i'm not sure techniques.) should write function things like:
def f(sigma, price): return bsformula(s0,k,r,t,q,sigma) - price
then, while calling newton method, takes args=() 1 parameter in function, write this:
value = newton(bsprice2, 0.5, args=price)
but 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 concatenate tuple (not "float") tuple
could tell me why that? how fix it? appreciated.
newton-raphson method not 1 calculate implied volatility, since derivative ("vega") can small @ points, makes method hunt , never find solution.
use bisection method, beginning 0 , volatility ridiculously high particular application/target market. use 1000%/year if wish, bit slower find solution if typical volatility 25%/year.
Comments
Post a Comment