Retirement Simulator Introduction and Overview

Published Dec. 31, 2021, 4:15 p.m.

Welcome to the introduction to the python millionaire retirement simulator series.  I've created this tutorial series in order to showcase some of the fun features of python that can be used to create a "saving for retirement" simulation that is fully customizable.  We'll be using the datetime module in python to march through time.  While marching through time we will simulate putting money into the fund. We will use the random module to pick reasonably realistic interest rates over time and see how your money grows (or shrinks) over time.  The final product will be a simulation that predicts a large number of random scenarios so that we can see which ones are the most likely.  Furthermore, we can select different retirement dates to see how that changes the final outcomes.

If you follow this entire series you will have made a python-based retirement planner like the one I show in the video. We will start off very simply.  The bare-bones of this simulation is a 'while' loop that continues to run until we go past a retirement date that we will select.  Once that it established we will determine how frequently we get a paycheck and how much money we put into our retirement fund from each paycheck.  Next we will add a simple (semi-realistic) interest rate for the retirement account.  There will be a bit of math used to convert the "annual interest rate" into  what I call a "paycheck interest rate". Eventually we will use some historical data for market rates (a distribution of market rates), make a fit to that data (using a Gaussian function), and then create our own sample distribution of interest rates.

With all that established we will run a few thousand simulations and analyze the results!  Of course you are encouraged to make your own personalizations along the way.  However, if you follow this series exactly we will pick three retirement dates in the years 2040 2035 and 2030.  I will show you some of the formatting for the matplotlib module so that we can color code our simulations as well. Of course, for this retirement planner to do anything useful, we'll need to be able to look at the final outcomes of each simulation and determine some meaningful results.  It should not be surprising to find out that working and saving money for a longer amount of time increases the likelihood of more wealth in retirement (but it does not guarantee it).  Our model will be "random" and "probabilistic" -- meaning that when we run many 1000 simulations we can find out which final outcomes are "very likely" and which ones are "not very likely".

I tuned this simulation for a fixed retirement date.  However, at the end of the series I show that you can easily adjust it work for a final retirement amount as well.  All along the way there should be plenty of opportunity for customization.  In the final video I will spend some time showing how to configure plots in python.

I hope you've enjoyed this introduction and I hope you will stick around for the whole series!  Thanks for watching.

skip_nextRetirement Simulator #1: March through time with datetime and put money under the mattress!
  • Retirement Simulator Introduction and Overview
    (currently viewing)
  • Retirement Simulator #1: March through time with datetime and put money under the mattress!

  • Retirement Simulator #2: Apply an interest rate and verify it!

  • Retirement Simulator #3: Use a Gaussian distribution of rates!

  • Retirement Simulator #3+: Verify our Gaussian distribution!

  • Retirement Simulator #4: Make a US market rates distribution

  • Retirement Simulator #5: Fit the Market Data with scipy curve_fit

  • Retirement Simulator #6: Sampling from our custom market distribution

  • Retirement Simulator #7: Organize multiple plots with subplots! and learn about plt.pause()

  • Retirement Simulator #8: Multiverse Investing: Simulate 1000 random investors

  • Retirement Simulator #9: Track averages and final outcomes

  • Retirement Simulator #10: Test and Compare Different Retirement dates (And make it pretty!)