Submit your assignment in a single Python (.py) file on Avenue2Learn. Please name
the file FirstName_LastName.py. Answer each question in a cell (use #%% to define a
cell). Use # to add extra notes to your code. Make sure that all cells can be executed
without any error. All functions that you need are listed in the
TeachingNote_Python.pdf file but you are allowed to use other functions that do the
task.
1. Download and import stock price data for Amazon.com, Inc. (AMZN), and American Airlines
Group Inc. (AAL) from Yahoo Finance Website from Jan 2016 to Nov 2021 at the daily frequency.
You may either
– Use the Pandas_DataReader library and download data directly from Python.
– Or download prices from Yahoo Finance Historical tab, export them in CSV files and then
import the CSV file to a Pandas dataFrame. [this could be a solution for students in
China who do not get easy access to Yahoo Finance]
2. In a time‐series dataFrame, find the daily returns for each stock from the adj close price data of
each stock. Drop
3. Find the variance of the daily returns for each company.
4. Compute the simple moving average volatility (SMA) with a 45‐day window. Plot them on the
same graph. Notice how COVID‐19 shock affected the two companies differently.
5. Similarly, compute and plot exponentially weighted average volatility (EWMA),
For this step, on the returns’ dataFrame, create two new columns called EMWA_variance_AMZN and
EMWA_variance_AAL. Then use a for loop
(for time 𝑡) that iterates from day 2 to the end of the sample. In each iteration, calculate the variance for
each day based on the previous day’s variance and returns following the above equation.