jharvey09 / Your_Personal_Financial_Planner

In this project, I will use a Monte Carlo function to run a series of transactions for future portfolio results using their cryptocurrency and stock portfolio. Additional portfolio projections added.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Your Personal Financial Planner

image

Table of Contents:

Background

Steps

Resources

Steps_Breakdown

Retirement Planning

Summary

Index:

Collect Crypto Prices Using the requests Library

Collect Investments Data Using Alpaca: SPY (stocks) and AGG (bonds)

Savings Health Analysis

Retirement Analysis

Current value of Bitcoin & Ethereum portfolio:

image

Current value of AGG/SPY portfolio:

image

Background:

In this project, I will use Python to create two tools, assisted by other functions; and libraries used for financial planning. I'm building a "Personal Finance Planner"; that allows users to visualize their savings composed by investments split between shares and cryptocurrencies.

The first will be a personal finance planner that will allow users to visualize their savings composed by investments in shares and cryptocurrencies to assess if they have enough money as an emergency fund. The second tool will be a retirement planning tool that will use the Alpaca API to fetch historical closing prices for a retirement portfolio composed of stocks and bonds, then run Monte Carlo simulations to project the portfolio performance at 30 years. I will then use the Monte Carlo data to calculate the expected portfolio returns given a specific initial investment amount.

Steps:

To develop the personal finance planner prototype, you need the following information to compose the analysis: The average household income for each member of the credit union is $12,000. Every union member has a savings portfolio composed of cryptocurrencies, stocks, and bonds: Assume the number of crypto assets: 1.2 BTC and 5.3 ETH. Assume the shares in stocks and bonds: 50 SPY (stocks) and 200 AGG (bonds).

Collect Crypto Prices Using the requests Library:

First, Create two variables called my_btc and my_eth. Set them equal to 1.2 and 5.3, respectively. Use the requests library to fetch the current price of US dollars of bitcoin (BTC) and ethereum (ETH), using the Alpaca API. Parse the API JSON response to select only the crypto prices and store each as a variable. Compute the portfolio value of cryptocurrencies and print the results.

Collect Investments Data Using Alpaca: SPY (stocks) and AGG (bonds):

"Important: Remember to create a .env file in your working directory to store the values of your Alpaca API key and Alpaca secret key." First, create two variables named my_agg and my_spy and set them equal to 200 and 50, respectively. Set the Alpaca API key and secret key variables, then program the Alpaca API object using the tradeapi.REST function from the Alpaca SDK. Format the current date as ISO format. Change the date set to the current date. Next, get the current closing prices for SPY and AGG using Alpaca's get_barset() function. Transform the function's response to a Pandas DataFrame and preview the data. Pick the SPY and AGG close prices from Alpaca's get_barset() DataFrame response and store them as Python variables. Print the closing values for validation. Compute the value in dollars of the current amount of shares and print the results.

Savings Health Analysis:

In this section, I will assess the financial health of the credit union's members. First, I will create a variable called monthly_income and set the value at 12000. I want to create a DataFrame to analyze savings health, called df_savings. It will consist of two rows, first row will hold crypto assets the other row will hold the total value of shares. The DataFrame will house one column named amount with two rows for crypto and shares are index values.

Savings Health Analysis Visual:

image

Steps_Breakdown:

  1. Collect Crypto Prices Using (requests) Library
  2. The Alpaca Markets API was used to pull historical stocks and bonds information
  3. An "Emergency Fund" can be created by taking the monthly salary and multilplying it by 3 months
  4. Collect Investment Data Using Alpaca: SPY/ AGG Stocks
  5. Saving Health Analysis
  6. Run Monte Carlo Simulation
  7. Retirement Analysis

Current value of Bitcoin & Ethereum portfolio

image

Current value of AGG/SPY portfolio

image

Savings Health Analysis:

image

Plotted to a Pie Chart:

image

Retirement Planning:

Monte Carlo Simulation:

For this portion, use the Alpaca API to fetch historical closing prices for a retirement portfolio and then use the MCForecastTools toolkit to create Monte Carlo simulations to project the portfolio performance at 30 years. Use the Alpaca API to fetch five years of historical closing prices for a traditional 40/60 portfolio using the SPY and AGG tickers to represent the 60% stocks (SPY) and 40% bonds (AGG) composition of the portfolio. Make sure to convert the API output to a DataFrame and preview the output. Configure and execute a Monte Carlo Simulation of 500 runs and 30 years for the 40/60 portfolio. Plot the simulation results and the probability distribution/confidence intervals.

Retirement Analysis:

Fetch the summary statistics from the Monte Carlo simulation results. Make the initial investment $20,000, calculate the expected portfolio returns in dollars at the 95% lower and upper confidence intervals. Calculate the portfolio returns at the 95% lower and upper confidence intervals based on a 50% increase in the initial investment.

Retirement Planning-Monte Carlo Simulation Outcomes:

image

Personal Savings Analysis:

image

Bar Graph:

image

Summary:

I adjusted the portfolio to either include more risk (a higher stock than bond ratio) or maximize the initial investment and rerun the retirement analysis to see what it would take to retire in 5 or 10 years instead of 30! Calculate the five years worth of historical data used for SPY & AGG with the aide of the Alpaca API applying the (get_barset()) function. as well as the Monte Carlo simulation configuration that was adjusted to 10 & 5 years (MCForecastTools)

Short Term Retirement Projections-Monte Carlo Simuations (Line Plots):

10 Year Simulation:

image

5 Year Simulation:

image

Resources:

  1. Alpaca Markets API
  2. Alternative Free Crypto API

About

In this project, I will use a Monte Carlo function to run a series of transactions for future portfolio results using their cryptocurrency and stock portfolio. Additional portfolio projections added.


Languages

Language:Jupyter Notebook 100.0%