Hi, happy to share. Hereâ€™s the GitHub:
I assume you are asking how I project wealth into the future using market returns, savings and spending:

I generate a random market return for every year of the userâ€™s life. This is just generating a random number (in my case Iâ€™m using a mean of 0.08 and standard deviation of .14).

If a user is expected to live another 60 years, thatâ€™s 60 random numbers and that represents a possible future for the user.

I then construct 10,000 of these possible futures. In effect this constructs an array with 10,000 subarrays and each of these subarrays is composed of 60 random stock market returns. This is called a Monte Carlo simulation. It can easily be accomplished using the numpy python library: np.random.normal(mean, stdev, size=[num_simulations, periods]) (see random_walk_simulations() in functions.py)

Similarly I then construct a 10,000 x 60 matrix (array) containing information about user savings in each year, another matrix for user spending, another matrix for social security payments, allocation between stocks/bonds, etc.

then itâ€™s just a matter of combining all these matrices together. See the calc_wealth_trajectory() function for this logic. Iâ€™m going to take the wealth in the prior period and calculate the wealth in the current period by multiplying the prior wealth by the current market return (incorporating the stock return/bond return) and then adding/subtracting the userâ€™s savings/spending.

the end result is a 10,000 x 60 matrix where each element represents the wealth at that point in time in a possible future. From there you can calculate at time t what the 50th percentile is for wealth (expected scenario), of the 5th percentile (pessimistic scenario). See wealth_distributions() for this logic.
But if youâ€™re asking how I created the chart itself, then thatâ€™s easy too. See line 382516 of apps/home.py