Assignment to show learning of pandas, python, and financial topics over the last several weeks in the Rice University FinTech Bootcamp! [1]
- General info
- Screenshots
- Technologies
- Installation Guide
- Code Examples
- Usage
- Sources
- Status
- Contributors
The following repository encompasses skills learned regarding Python, the Pandas library, and quantitative analysis techniques. The assignment is to create a tool, an analysis notebook, that analyzes and visualizes portfolios across the various metrics to determin which portfolios outperformed the others and the market.[1]
- Combined Whale, Algorithmic, and S&P 500 Returns
- Performance - Cumulative Returns
- Range of Risk
- Correlation Heatmap
* Python - Version 3.8.5
* VS Code - Version 1.49.1
* Jupyter Notebook - Version 6.1.1
* Windows 10
* Library - pandas
* Library - numpy
* Library - datetime
* Library - pathlib
* Library - seaborn
* Library - matplotlib
-
Download entire repository titled, a_whale_off_the_portfolio
-
Open Git Terminal
-
Navigate into repository file path where the repository downloaded.
-
The files should be visible and ready to run by typing the 'ls' command in the prompt and pressing the Enter key on your keyboard. You should see the following files and the whale_analysis.ipynb notebook.
*See Usage section below for instructions how to run the program.
- Calculating cumulative returns and plotting data
# Plot cumulative returns
cumulative_returns = (1 + combined_returns).cumprod()
cumulative_returns.plot(title="Cumulative Returns", figsize=(20,10))
- To compare which portfolios carry a greater risk than the S&P 500 based on daily standard deviation.
# Determine which portfolios are riskier than the S&P 500
index_num = 0
for portfolio in combined_daily_std:
if portfolio > combined_daily_std["S&P 500"]:
true_false = "True"
print(f"{combined_daily_std.index[index_num]:<30}{true_false:>6}")
else:
true_false = "False"
print(f"{combined_daily_std.index[index_num]:<30}{true_false:>6}")
index_num += 1
- Calculating Beta for one portfolio compared to the S&P 500 and plotting the information.
rolling_covariance = combined_returns['BERKSHIRE HATHAWAY INC'].rolling(window=21).cov(combined_returns['S&P 500'])
rolling_variance = combined_returns['S&P 500'].rolling(window=21).var()
rolling_beta = rolling_covariance / rolling_variance
rolling_beta.plot(figsize=(20,10), title="Berkshire Hathaway Inc Beta")
-
To run the analysis process, navigate to the directory where whale_analysis.ipynb is located using Git Terminal within the a_whale_off_the_portfolio directory.
-
Execute the command 'code .' in the terminal to open VS Code.
-
VS Code opens. Select the main.ipynb file in the PyBank directory.
-
Click the Run All Cells button, double arrows, to run all cells in the Jupyter Notebook file.
-
All cells in the notbook run.
Project is: finished
- Jonathan Owens
- LinkedIn: www.linkedin.com/in/jonowens