Simulating future stock prices using Monte Carlo methods

Question

Using Monte Carlo methods, simulate future stock price outcomes for Apple ($AAPL) using Python. You can read more about Monte Carlo simulation (in a finance context) here.

Below is code using Python to grab the initial stock price data for Apple, to help get you started:

# Import required libraries
import math
import matplotlib.pyplot as plt
import numpy as np
from pandas_datareader import data
apple = data.DataReader('AAPL', 'yahoo',start='1/1/2009')
apple.head()
High Low Open Close Volume Adj Close
Date
2009-01-02 13.005714 12.165714 12.268572 12.964286 186503800.0 11.357091
2009-01-05 13.740000 13.244286 13.310000 13.511429 295402100.0 11.836406
2009-01-06 13.881429 13.198571 13.707143 13.288571 322327600.0 11.641174
2009-01-07 13.214286 12.894286 13.115714 13.001429 188262200.0 11.389630
2009-01-08 13.307143 12.862857 12.918571 13.242857 168375200.0 11.601127

Solution

Access restricted

Subscribe to premium account to see the solution.

Get premium now