0
$\begingroup$

I am attempting to use AAD (Adjoint Algorithmic Differentiation) with a simple Black MC pricer, and found that the Gamma is incorrect. The output was compared to Black analytical Greeks, as well as Finite Difference Greeks, and there is a discrepancy. What confuses me is the Black analytical formula produces the correct Gamma with identical AutoGrad (or JAX) code. I don't know if anyone can spot my error or has more experience with 2nd order derivatives and AAD that can provide advice on how to fix the issue.

Here's the simple MC Black option pricer for a call option, along with the AutoGrad code to replicate the issue. MC_call_price is a simple MC, BS_call_price is the analytical one:

# use either jax or autograd functions, same format
import autograd.numpy as np # import jax.numpy as np
from autograd import grad # from jax import grad
from autograd.scipy.stats import norm # from jax.scipy.stats import norm

def MC_call_price(F, vol, K, T, IR, steps, trials):
    np.random.seed(123)
    dt = T/steps
    paths = np.log(F) +  np.cumsum(((IR - vol**2/2)*dt + vol*np.sqrt(dt) * \
                          np.random.normal(size=(int(steps),int(trials)))), axis=0)
    payoff = np.mean(np.maximum(np.exp(paths)[-1]-K, 0)) * np.exp(-IR*T)
    return payoff

def AAD_Greeks(F, vol, K, T, IR, steps, trials):
    # setup gradient functions to evaluate with AAD
    gradient_func = grad(MC_call_price, (0)) # tuple specifies inputs we want to differentiate
    gradient_func2 = grad(gradient_func) # second derivative
    # solve for Greeks
    delta = gradient_func(F, vol, K, T, IR, steps, trials)
    gamma = gradient_func2(F, vol, K, T, IR, steps, trials)
    return delta, gamma

def BS_call_price(F, vol, K, T, IR):
    b = np.exp(-IR*T).astype('float')
    x1 = np.log(F/(b*K))
    x1 += (.5*(vol**2)*T)
    x1 = x1/(vol*(T**.5))
    z1 = norm.cdf(x1)
    z1 = z1*F
    x2 = np.log(F/(b*K)) - .5*(vol**2)*T
    x2 = x2/(vol*(T**.5))
    z2 = norm.cdf(x2)
    z2 = b*K*z2
    return z1 - z2

def AAD_Greeks2(F, vol, K, T, IR):
    # setup gradient functions to evaluate with AAD
    gradient_func = grad(BS_call_price, (0)) # tuple specifies inputs we want to differentiate
    gradient_func2 = grad(gradient_func) # second derivative
    # solve for Greeks
    delta = gradient_func(F, vol, K, T, IR)
    gamma = gradient_func2(F, vol, K, T, IR)
    return delta, gamma

F = 100.0
vol = 0.30
K = 90
T = 0.5
IR = 0.03
steps = 1
trials = 1000000
bump = 0.005

optionprice = MC_call_price(F, vol, K, T, IR, steps, trials)
delta, gamma = AAD_Greeks(F, vol, K, T, IR, steps, trials)
print("\nOption price", optionprice,"\n", "\nAAD: Delta", delta, "Gamma", gamma)
up = MC_call_price(F+bump, vol, K, T, IR, steps, trials)
down = MC_call_price(F-bump, vol, K, T, IR, steps, trials)
FDdelta = (up-down)/(2*bump)
FDgamma = (up - 2*optionprice + down)/(bump**2)
print("FD: Delta", FDdelta, "Gamma", FDgamma)
BSoptionprice = BS_call_price(F, vol, K, T, IR, )
BSdelta, BSgamma = AAD_Greeks2(F, vol, K, T, IR)
print("\n\nBS Option price", BSoptionprice,"\n", "\nAAD: Delta", BSdelta, "Gamma", BSgamma)

And the output showing MC doesn't produce the correct Gamma, but the BS analytical formula does with AAD, which is close to the FD method:

Option price 14.892979946909723 
 
AAD: Delta 0.7497560731718061 Gamma 5.204170427930421e-18
FD: Delta 0.7497588343497341 Gamma 0.013656582353860358


BS Option price 14.880707205664976 
 
AAD: Delta 0.7496697714173796 Gamma 0.01499062307583833

Thanks for any observations or suggestions on how to fix Gamma! I've tried the same programming model for more advanced options (baskets) and the Gamma is always close to 0, so I imagine I am missing something.

$\endgroup$
1
  • $\begingroup$ Recent improvements in Greeks computation, such as Adjoint Algorithmic Differentiation, are unfortunately uneffective on second order Greeks (such as Gamma), which are plagued by the most significant instabilities, so that a viable alternative to standard finite differences is still lacking arxiv.org/pdf/2106.12431.pdf $\endgroup$
    – Matt
    Jul 23 at 21:23

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.