QQMN534 question1 final template

# -*- coding: utf-8 -*-

# 5QQMN534 22-23
# Candidate Number:
# Do not enter Name

#%% QUESTION 1: Resampling Returns Data

#%% a) Read in the msft_returns.xlsx file provided in Q1_data folder into a DataFrame and name the variable returns

#%% b) Calculate the Simple Returns of the MSFT Adjusted CLose Data in a New Column called sim_ret

#%% c) Calculate the log returns of the MSFT Adjusted CLose Data in a New Column called _log_ret

#%% d) Calculate the cumulative returns from the daily log returns in a new column called cum_ret_log

#%% e) Calculate the cumulative returns from the daily simple returns in a new column called cum_ret_sim

#%% f) Check cum_ret_log total cumulative return and cum_ret_sim total cumulative returns are the same value.
# Round to four decimal places. Print out a confirmation to screen

#%% g) Calculate Monthly returns from daily log returns to six decimal places
# Print out the last five rows to screen.

#%% h) Calculate monthly returns from simple returns to six decimal places
# Print out the last five rows to screen.

#%% i) Save the Monthly and Simple Returns DataFrames to seperate excel files
# Note: Results in part g and h should be the same.

#%% j) Calculate the Monthly Total Cumulative Return from Simple Monthly Returns and check
# it is equal to the Total cumulative Daily Returns. Round to four decimal places.
# Print out this confirmation and print out the last five rows to screen.

#%% k) Save the Monthly Return Log, Monthly Ret Simple, Monthly Cumulative Return into a new DataFrame called monthly_rets

#%% l) PLot the monthly returns for year 2000 and year 2020 in a bar chart in seperate graphs

# Calculate descriptive statistics for each month on all years and save the results to a DataFrame.
# Note: Each year includes all monthly returns January to December.
# Years should be the index. Months should be the columns.
# Plot the mean, std in a bar graph and then plot the min and max in another bar graph.

#%% n) Calculate the annual yearly return and provide code for a double check that the cumulative yearly return = daily cumulative return.

#%% #%% o) Calculate the descriptive statistics on all months for each year.
# Note results should be different from part m.

#%% p) How many monthly returns outliers have there been that are greater or less than 20%?
# How many negative and how many positive outliers?
# What dates did these outliers occur on?
# Print results to screen.