Skip to content

willwillis/python-pandas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unit 4 Homework Assignment: A Whale Off the Port(folio)

Portfolio Analysis

Background

The investment division of Harold's company has been investing in algorithmic trading strategies. Some of the investment managers love them, some hate them, but they all think their way is best.

You just learned these quantitative analysis techniques with Python and Pandas, so Harold has come to you with a challenge: to help him determine which portfolio is performing the best across many areas: volatility, returns, risk, and Sharpe ratios.

You will need to create a tool (an analysis notebook) that analyzes and visualizes the major metrics of the portfolios across all of the aforementioned areas, and determine which portfolio outperformed the others. You will be given the historical daily returns of several portfolios: some from the firm's algorithmic portfolios, some that represent the portfolios of famous "whale" investors like Warren Buffett, and some from big hedge and mutual funds. You will then use this analysis to create a custom portfolio of stocks and compare its performance to that of the other portfolios, as well as the larger market (S&P 500).

In this homework assignment, you will be accomplishing three main tasks:

  1. Read in and Wrangle Returns Data
  2. Determine Success of Each Portfolio
  3. Choose and Evaluate a Custom Portfolio

Instructions

File: Whale Analysis Starter Code

Prepare the Data

First, read and clean several CSV files for analysis. The CSV files include whale portfolio returns, algorithmic trading portfolio returns, and S&P 500 historic prices. Use the Whale Analysis Starter Code to complete the following steps:

  1. Use Pandas to read in each of the CSV files as a DataFrame. Be sure to convert the dates to a DateTimeIndex.

  2. Detect and remove null values.

  3. Remove dollar signs from the numeric values and convert the data types as needed.

  4. The whale portfolios and algorithmic portfolio CSV files contain daily returns, but the S&P 500 CSV file contains closing prices. Convert the S&P 500 closing prices to daily returns.

  5. Join Whale Returns, Algorithmic Returns, and the S&P 500 Returns into a single DataFrame with columns for each portfolio's returns.

returns-dataframe.png

Conduct Quantitative Analysis

Analyze the data to see if any of the portfolios outperform the stock market (i.e., the S&P 500).

Performance Analysis

  1. Calculate and plot cumulative returns. Does any portfolio outperform the S&P 500?

  2. Calculate the cumulative terms by month and year. What were the best returns in 2017? What were the best returns for December 2018?

Risk Analysis

  1. Create a box plot for each of the returns. Which box has the largest spread? Which has the smallest spread?

  2. Calculate the standard deviation for each portfolio. Which portfolios are riskier than the S&P 500?

Rolling Statistics

  1. Plot the rolling standard deviation of the firm's portfolios along with the rolling standard deviation of the S&P 500. Does risk increase for each of the portfolios at the same time risk increases in the S&P?

  2. Construct a correlation table for the algorithmic, whale, and S&P 500 returns. Which returns most closely mimic the S&P?

  3. Choose one portfolio and plot a rolling beta between that portfolio's returns and S&P 500 returns. Does the portfolio seem sensitive to movements in the S&P 500?

Plot Sharpe Ratios

Investment managers and their institutional investors look at the return-to-risk ratio, not just the returns. (After all, if you have two portfolios that each offer a 10% return, yet one is lower risk, you would invest in the lower-risk portfolio, right?)

  1. Using the daily returns, calculate and visualize the Sharpe ratios using a bar plot.

  2. Determine whether the algorithmic strategies outperform both the market (S&P 500) and the whales portfolios.

Create Custom Portfolio

Harold is ecstatic that you were able to help him prove that the algorithmic trading portfolios are doing so well compared to the market and whales portfolios. However, now you are wondering whether you can choose your own portfolio that performs just as well as the algorithmic portfolios. Investigate by doing the following:

  1. Visit NASDAQ's Historical Price Data and choose 3-5 stocks for your own portfolio.

  2. Download the data as CSV files and calculate the portfolio returns.

  3. Add your portfolio returns to the DataFrame with the other portfolios and rerun the analysis. How does your portfolio fair?


Resources

Pandas API Docs


Hints

  • The Pandas functions used in class this week will be useful for this assignment.

  • Be sure to use head() or tail() when you want to look at your data but don't want to print to a large DataFrame.


Submission

  1. Create a Jupyter Notebook containing your data preparation, analysis, and visualizations. Put your analysis and answers to the assignment questions in raw text (markdown) cells in the report.

  2. Submit your notebook to a new GitHub repository.

  3. Add the URL of your GitHub repository to your Assignment when submitting via Bootcamp Spot.


© 2019 Trilogy Education Services

About

Repo for FinTech homework

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published