https://github.com/sarahm44/python-portfolio-analysis
Analysis of financial portfolios using Python, across the metrics of volatility, returns, risk and Sharpe ratios.
https://github.com/sarahm44/python-portfolio-analysis
financial-analysis fintech
Last synced: 3 months ago
JSON representation
Analysis of financial portfolios using Python, across the metrics of volatility, returns, risk and Sharpe ratios.
- Host: GitHub
- URL: https://github.com/sarahm44/python-portfolio-analysis
- Owner: sarahm44
- Created: 2022-03-03T10:11:46.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-05T05:57:00.000Z (almost 3 years ago)
- Last Synced: 2025-02-09T12:32:00.261Z (5 months ago)
- Topics: financial-analysis, fintech
- Language: Jupyter Notebook
- Homepage:
- Size: 4.81 MB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python Portfolio Analysis
## Contents
- [Overview](#overview)
- [Data Preparation](#data-preparation)
- [Quantitative Analysis](#quantitative-analysis)
* [Performance Analysis](#performance-analysis)
* [Risk Analysis](#risk-analysis)
- [Sharpe Ratios](#sharpe-ratios)
- [Custom Portfolio](#custom-portfolio)
* [Data Preparation](#data-preparation-1)
* [Re-run the Analysis, Comparing My Portfolio](#re-run-the-analysis-comparing-my-portfolio)## Overview
I was tasked with analysing a number of financial portfolios across the areas of:
* volatility
* returns
* risk
* Sharpe ratiosI created an [analysis notebook](https://github.com/sarahm44/unit-4-assignment/blob/main/whale_analysis.ipynb) 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](https://github.com/sarahm44/unit-4-assignment/blob/main/whale_analysis.csv), [Algorithmic Returns](https://github.com/sarahm44/unit-4-assignment/blob/main/algo_returns.csv), and the [S&P 500 Returns](https://github.com/sarahm44/unit-4-assignment/blob/main/sp_tsx_history.csv) 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](https://github.com/sarahm44/unit-4-assignment/blob/main/ada_data.csv), [Bitcoin](https://github.com/sarahm44/unit-4-assignment/blob/main/btc_data.csv) and [Ethereum](https://github.com/sarahm44/unit-4-assignment/blob/main/eth_data.csv).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:
