Monte Carlo Options Pricing in Two Lines of Python
This is an old video that I produced sitting on my bed in the morning in order to learn how to make basic Youtube videos. Nevertheless, I became quite popular. I apologise for looking a bit rough. Hope you enjoy it regardless.
Here is the code:
from numpy import cumprod, random, sqrt, mean k = cumprod(1+random.randn(10000,252)*0.2/sqrt(252),1)*100 mean((k[:,-1]-100)*((k[:,-1]-100)>0))
If that seems a bit complex, check out the video for an explanation how the code works.