Created
March 5, 2018 22:11
-
-
Save bobular/aeacf8c9090ac68b317ff805a3ea84d4 to your computer and use it in GitHub Desktop.
Extremely simple pension modeller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# -*- mode: cperl -*- | |
# | |
# ./model.pl 0.26 0.02 40 3 0.5 25 | |
# | |
# 0.26 = fraction of salary contribution total (employer+employee) | |
# 0.02 = fractional expected annual asset growth | |
# 40 = number of years working | |
# 3 = salary multiple for lump sum payment | |
# 0.5 = fraction of salary paid out in retirement | |
# 25 = number of years retirement | |
use strict; | |
use warnings; | |
my ($contrib, $growth, $years_work, $lump_multiple, $payout, $years_retired) = @ARGV; | |
my $pot = 0; | |
my $salary = 100; | |
printf "annual salary is %d\n", $salary; | |
foreach (1 .. $years_work) { | |
$pot += $salary*$contrib; | |
$pot *= (1+$growth); | |
} | |
printf "pot is %d after %d years contributions at %d%% of salary and %d%% annual growth of pot\n", | |
$pot, $years_work, $contrib*100, $growth*100; | |
my $lump_sum = $salary*$lump_multiple; | |
$pot -= $lump_sum; | |
printf "lump sum payout of %d upon retirement\n", $lump_sum; | |
foreach (1 .. $years_retired) { | |
$pot -= $salary*$payout; | |
$pot *= (1+$growth); | |
} | |
printf "after %d years retirement paying %d%% of salary, with %d%% growth of (shrinking) pot, the balance is %d\n", | |
$years_retired, $payout*100, $growth*100, $pot; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please see the new version here:
https://gist.github.com/bobular/ffd25244538db9daa92381b1efe8645c
This model does not take into account career progression (annual salary increments) and I have also made some more minor changes to make the model even more conservative.