Session Ready
Exercise

Calculate and plot SMAs

Daily price data is inherently messy and noisy. You want to analyze the Apple stock daily price data, and plan to add a simple moving average (SMA) indicator to smooth out the data. Specifically, you decide to use the 50-day SMA.

The stock data has been preloaded in aapl_data, and matplotlib.pyplot has been imported as plt. Additional customizations to the plot such as a title and legend have already been provided for you.

Instructions
100 XP
  • Calculate the 50-day SMA using the Close price, and save it in a new column named sma_50.
  • Plot a line chart using the data in the columns sma_50 and Close.