Session Ready
Exercise

Get the Drift

In the last exercise, you simulated stock prices that follow a random walk. You will extend this in two ways in this exercise.

  • You will look at a random walk with a drift. Many time series, like stock prices, are random walks but tend to drift up over time.
  • In the last exercise, the noise in the random walk was additive: random, normal changes in price were added to the last price. However, when adding noise, you could theoretically get negative prices. Now you will make the noise multiplicative: you will add one to the random, normal changes to get a total return, and multiply that by the last price.
Instructions
100 XP
  • Generate 500 random normal multiplicative "steps" with mean 0.1% and standard deviation 1% using np.random.normal(), which are now returns, and add one for total return.
  • Simulate stock prices P:
    • Cumulate the product of the steps using the numpy .cumprod() method.
    • Multiply the cumulative product of total returns by 100 to get a starting value of 100.
  • Plot the simulated random walk with drift.