Why is d2 invalid?

1139 views python
3

Can someone please help me with this? Why is the line with d2 invalid syntax?

def put_value(S, K, sigma, T):

    d1 = ((np.log(S / K) + (T * 0.5 * sigma * sigma)) / (sigma * np.sqrt(T))
    d2 = d1 - (sigma * np.sqrt(T))
    put = (norm.cdf(d2, 0.0, 1.0) * K) - (norm.cdf(d1, 0.0, 1.0) * S)
    return put

answered question

1 Answer

8

You have an unclosed open parenthesis on the previous line. Either delete it or close it.

d1 = ((np.log(S / K) + (T * 0.5 * sigma * sigma)) / (sigma * np.sqrt(T))
   # ^ never closed

posted this

Have an answer?

JD

Please login first before posting an answer.