Skip to content

Instantly share code, notes, and snippets.

@faizsiddiqui
Last active February 2, 2025 06:57
Show Gist options
  • Save faizsiddiqui/65fd0675dac6d538447788710e8be85b to your computer and use it in GitHub Desktop.
Save faizsiddiqui/65fd0675dac6d538447788710e8be85b to your computer and use it in GitHub Desktop.
Calculate FD Interest & Schedule
from datetime import datetime, timedelta
from dateutil.relativedelta import relativedelta
def calculate_fd_interest(principal, rate, tenure_days, start_date):
interest_dates = []
current_date = datetime.strptime(start_date, "%Y-%m-%d")
end_date = current_date + timedelta(days=tenure_days)
quarterly_rate = rate / 4 / 100 # Quarterly interest rate
total_principal = principal
while current_date < end_date:
current_date += relativedelta(months=3) # Next quarter
if current_date > end_date:
break
interest = principal * quarterly_rate # Simple interest per quarter
total_principal += interest
interest_dates.append((current_date.strftime("%Y-%m-%d"), round(interest, 2), round(total_principal, 2)))
return interest_dates
# Example usage
principal = float(input("Enter the principal amount: ")) # Initial deposit amount
rate = float(input("Enter the annual interest rate (in %): ")) # Annual interest rate in %
tenure_days = int(input("Enter the tenure in days: ")) # Tenure in days
start_date = input("Enter the FD start date (YYYY-MM-DD): ") # FD start date
interest_schedule = calculate_fd_interest(principal, rate, tenure_days, start_date)
print("Quarterly Interest Payout Schedule:")
for date, amount, total in interest_schedule:
print(f"Date: {date}, Interest: {amount}, Total Amount: {total}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment