Created
August 13, 2022 20:37
-
-
Save firobeid/c42cc161f58da215774c4f28b5e8db36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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