The purpose of a Monte Carlo simulation is to observe a range of potential outcomes based on a numerical simulation. For instance, if an investor chooses to hold an asset with a given level of return and volatility, then the same can be modelled to examine a range of potential gains and losses over a specified period.
The below program calculates a price path of a stock using a random walk for a given level of return (mu) and volatility (vol). Moreover, our histogram plots allow us to observe a range of potential returns throughout the period as well as frequency of those returns.
Monte Carlo Simulation and Random Walk Generation
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import norm
T = 250 #Number of trading days (we also run at 1000 for the purposes of comparison).
mu = 0.09 #Return
vol = 0.1 #Volatility
price_list = 
for x in daily_returns:
#plt.hist(daily_returns-1, 100) #Note that we run the line plot and histogram separately, not simultaneously.
OBSERVATIONS AND GRAPHS
We see that when we run the simulation across 1000 trading days as opposed to 250, the distribution of returns comes to represent one where we do not positive or negative skew since the extremities of returns are identical at +/-0.1. In this regard, the higher our number of observations (trading days), the more our histogram comes to represent a normal distribution. Whereas, the lower the number of trading days, we see that we have negative skew in that the lowest return was -0.02 whereas the highest return was 0.015.
10% VOLATILITY OVER 250 TRADING DAYS
10% VOLATILITY OVER 1000 TRADING DAYS
RANDOM WALK AT 10% VOLATILITY
RANDOM WALK AT 30% VOLATILITY