Closed eatonlin98 closed 1 year ago
Please, create issues only if there are errors, or if something is wrong in the math or in the code.
An issue should be short, easy to read, and should indicate the error message.
In this case there are no errors. The Heston price seems to be correct.
The answers to your questions are:
partial
to bind the extra arguments. Therefore the function cf_H_b_good
has only 1 argument.k
is the first argument of Q1
.
def cf_Heston(u, t, v0, mu, kappa, theta, sigma, rho): """ Heston characteristic function as proposed in the original paper of Heston (1993) """ xi = kappa - sigma rho u 1j d = np.sqrt(xi2 + sigma2 (u*2 + 1j u)) g1 = (xi + d) / (xi - d) cf = np.exp( 1j u mu * t
limit_max = 1000 # right limit in the integration call = S0 Q1(k, cf_H_b_good, limit_max) - K np.exp(-r T) Q2(k, cf_H_b_good, limit_max) print("Heston Fourier inversion call price: ", call)
when call 'call' function, I need to use Q1 and Q2. but in Q1, cf function only has one input like 'u - 1j'. But here it should be cf_Heston function with 7 inputs. Not sure how did you run out with just one input?
Also the cf formula in cf_Heston, wouldn't it be:
1j u mu t => 1j u * log(K), K is strike price.
def Q1(k, cf, right_lim): """ P(X<k) - Probability to be in the money under the stock numeraire. cf: characteristic function right_lim: right limit of integration """