Skip to content

Instantly share code, notes, and snippets.

@firobeid
Created August 13, 2022 20:37
Show Gist options
  • Select an option

  • Save firobeid/c42cc161f58da215774c4f28b5e8db36 to your computer and use it in GitHub Desktop.

Select an option

Save firobeid/c42cc161f58da215774c4f28b5e8db36 to your computer and use it in GitHub Desktop.
def option_pricer(n, So, k, r, sigma, t):
import numpy as np
N = n
St = So * np.exp((r - 0.5*sigma**2)*t + sigma*np.sqrt(t)*np.random.normal(size = N))
print(np.exp((r - 0.5*sigma**2)*t + sigma*np.sqrt(t)))
print(St)
pv_call = np.exp(-r*t) * np.maximum(St - k,0)
print(np.exp(-r*t))
print(pv_call)
c = np.mean(pv_call)
return c, np.mean(St)
option_pricer(1000000, 15, 11, 0.0145, 0.25, 1 / 12)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment