There are many ways to compute the mortgage monthly payment, this can be done using numpy-financial
package as follow:
with an interest rate of 4.84, and an amount of 5000 over 60 months duration
import numpy_financial as npf
npf.pmt(4.84/100/12, 12*5, 5000)
-93.99009193143375
with simple code
interest_rate = 4.84 / 100 / 12
loan_duration_months = 60
amount_credit = 5000
monthly_payment = amount_credit * (interest_rate * (1 + interest_rate) ** loan_duration_months) / ((1 + interest_rate) ** loan_duration_months - 1)
print(monthly_payment)
93.99
I need to adapt the code to take into consideration the first payment is delayed n months (e.g: 6 months)
The solution to the mentioned problem is simple
First we need to compute the amount of interest of our loan that adds up to the loan amount, let's say we borrowed 10000$ with an interest rate of 5%, the accumulated interest of our loan over 6 months (meaning we didn't make a payment during this 6 months)
interest_rate = 4.84 / 100 / 12
loan_duration_months = 60
payment_delayed_months = 6
loan_amount = 10000
delayed_period_interest_amount = interest_rate * (payment_delayed_months - 1) * loan_amount
print(delayed_period_interest_amount)
201.66666666666666
Now we can compute monthly payment as if we have an initial loan amount 10201.66, using one of the previous mentioned in the problem, for example
import numpy_financial as npf
npf.pmt(4.84/100/12, 12*5, 10201.66)