Last active
August 3, 2016 06:46
-
-
Save squamous/4442f265356f2ec0c9f6ebc0f42b5d34 to your computer and use it in GitHub Desktop.
Calculate savings goals with inflation adjustment
This file contains hidden or 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 python | |
# | |
# Calculate savings goals with inflation adjustment. | |
# | |
import locale | |
locale.setlocale(locale.LC_ALL, '') | |
SAVING_PERIOD = 5 # years | |
INFLATION_PERCENTAGE = 4 # percentage | |
UNIT_PRICE = 270 # Australian dollars (AUD) | |
UNITS_PER_BATCH = 32 | |
RENT_PCM = 1300 # AUD | |
GOAL_ACCUMULATED = 0 # AUD | |
rent_pa = RENT_PCM * 12 | |
batch_value = UNITS_PER_BATCH * UNIT_PRICE | |
SAVINGS_GOAL_PA = 2 * rent_pa # AUD | |
saving_goal_total = SAVING_PERIOD * SAVINGS_GOAL_PA | |
annual_saving_goal_minus_inflation = [int(SAVINGS_GOAL_PA)] | |
for i in range(0, SAVING_PERIOD): | |
inflation = annual_saving_goal_minus_inflation[i] * INFLATION_PERCENTAGE /100 | |
annual_saving_goal_minus_inflation.append( | |
annual_saving_goal_minus_inflation[i] - inflation | |
) | |
inflation_per_annum_list = [SAVINGS_GOAL_PA - n for n in annual_saving_goal_minus_inflation] | |
expenses_per_annum_list = [0] | |
real_savings_goal = saving_goal_total + sum(inflation_per_annum_list + expenses_per_annum_list) | |
real_savings_monthly_goal = real_savings_goal / SAVING_PERIOD / 12 | |
real_savings_annual_goal = real_savings_goal / SAVING_PERIOD | |
units_sold_per_month = float(real_savings_goal ) / UNIT_PRICE / SAVING_PERIOD / 12 | |
batches_per_annum = float(real_savings_annual_goal) / batch_value | |
print """ | |
({upb} UNIT) BATCH VALUE: {bv} @ {up}/unit | |
SAVING PERIOD: {sp} years | |
Goals: | |
ANNUAL SAVING GOAL: {sgpa} | |
TOTAL SAVING GOAL: {tsg} | |
TOTAL INFLATION: {ti} | |
REAL SAVING GOAL: {rsg} | |
monthly: {rsmg} | |
annual: {rsga} | |
Targets: | |
UNITS/month: {uspm} | |
BATCHES/annum: {bpa} | |
GOAL REMAINING: {gr} | |
""".format( | |
upb=UNITS_PER_BATCH, | |
bv=locale.currency(batch_value), | |
up=locale.currency(UNIT_PRICE), | |
sgpa=locale.currency(SAVINGS_GOAL_PA), | |
sp=SAVING_PERIOD, | |
uspm=units_sold_per_month, | |
tsg=locale.currency(saving_goal_total, grouping=True), | |
ti=locale.currency(sum(inflation_per_annum_list), grouping=True), | |
rsg=locale.currency(real_savings_goal, grouping=True), | |
rsmg=locale.currency(real_savings_monthly_goal, grouping=True), | |
rsga=locale.currency(real_savings_annual_goal, grouping=True), | |
bpa=batches_per_annum, | |
gr=locale.currency(real_savings_goal - GOAL_ACCUMULATED, grouping=True) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment