Forecasting Wealth for Financial Planning
An effective concept in personal finance is passive investing: buying and holding a broadly diversified portfolio of ETFs. History shows that while markets can swing wildly in the short term, over the long run, the world economy yields positive returns. In Fact, there's the idea that with almost certainty, there will be some form of world economy in the future that also yields positive returns.
But why not try to figure out what the best stocks are and pick those? This contradicts the idea of passive investing. The key assumption is that no one can reliably predict which companies or sectors will perform in the future. There's evidence that such fund managers cannot beat their indices.
So, I've been investing in a diversified ETF portfolio for many years now. Once a month, I review the development of my accounts and record the values in a simple CSV file. At some point, I wrote a small Python script to visualize the growth, and after collecting data for several years, I could clearly see an exponential trend emerging.
That led me to the next idea: fitting an exponential curve to my data and projecting my portfolio's value two or three years into the future. Adding some predictions to the script took less than an hour, and it seems surprisingly effective. Knowing where I'll be financially in a couple of years lets me make the right choices now. Especially, as we tend to underestimate exponential growth. Seeing where your investments will be in just a few years can be a boost to stay consistent and motivated.
For the exponential fit, I used a simple model that combines an exponential and a linear component:
This model predicts well if you've been investing in the same mix of assets over a long period (e.g., a diversified ETF portfolio) and saving at a steady rate. Under those assumptions, the model becomes quite predictive.
#!/usr/bin/python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
from datetime import timedelta
data = pd.read_csv("finance.csv")
data["date"] = pd.to_datetime(data["date"])
data = data.sort_values("date")
t0 = data["date"].min()
data["t"] = (data["date"] - t0).dt.days
# Model
def exp_linear_model(t, a, b, c, d):
return a * np.exp(b * t) + c * t + d
# Model Fit
t = data["t"].values
y = data["money"].values
initial_guess = [y[0], 0.001, 0.0, 0.0]
params, covariance = curve_fit(exp_linear_model, t, y, p0=initial_guess, maxfev=10000)
a, b, c, d = params
print("Fitted parameters:")
print(f"a={a:.4f}, b={b:.6f}, c={c:.4f}, d={d:.4f}")
future_days = 365 * 2
t_future = np.arange(0, t[-1] + future_days)
y_fit = exp_linear_model(t_future, a, b, c, d)
dates_future = [t0 + timedelta(days=int(x)) for x in t_future]
plt.figure(figsize=(10, 6))
plt.plot(data["date"], data["money"], color="blue", label="Observed data", marker='.', linestyle='-')
plt.plot(dates_future, y_fit, color="red", label="Model fit + forecast")
plt.xlabel("Date")
plt.ylabel("Money")
plt.title("Wealth Development Over Time (with Exponential and Linear Fit)")
plt.legend()
plt.grid(True)
plt.tight_layout()
plt.show()