For this question you will use the following files: · “portfolios.csv” with historical returns on the 99 stock portfolios, risk-free rate and return on the market portfolio [WE WILL REFER TO THE 99...


For this question you will use the following files:


· “portfolios.csv” with historical returns on the 99 stock portfolios, risk-free rate and return on the market portfolio [WE WILL REFER TO THE 99 STOCK PORTFOLIOS AS 99 ASSETS]


· “bookToMarket.csv” with the book-to-market ratios of the 99 assets


· “marketEquity.csv” with the total market equity (market cap) of the 99 assets



Preliminary coding steps:


- Import numpy, pandas, matplotlib and statsmodels libraries


- Load portfolios.csv, bookToMarket.csv and “marketEquity.csv”


datasets into pandas, store them as variables called data, bm and me respectively.


- Extract 99 assets and assign them to a variable called assets.


- Obtain the number of rows and columns of assets and store results as rr and cc


respectively.



Part 1: Value





a) i) For each month in the data, sort the returns on the 99 assets based on the book-to- market ratio of those assets and call it assets_sorted. Also in the same for loop obtain the corresponding sorted market equity (i.e. sorted based on book-to-market) and call it me_sorted.



Report answer for obtained assets_sorted and me_sorted by placing the first 3 rows into a docstring i.e. you should have something that looks as:



'''


assets_sorted


N/A N/A N/A N/A ... N/A N/A N/A N/A


1963-07


1963-08


1963-09 '''





'''


me_sorted



1963-07


1963-08


1963-09 '''






N/A N/A N/A N/A ... N/A N/A N/A N/A





ii) construct 6 equal-size portfolios based on this sort (so the 1st portfolio has the 1/6 original assets with the lowest book-to-market ratio, the 2nd portfolio has the next lowest 1/6, etc), call the variable portfolios. Compute the equal-weighted return on each of those 6 portfolios. Report the mean and standard deviation of those returns.



Programming tips:


You will need to loop over the following sequence: [0, 16, 32, 48, 64, 80]. Be careful to ensure that in case where ii = 80 you are indeed using the 19 remaining values of assets (not just 16). You may find an if else branching statement useful.



Report answer for obtained portfolios by placing the first 3 rows into a docstring. Report mean and standard deviation by placing the 6 values for each into a docstring.







b) Compute the return on a factor-mimicking portfolio for Value (call it r_value) by going long the portfolio with the highest book-to-market (portfolio 6 from part a) ) and going short the portfolio with the lowest book-to-market ratio (portfolio 1 from part a) ).


Plot the series and report the mean and standard deviation of those returns. Report answer for r_value by placing the first 3 rows into a docstring.


Report mean and standard deviation using a docstring.






Part 2: Momentum





In this part you are going to construct and examine the momentum factor. The momentum factor sorts assets based on their average return from month t-1 to month t-12 (however you should skip the return in the last month t-1, this is based on research showing that momentum is best predicted without using t-1).


So, for example, if we are in January 2020, the momentum variable for Jan 2020 is constructed by computing the average return on the asset for 11 months: from Jan 2019 to Nov 2019.



a) Compute momentum for each asset (i.e. its average return from month t-1 to month t- 12). Note that you will lose the first 12 observations of the sample when doing this.






b) Sort the assets based on their momentum, and compute 10 portfolios based on that sort and their corresponding return, call the resulting variable portfolios_m. Report the mean and standard deviation of the returns for each of the 10 portfolios.






c) Regress the returns of each of the 10 portfolios on a two factor model with the market risk premium and the value factor you computed in question 1.b) as the 2 factors (remember to include a constant).





Report answer for each part above inside a docstring.




Part 3: Momentum Trading





a) Assume that you are an asset manager that wishes to invest in the highest momentum portfolio, at the end of last month included in the sample. Report the assets that you should buy.





b) Turnover is the percentage of assets in the portfolio that changes from period to period (i.e. when comparing assets held at t vs t-1). A strategy with high turnover implies high transaction costs, therefore it is an important quantity to compute.



Calculate the historical average turnover associated with investing in the highest momentum portfolio. More precisely, for each month (starting from the 2nd) in the sample, compute the % of assets in the portfolio that are new as compared to the previous month sold. Then take the average over the whole sample.



Report answer for each part above inside a docstring.











Part 4: Combining Value and Momentum





For each month in the data:



i) sort the returns on the 99 assets based on the book-to-market ratio of those assets



ii) create 3 equal-size portfolios based on the previous sort (bottom 33% to top 33%)



iii) within each of the previous 3 portfolios sort the assets based on momentum



iv) create an additional 3 equal-size portfolios based on this new sort



v) compute the equal-weighted return on each of these 3*3 (i.e. 9) portfolios Report the mean and standard deviation of the 9 portfolios.


Report answer for each part above inside a docstring.







Part 5: Value Weighted Returns





Repeat a) but using value-weighted returns for the 6 portfolios instead of equal-weighted returns (where value-weighted returns are returns weighted by the relative market cap of each asset), store result into dataframe called portfolios_vw.



NOTE: this is referred to as computing value-weighted returns, since we are weighting them by the value of each “company”. Not to be confused with the concept of the value factor which is based on the book-to-market ratio.



Programming tips (full solution):


You can solve the full task by either:


o [advised] creating 2 nested for loops (requires adapting the code developed for 1 value case above.


o [advanced] adapting the code from part 1 a) and using linear algebra in Python (hint: if you have a matrix m of size 680x16 and a vector v of size 680x1, and you would like divide each element in row n of the matrix, by a number in position n of vector: use (m.T / v).T where .T means transpose (shorthand for .traspose() method you have seen before).



Feel free to use either of the above approaches, mark allocation won’t change. Whichever way you chose to solve this, do remember to use all 19 values of assets for the last portfolio.



Report answer for portfolios_vw by placing the first 3 rows into a docstring. Report mean and standard deviation by placing the 6 values for each into a docstring.


May 12, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here