Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Intro Fintech in Portfolio Management

Assignment 2

Due by 1 PM, March 11, 2024

(Each group would send their ppt file and code file directly to [email protected])

Period of analysis: Jan 1, 2010 - March 5, 2024

1. Use Python to download all S&P 500 daily stock returns from yahoo finance starting from

January 1, 2010 to June 4, 2024. Note that you have to download all sectors’ returns except two sectors – “Financials” and Real Estate.”

2. After downloading all returns, convert the dataframe from wide format to long format, having a column “Symbol” of all stocks’ names and another column “ret” showing stock returns. Then   merge “gics_sector” column from S&P 500 list collected from Wikipedia with return data.

3. Calculate correlation of annual average returns for each sector. Note that to calculate this time you have to convert the shape from long to wide having all sectors as the column names.

4. Select the sector of which returns are least correlated with your sector. For example, if you work on “Financials,” and find out that your sector is least correlated with “Industrials,” then create a portfolio of all stocks from Financials” and “Industrials.”

5. Once you select two sectors, calculate the annual Share ratio of each company. Then calculate the average value of annual Sharpe ratio of each company over the sample period. Note that you have to download 3-month T-bill secondary market rate (TB3MS) using “fred” API for the

period so that you can calculate excess returns for measuring Sharpe ratios.

6. From each sector, find out the best 5 stocks with highest values of Sharpe ratios (total 10 stocks).

7. Now, calculate CAPM beta for each of the 10 stocks. Use “^GSPC” or S&P500 as the benchmark (you have to download ^GSPC returns for the period and calculate its excess returns).

8. Create a dataframe showing 10 stocks with Sharpe ratios (calculated in step#6 above) and their betas. Now, select first five stocks with the highest Sharpe ratios, and then, within that highest five, select the three stocks with the lowest beta.

9. Finally, draw a graph showing prices of the selected three stocks for the period in the primary axis and ^GSPC prices in the secondary axis.

The ppt file would include -

First slide – Sector names, total number of companies and some intro on the sectors; second slide – show the correlation matrix as done in Q3

third slide – list 10 companies of 2 sectors and their Sharpe ratios and CAPM beta as done in Q8, fourth slide – the Graph of stock prices and S&P500 as instructed in Q9.

Send the ppt file and code file directly to [email protected]

Your coding file will be graded on assignment category and PPT on presentation category.