如何进行摊销计算

时间:2019-06-27 01:15:43

标签: python

我正在尝试在python中进行摊销计算。我使用的是PyCharm IDE,并且一直得到错误的答案。 MIR和MT是抵押贷款利率和抵押期限(年),并且在脚本中的输入要高得多。

我不确定是什么问题,有帮助吗?

monthly_rate = MIR / 100
loan_term_months = MT * 12
balance = Mortgage_Balance

# Top of the equation
math1 = monthly_rate * ((1 + monthly_rate) ** MT)    # r(1+r)^n
# Bottom of the equation
math2 = ((1 + monthly_rate) ** MT) - 1   # (1+r)^n -1

# Total Equation
annual_payment = (Mortgage_Balance * math1) / math2    # P (r(1+r)^n /(1+r)^n -1)

final_monthly_payment = round((annual_payment / 12), 2)
final_annual_payment = round(annual_payment, 2)

预期结果(当MIR = 4.375和MT = 30时):617.87

给出结果(当MIR = 4.375和MT = 30时):623.82

1 个答案:

答案 0 :(得分:2)

使用scipy financial functions获得每月付款时,可以看到差异。

给定的结果623.82是通过将年付款除以12得到月付款得出的。这是一个错误。您真的想计算月付款而不是年付款除以12。

这是scipy付款功能的结果。

>>> pmt(.04375, 30, 123750)
-7485.858293501044
>>> -7485.8582935010447/12
-623.8215244584204
>>> pmt(.04375/12, 360, 123750)
-617.8655064472862

您可以看到每月付款使用利率除以12(以获得每月利率),期限= 360(30年乘以12个月)。

因此,在您的计算中,

monthly_rate = MIR / 100

“应该是”

monthly_rate = MIR / 100/12

loan_term_months = MT * 12

您在此处正确计算了周期,但未在公式中使用它们。

math1 = monthly_rate * ((1 + monthly_rate) ** loan_term_months)

math2 = ((1 + monthly_rate) ** loan_term_months) - 1