Bootstrap Sampling for Stock Simulations in Python

in previous posts, I have discussed Monte Carlo simulations specifically in regards to generating future stock prices. We will now examine a bootstrap sampling technique in regards to simulating stock prices.


Bootstrapping is a type of resampling method. Assume one given time series containing historical stock prices. With this model, we have calculated periodic returns which will eventually be randomly indexed to in order to generate future simulated prices. Here’s the methodology of the model. First, we need to gather the data, extract daily returns, and then index the returns.  We can now randomly index the returns or shuffle the returns which will determine our future price patterns for each asset. We will take the last price of the stock(s) and compound them by the return(s) on the respective day. The previous price will be used for the next day’s calculation compounded by the next return on a random day via shuffling the rows in the data frame. In Excel, we would have to select a random number which would index the returns for the day, a more prolonged process. This is yet another reason to use Python!

Implementing the Model:

I decided to create a class for this model. The first thing we need to do is create the class with some initial variables. Then we need to get our data. Of course, we must also import the necessary dependencies as well.

Next, we can conduct our simulation.

We can quickly analyze the trials as well. Refer to my post on Monte Carlo simulations within Python to get an idea of what you can do.

Finally, we can run our script.

About the author


Hi, I'm Frank. I have a passion for coding and extend it primarily within the realm of Finance.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *