Skip to content

Analysis of financial portfolios using Python, across the metrics of volatility, returns, risk and Sharpe ratios.

Notifications You must be signed in to change notification settings

sarahm44/python-portfolio-analysis

Repository files navigation

Python Portfolio Analysis

""

Contents

Overview

I was tasked with analysing a number of financial portfolios across the areas of:

  • volatility
  • returns
  • risk
  • Sharpe ratios

I created an analysis notebook that analyzes and visualizes the major metrics of the portfolios across all of these areas, and determines which portfolio outperformed the others.

My data set included a number of different portfolios.

The three main tasks were to:

  1. Read in and wrangle returns data
  2. Determine success of each portfolio
  3. Choose and evaluate a custom portfolio

Data Preparation

For the data preparation I was required to do the following:

  • Use Pandas to read each CSV file in as a DataFrame.
  • Detect and remove all null values.
  • Convert the S&P 500 closing prices to daily returns.
  • Join the Whale Returns, Algorithmic Returns, and the S&P 500 Returns into a single DataFrame with columns for each portfolio's individual returns.

See the single DataFrame below: ""

Quantitative Analysis

In this section, I was required to calculate and visualize performance and risk metrics for the portfolios.

Performance Analysis

Daily Returns

""

Cumulative Returns

""

Risk Analysis

Box Plot

""

Standard Deviation

""

Portfolios Riskier than S&P TSX 60

""

Annualised Standard Deviation

""

Rolling Standard Deviation with a 21-day Window

""

Calculate Correlation

""

Plot Correlation

""

Beta

I was required to calculate and plot Beta for a chosen portfolio (algo 1) and the S&P 60 TSX. ""

Sharpe Ratios

Annualised Sharpe Ratios

""

Sharpe Ratios Bar Plot

""

Determine whether the algorithmic strategies outperform both the market (S&P TSX 60) and the whales portfolios

I found as follows: ""

Custom Portfolio

Data Preparation

I created a custom portfolio of Cardano, Bitcoin and Ethereum.

I used the Google Finance function to choose a portfolio, then downloaded the data needed as CSV files.

In my notebook I read in the CSVs and joined them as a single DataFrame, as below: ""

I calculated the weighted returns for the portfolio assuming an equal number of shares for each stock: ""

Then I added these to my DataFrame containing all portfolios: ""

Re-run the Analysis, Comparing My Portfolio

Annualised Standard Deviation

""

Rolling Standard Deviation with a 21-day Window

""

Calculate Correlation

""

Plot Correlation

""

Beta

I was required to calculate and plot 60-day Rolling Beta for My Portfolio compared to the S&P 60 TSX. ""

Annualised Sharpe Ratios

""

Sharpe Ratios Bar Plot

""

My Portfolio Compared to the Market

For my portfolio, I found as follows: ""

About

Analysis of financial portfolios using Python, across the metrics of volatility, returns, risk and Sharpe ratios.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published