Heston Model Delta And Gamma
def calculate_greeks(S0, K, T, r, v0, kappa, theta, sigma, rho, M_in_year, Ite, delta_S=0.1, gamma_S=0.001): np.random.seed(SEED) # Original prices call_price, put_price = heston_model_mc(S0, K, T, r, v0, kappa, theta, sigma, rho, M_in_year, Ite) # Prices with S0 + delta_S call_price_up, put_price_up = heston_model_mc(S0 + delta_S, K, T, r, v0, kappa, theta, sigma, rho, M_in_year, Ite) # Prices with S0 + gamma_S call_price_gamma_up, put_price_gamma_up = heston_model_mc(S0 + gamma_S, K, T, r, v0, kappa, theta, sigma, rho, M_in_year, Ite) # Prices with S0 - gamma_S call_price_gamma_down, put_price_gamma_down = heston_model_mc(S0 - gamma_S, K, T, r, v0, kappa, theta, sigma, rho, M_in_year, Ite) # Calculate delta delta_call = (call_price_up - call_price) / delta_S delta_put = (put_price_up - put_price) / delta_S # Calculate gamma gamma_call = (call_price_gamma_up - 2 * call_price + call_price_gamma_down) / (gamma_S ** 2) gamma_put = (put_price_gamma_up - 2 * put_price + put_price_gamma_down) / (gamma_S ** 2) return round(delta_call, 2), round(delta_put, 2), round(gamma_call, 2), round(gamma_put, 2) # Correlation -0.30 rho = -0.30 delta_call_1, delta_put_1, gamma_call_1, gamma_put_1 = calculate_greeks(S0, K, T, r, v0, kappa, theta, sigma, rho, M_in_year, Ite) # Correlation -0.70 rho = -0.70 delta_call_2, delta_put_2, gamma_call_2, gamma_put_2 = calculate_greeks(S0, K, T, r, v0, kappa, theta, sigma, rho, M_in_year, Ite) results_9 = pd.DataFrame({"Q #": [5] * 4 + [6] * 4}) results_9["Greek"] = (["Delta"] * 2 + ["Gamma"] * 2) * 2 results_9["Type"] = ["ATM Call", "ATM Put"] * 4 results_9["Value"] = [delta_call_1, delta_put_1, gamma_call_1, gamma_put_1] + \ [delta_call_2, delta_put_2, gamma_call_2, gamma_put_2] results_9 results_9 Please, are the formulas for delta and gamma for this code correct. I saw something about finite differences in a book. Can you help me correct or change the code if it's wrong.