案例Finance 之python FINA 6421: 上机 Examinat
当前位置:以往案例 > >案例Finance 之python FINA 6421: 上机 Examinat
2017-12-23


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!


1) 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’.

a. Write out your pseudo code that your team used.

b. 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.  len

c. 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.

2) Using your DataFrame of common-stock-only daily total returns, compute the following for each asset (build one table for all together preferably):

a. Mean return

b. Median return

c. Standard deviation of the returns

d. Maximum

e. 95th percentile returns (note:  try numpy.percentile)

f. 5th percentile return

3) 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

a. Plot the daily price level prccd

b. Plot the daily dividend reinvestment factor trfd

c. Plot the daily share adjustment factor ajexdi

d. 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?


在线提交订单