Skip to content

Instantly share code, notes, and snippets.

@amberj
Created October 19, 2021 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amberj/eba0f41be9d48c90351dedd06018439c to your computer and use it in GitHub Desktop.
Save amberj/eba0f41be9d48c90351dedd06018439c to your computer and use it in GitHub Desktop.
Calculate interest earned and maturity amount for Recurring Deposit (RD) in Python
#!/usr/bin/env python3
monthly_installment = 30000
# 36 means one installment every month for 3 years
number_of_installments = 36
# Annual rate of interest
# e.g. 9.25%
r = 9.25
# number of compounding periods per year
#
# monthly = 12
# quarterly = 4
# daily = 365
# half_yearly = 2
# yearly = 1
n = 4
# number of years
#t = 2.25
# if r=9, then r_computed is 9/100
r_computed = r/100.0
count = 1
final_maturity_amount = 0
while count <= number_of_installments:
t = (number_of_installments - count)/12.0
individual_maturity_amount = monthly_installment * ((1 + (r_computed/n))**(n*t))
final_maturity_amount = final_maturity_amount + individual_maturity_amount
count = count + 1
print("Final maturity amount:", final_maturity_amount)
print("Interest earned:", final_maturity_amount-(monthly_installment*number_of_installments))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment