FINA 6421: Homework 1
Please submit one homework answer set for your group, along with individual print-outs of your code for each member of the team. Groups are expected to work together, but all individuals are expected to maintain their own unique code base (code printouts must be different for each person in the team). The best way to learn the material is to think about how you want to structure your code together as a team, and then actually implement it yourself!
- Build a function called getTotalReturns() that takes as an input the raw DataFrame of daily data from Compustat provided on the website, and generates daily total returns for common stock only. Note: ‘prccd’, ‘trfd’, and ‘ajexdi’ are the names of the daily columns that correspond to the monthly columns of ‘prccm’, ‘trfm’, and ‘ajexm’.
- Write out your pseudo code that your team used.
- Add to your function a code block that prints the number of valid days in the daily data for each asset, and prints to the screen a warning if one of the assets has a different number of days than the rest. Screenshot your output as part of your answer. Do they all have the same number of days? If any are different than the rest, provide the individual day(s) that differ from the rest.
- Add a keyword input to the function that allows you to either include preferred stock or omit it from your output. Demonstrate that this works for your function by running it both ways (common stock only or common and preferred together) and printing the output columns.
- Using your DataFrame of common-stock-only daily total returns, compute the following for each asset (build one table for all together preferably):
- Mean return
- Median return
- Standard deviation of the returns
- Maximum
- 95th percentile returns (note: try numpy.percentile)
- 5th percentile return
- Using the raw data, plot timeseries of the following for IBM. All plots must have date on the x-axis! Label all axes, and be sure that all plots have an appropriate title
- Plot the daily price level prccd
- Plot the daily dividend reinvestment factor trfd
- Plot the daily share adjustment factor ajexdi
- What happens to the price of IBM when the share adjustment ajexdi goes from a value of 2 to a value of 1? What happened to make that adjustment necessary?