Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Calculate the Implied Volatility Using Newton Raphson Algorithm.For this question, please what is wrong with this code?:def newtonRap(cp, price, s, k, t, rf): v = sqrt(2*pi/t)*price/s print "ini

Calculate the Implied Volatility Using Newton Raphson Algorithm.

For this question, please what is wrong with this code?:

def newtonRap(cp, price, s, k, t, rf):    v = sqrt(2*pi/t)*price/s    print "initial volatility: ",v    for i in range(1, 100):        d1 = (log(s/k)+(rf+0.5*pow(v,2))*t)/(v*sqrt(t))        d2 = d1 - v*sqrt(t)        vega = s*norm.pdf(d1)*sqrt(t)        price0 = cp*s*norm.cdf(cp*d1) - cp*k*exp(-rf*t)*norm.cdf(cp*d2)        v = v - (price0 - price)/vega        print "price, vega, volatility\n",(price0, vega, v)        if abs(price0 - price) < 1e-25 :            break    return v

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question