PurposeTo perform MonteCarlo simulations and use it to calculate expected price at a given future date. What are MonteCarlo Simulations?MonteCarlo simulations are basically simulations of probability. As per investopedia: "Monte Carlo simulations are used to model the probability of different outcomes in a process that cannot easily be predicted due to the intervention of random variables. " Basically, given a set of parameters and some random variables, we perform thousands of simulations and then seek expected outcome. Gaussian Process and Brownian MotionIn our case, we will make use of Gaussian Process that provides us with the random variable and then use it along with Asset Volatility, Riskfree rate, and time duration to calculate the expected price at a given future date. This continuoustime stochastic process represents the Brownian motion (aka the Wiener Process). Primary use of this Gaussian based MonteCarlo simulations is to generate asset prices is used to calculate American Option prices, which we will go over in another blog. Below is the Python library to generate value from Gaussian distribution. Gaussian random variable in Python
Fetch underlying dataIn order to successfully apply MonteCarlo simulations on this Gaussian process, we need to get below data:
Panda library has a useful function to download these prices from Morningstar, Quandl, Yahoo, etc. Downloads from Yahoo are having some issue recently; hence, in our case we will use combination of Quandl and Morningstar. Download Asset Prices
Download Treasury rate
Volatility CalculationNow that we have historical asset prices, we will go ahead and calculate the asset volatility. We do this by first calculating the Log returns for each day. Once, we have log returns for each day, we calculate the standard deviation using the ever helpful Pandas' std function. Note, this will provide us with daily standard deviation; hence, we need to annualize it by multiplying it with 252 (i.e. expected number of trading days in an year). Once we have annualized standard deviation, we take square root of it to calculate annualized volatility. Below code reflects how easy it is in Pandas: Calculate annualized volatility from daily asset prices
Apply Gaussian Process and perform SimulationsWe now have all the required inputs and are ready to apply Gaussian Process to calculate expected asset price using MonteCarlo simulations. For each simulation, we calculate expected price using below equation: ST = St * exp( (Rf− 0.5*σ^2)(T−t) + σϵ√(T−t) ) where, ST = Expected asset price at time St = Current asset price at time t (aka Spot price) Rf = Risk free rate or 3month treasury rate σ = Annualized Volatility (T−t) = Time to maturity in years ϵ = Random variable based on Gaussian Distribution Once, we get expected stock price using above equation, we repeat this calculation for N number of simulations. The only variable changing in each simulation is the Gaussian process; thereby, we representing a continuous time stochastic process, i.e. Wiener process. Below Python code performs these MonteCarlo simulations: MonteCarlo simulations and Wiener Process
Running Simulations on Tesla Stock (TSLA) for a future date
SourceCode
Your comment will be posted after it is approved.
Leave a Reply. 
AuthorI am a passionate, driven polyglot programmer and architect with a knack of solving complex problems in quick and efficient way. Along with programming, software development, financial products, and management expertise, I also bring skills in statistical modeling, empowering me to work on challenging projects that require combination of software development and quantitative analysis. Categories
All
