The Tax-Free Retirement Account, commonly referred to as a Roth Individual Retirement Account (IRA), and the Keogh Plan are both tax-advantaged retirement savings accounts available in the United States. Contributions are made from income that has already been taxed, and the balance then compounds free of any further tax on the interest it earns. This example shows how uncertainty in the parameters of this model (e.g., annual contribution, tax rate, etc.) affect the future value of the account. The application calculates the total return of your tax-free investment and compares it with the return of an ordinary taxable investment scheme, in which the interest earned is taxed every year.
The correct way to clone this repository to get the submodules is:
git clone --recursive git@github.com:signaloid/Signaloid-Demo-Finance-IndividualRetirementAccount.gitIf you forgot to clone with --recursive and end up with empty submodule directories, you can remedy this with:
git submodule update --initTo run this application on the Signaloid Cloud Developer Platform, you need a Signaloid account. You can sign up for a Signaloid account using this link.
Once you have a Signaloid account, you can click the "add to signaloid.io" button at the
top of this README.md to connect this repository to the Signaloid Cloud Developer Platform
and run the application.
Apart from using Signaloid's Cloud Compute Platform, you can compile and run this application
locally. Local execution is essentially a native Monte Carlo implementation,
that uses GNU Scientific Library1 to generate samples for the different input distributions.
In this mode the application stores the generated output samples, in a file called data.out.
The first line of data.out contains the execution time of the Monte Carlo implementation
in microseconds (μs), and each next line contains a floating-point value corresponding to an output sample value.
The native build needs GNU Make, a C compiler, and the GNU Scientific Library (GSL).
On macOS, install the Xcode Command Line Tools (which provide make and the C
compiler) and then install GSL with Homebrew:
xcode-select --install
brew install gslOn Linux (Debian/Ubuntu):
sudo apt-get install -y build-essential libgsl-devThe top-level Makefile detects the GSL install location automatically, covering
Homebrew on Apple Silicon (/opt/homebrew), Homebrew on Intel (/usr/local) and
MacPorts (/opt/local), so no further configuration is needed on macOS.
In order to compile and run this application in the native Monte Carlo mode:
- Compile natively, from the repository root (e.g., on Linux):
make local-build
This builds the demo-native-mc executable at the repository root.
2. Run the application in the MonteCarlo mode, using (-M) command-line option:. We need to select a single output
when in MonteCarlo mode, so we print the taxable investment output here.
./demo-native-mc -M 10000 -S 0
The above program runs 10000 Monte Carlo iterations. 3. See the output samples generated by the local Monte Carlo execution:
cat data.out
The inputs and their distributions are:
-
$n$ : The number of years to retirement. -
$t_i$ : The total annual contribution to the account in the$i^\mathrm{th}$ year. -
$c_i$ : The compounded annual interest rate in the$i^\mathrm{th}$ year. -
$r_i$ : The assumed tax rate on interest in the$i^\mathrm{th}$ year. -
$w_i$ : The withdrawal rate in the$i^\mathrm{th}$ year. Because contributions to a tax-free account are made from income that has already been taxed, the model applies$w_i$ to the$i^\mathrm{th}$ year's contribution, so only$(1 - w_i) t_i$ enters the account.
The output is the future value (FV) of the account at retirement.
For each of the two investments below, the HP 12C Platinum Solutions Handbook2 provides a closed-form formula. That formula is only useful when the input variables are constant over the years until retirement, so we also give the equivalent formula for input variables that vary over the years, which is the one this application evaluates.
For constant input variables:
For input variables that vary over the years:
Following is an example output for an ordinary taxable investment, using Signaloid's C0Pro-S core, for the default inputs:
For constant input variables:
For input variables that vary over the years:
Following is an example output for a tax-free investment, using Signaloid's C0Pro-S core, for the default inputs:
Example: Personal Finance: Tax-Free Retirement Account (Roth IRA) or Keogh Plan - Signaloid version
Usage: Valid command-line arguments are:
[-i, --input <Path to input CSV file : str>] (Read inputs from file.)
[-o, --output <Path to output CSV file : str>] (Specify the output file.)
[-S, --select-output <output : int>] (Compute 0-indexed output. By default, all outputs are computed.)
[-M, --multiple-executions <Number of executions : int> (Default: 1)] (Repeated execute kernel for benchmarking.)
[-T, --time] (Timing mode: Times and prints the timing of the kernel execution.)
[-b, --benchmarking] (Benchmarking mode: Generate outputs in format for benchmarking.)
[-j, --json] (Print output in JSON format.)
[-h, --help] (Display this help message.)
[-n, --number-of-years <The number of years to retirement : int in [0, inf)> (Default: 20)]
[-c, --compounded-annual-interest-rate <The compounded annual interest rate expressed as a percentage: double> (Default: Uniform(0.5, 1.0))]
[-t, --total-annual-contribution-to-account <The total annual contribution to the account : double> (Default: Uniform(5000.0, 10000.0))]
[-r, --assumed-tax-rate-on-interest <The assumed tax rate on interest expressed as a percentage : double> (Default: Uniform(20.0, 40.0))]
[-w, --withdrawal-rate <The withdrawal rate expressed as a percentage : double> (Default: Uniform(20.0, 40.0))]
Footnotes
-
HP 12C Platinum Solutions Handbook, Appendix B, page 164. ↩

