Question
Save For Your Retirement! Retirement Age: Estimate the age at which you want to retire. Store this in a variable called retirementAge. In [ ]:
Save For Your Retirement!
Retirement Age:
Estimate the age at which you want to retire. Store this in a variable called retirementAge.
In [ ]:
retirementAge = 70
Estimate how long you think you'll live. Assume that is after your retirement age. Store this in a variable called deathAge.
In [ ]:
deathAge = 85
Retirement Pay:
Figure out how much income you want to live on during your retirement. Assume for simplicity there is no inflation so you can use 2020 dollars. Store this in a variable called retirementPay.
In [ ]:
retirementPay = 50000
Retirement Savings
Figure out how much you need to retire by using the formula savings = (deathAge - retirementAge)*retirementPay
In []: savings = (deathAge - retirementAge)*retirementPay
print(savings)
How to Build Up Your Retirement Savings
Assume in one more year you have your dream job and are making a decent salary, which you will make until you retire.
Every year you put in M dollars into the stock market, which earns R rate of return each year.
Your retirement account then grows in the following pattern.
- After Year 1, you'll have M in your account
- After Year 2, you'll have M*(1+R) + M in your retirement account.
- After Year 3, you'll have M*(1+R)**2 + M*(1+R) + M
- After Year 4, you'll have M*(1+R)**3 + M*(1+R)**2 + M*(1+R) + M
- After Year 5, you'll have M*(1+R)**4 + M*(1+R)**3 + M*(1+R)**2 + M*(1+R) + M
In general, if you work W years, you should have
(1+)+(1+)1++M(1+R)W+M(1+R)W1++M
in your retirement savings account.
Find M for various values of R
Assuming R=.05 is the average annual return on the stock market, and you work W=retirementAge - currentAge number of years, how large does M need to be in order for you to have savings?
Repeat this exercise for
- R = .07
- R = .10
(python)Question 3
Customize the code below for your age and produce plots for the three cases of
- =.05
- =.07
- =.1
Change the code below and create separate code cells for your 3 different plots. 1 point for each plot!
In [1]:
currentAge= 34
W = retirementAge - currentAge
R =.05
x = 1 +R
M = savings/((1-x**W)/(1-x)) ## This is the formula we derived in class.
## Alternatively a linear search approach can be implemented
print(M)
def total_savings(returnRate,numYears,totalSavings): """Assumes returnRate is a float between 0 and 1. numYears is the number of years until retirement. totalSavings is the amount you need to save. returns the yearly investment amount.""" myInvestment = 0 myTotal = 0 while myTotal < totalSavings: mytotal = 0 for i in range(1,numYears+1): mytotal= mytotal + myInvestment*(1+returnRate)**(i-1) if mytotal < totalSavings: mytotal =0 else: myTotal = mytotal myInvestment += 1 return myInvestment
Plot your savings growth!
Now import matplotlib.pyplot in order to plot the growth of your portfolio.
import matplotlib.pyplot as plt
mySavings = [] for i in range(0,W+1): if i ==0: mySavings.append(0) else: mySavings.append(M + mySavings[-1]*(1 + R))
fig = plt.figure() plt.plot(mySavings) plt.title('Retirement Savings at 50%') plt.xlabel('Number of years working') plt.ylabel('Value of Retirement Account ($)')
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started