문제

대출로 월 수수료를 계산하는 방법은 무엇입니까?

주어진 IS :

  • A : 대출 금액.
  • B : 대출 기간 (개월).
  • C : 이자율 PA (이자가 계산되고 매달 추가되고,이자의 1/12가 추가됩니다. 따라서이자가 12%에 달하는 경우 매달 1%의이자가 추가됩니다).
  • D : 기간이 끝난 후 빚진 금액.

이 문제는 평소와 약간 다릅니다. 목표는 대출 기간이 끝난 후에 대출을 지불하는 것이 아니라 여전히 주어진 금액을 빚지고있는 것이기 때문입니다. 나는 알고리즘을 찾을 수 있었으므로 전체 금액을 지불하고 싶다면 문제를 해결할 수 있었지만 물론 목표는 아무 것도 빚지지 않고 주어진 금액으로 인해 목표가 끝나는 경우이 문제에 효과가 없을 것입니다.

나는 추측으로 시작 하여이 문제에 대한 해결책을 만들고 충분히 가까워 질 때까지 그 추측을 계속 개선했습니다. 그러나 단순히 추측보다는 단순히 이것을 계산하는 더 좋은 방법이 있는지 궁금했습니다.

편집 : 여기 내가 지금하고있는 방법은 다음과 같습니다.

def find_payment(start, end, months, interest):
    difference = start
    guess = int(start / months * interest)
    while True:
        total = start
        for month in range(1, months + 1):
            ascribe = total * interest / 12
            total = total + ascribe - guess
        difference = total - end
        # See if the guess was good enough.
        if abs(difference) > start * 0.001:
            if difference < 0:
                if abs(difference) < guess:
                    print "payment is %s" % guess
                    return evolution(start, guess, interest, months)
                else:
                    mod = int(abs(difference) / start * guess)
                    if mod == 0:
                        mod = 1
                    guess -= mod
            else:
                mod = int(difference / start * guess)
                if mod == 0:
                    mod = 1
                guess += mod
        else:
            print "payment is %s" % guess
            return evolution(start, guess, interest, months)

Evolution은 대출이 지불 및이자이자에 대한 지불 및이자이자에 대한이자에 대한이자 금액 등을 나타내는 방식을 나타내는 기능 일뿐입니다.

예를 들어, $ 100K로 시작하여 대출에 대한 월별 지불금을 8%, 70 개월의 기간으로 $ 50K로 끝나는 경우

>>> find_payment(100000, 50000, 70, 0.08)
payment is 1363

위의 경우 나는 49935로 끝나고 5 번 루프를 통과했습니다. 루프를 통과하는 데 필요한 시간은 금액에 얼마나 가까이 가고 싶은지에 따라 다르며 약간 다양합니다.

도움이 되었습니까?

해결책

이것은 기본적으로 a입니다 모기지 상환 계산.

시작이 종말보다 크고이자가 0과 1 사이라고 가정합니다 (예 : 10%이자의 경우 0.1)

먼저 지불하고자하는 지불의 일부를 고려하십시오.

Principal = start - end

월별 지불은 다음과 같이 제공됩니다.

pay_a = (interest / 12) / (1 - (1+interest/12) ^ (-months))) * Principal

그런 다음 추가 관심사를 고려해야합니다. 이는 월간이자의 나머지 원금 시간과 동일합니다.

pay_b = interest / 12 * end

그래서 총 지불은입니다

payment = (interest / 12) * (1 / (1 - (1+interest/12) ^ (-months))) * Principal + end)

당신이 준 예에서

Start: 100000
End:  50000
Months: 70
Interest: 8% 
pay_a = 896.20
pay_b = 333.33
Payment = 1229.54

이 값을 Excel에서 테스트했을 때 70 번의 지불 후 Remaing Loan은 50,000이었습니다. 이것은 매달 지불하기 전에 명목에 대한이자를 지불한다고 가정합니다.

다른 팁

아마도 이것에 대해 생각하는 가장 쉬운 방법은 대출을 두 부분으로 나누는 것입니다. 한 부분은 전체적으로 상환되는 부분과 다른 부분은 아무것도 지불하지 않는 부분입니다. 이미 첫 번째 부분에 대한 월 수수료를 계산했습니다.

매월의이자를 계속 지불 할 수 있습니다. 그런 다음, 당신은 같은 amont를 빚지고 있습니다.

Owe_1 = a

Int_2 = Owe_1*(InterestRate/12)
Pay_2 = Int_2
Owe_2 = Owe_1 + Int_2 - Pay_2 # ==> Owe_1 + Int_2 - Int_2 = Owe_1

Int_3 = Owe_2*(InterestRate/12)
Pay_3 = Int_3
Owe_3 = Owe_2 + Int_3 - Pay_3 # ==> Owe_2 + Int_3 - Int_3 = Owe_2 = Owe_1

EMI를 계산하는 파이썬 코드

class EMI_CALCULATOR(object):
 # Data attributes
 # Helps to calculate EMI

  Loan_amount = None # assigning none values
  Month_Payment = None # assigning none values
  Interest_rate = None #assigning none values
  Payment_period = None #assigning none values

  def get_loan_amount(self):
 #get the  value of loan amount
      self.Loan_amount = input("Enter The Loan amount(in rupees) :")
      pass

  def get_interest_rate(self):
   # get the value of interest rate
      self.Interest_rate = input("Enter The Interest rate(in percentage(%)) : ")
      pass

  def get_payment_period(self):
   # get the payment period"
      self.Payment_period = input("Enter The Payment period (in month): ")
      pass


  def calc_interest_rate(self):
  # To calculate the  interest rate"
      self.get_interest_rate()

      if self.Interest_rate > 1:
         self.Interest_rate = (self.Interest_rate /100.0) 

      else:
         print "You have not entered The interest rate correctly ,please try again "
      pass

  def calc_emi(self):
  # To calculate the EMI"          

      try:

        self.get_loan_amount() #input loan amount 
        self.get_payment_period() #input payment period
        self.calc_interest_rate() #input interest rate and calculate the interest rate

      except NameError:
             print "You have not entered Loan amount (OR) payment period (OR) interest rate  correctly,Please enter and try again. "

      try:
        self.Month_Payment = (self.Loan_amount*pow((self.Interest_rate/12)+1,
                             (self.Payment_period))*self.Interest_rate/12)/(pow(self.Interest_rate/12+1,
                             (self.Payment_period)) - 1)

      except ZeroDivisionError: 
                    print "ERROR!! ZERO DIVISION ERROR , Please enter The Interest rate correctly and Try again."

      else:
         print "Monthly Payment is : %r"%self.Month_Payment
      pass


  if __name__ == '__main__':# main method 

        Init = EMI_CALCULATOR() # creating  instances


        Init.calc_emi() #to calculate EMI

자세한 정보는 다음과 같습니다. https://emilgeorgejames.wordpress.com/2015/07/29/python-emi-equated-nthly-installment-calculator/

이것은 다소 상세한 방법이지만 전체 지불도 제공 할 것입니다.

# Mortgage Loan that gives the balance and total payment per year

# Function that gives the monthly payment
def f1 (principle,annual_interest_rate,duration):
    r = annual_interest_rate/1200
    n = duration*12
    a=principle*r*((1+r)**n)
    b= (((1+r)**n)- 1)
    if r > 0 :
        MonthlyPayment = (a/b)
    else :
        MonthlyPayment = principle/n

    return MonthlyPayment

# Function that gives the balance
def f2 (principle,annual_interest_rate,duration,number_of_payments):
    r = annual_interest_rate/1200
    n = duration*12
    a= ((1+r)**n)
    b= ((1+r)**number_of_payments)
    c= (((1+r)**n)-1)
    if r > 0 :
        RemainingLoanBalance = principle*((a-b)/c)
    else :
        RemainingLoanBalance = principle*(1-(number_of_payments/n))

    return RemainingLoanBalance
# Entering the required values
principle=float(input("Enter loan amount: "))
annual_interest_rate=float(input("Enter annual interest rate (percent): "))
duration=int(input("Enter loan duration in years: "))

# Output that returns all useful data needed
print ("LOAN AMOUNT:",principle,"INTEREST RATE (PERCENT):",annual_interest_rate)
print ("DURATION (YEARS):",duration,"MONTHLY PAYMENT:",int(f1(principle,annual_interest_rate,duration)))


k=duration+1
BALANCE=principle
total=0
for i in range (1,k):
    TOTALPAYMENT= f1(BALANCE,annual_interest_rate,k-i)*12
    total+= TOTALPAYMENT
    BALANCE= f2(principle,annual_interest_rate,duration,12*i)
    print("YEAR:",i,"BALANCE:",int(BALANCE),"TOTAL PAYMENT",int(total))

이건 어때?

def EMI_calc(principle, rate, time, frequency):
    return (principle / ((1-((1+(rate/frequency))**(-1*(time*frequency))))/(rate/frequency)))

print("""
----- Welcome to EMI programe for Python -----
""")
print("\n You have chosen to know the EMI for Loan.\n")
input('\nTo Continue Press ENTER --- to ABORT Press ctrl+c > \n')

print("\nPlease Enter amount of Loan to be taken: >\n")
principle = int(input())
print("\nEnter rate of interst (%): >\n")
rate = float(input())/100
print("\nEnter Term (Years): >\n")
time = float(input())
print("\nPlease enter the frequency of installments) : >\n")
frequency = int(input())

EMI = round(EMI_calc(principle, rate, time, frequency),0)

print("""

---------------------------------------------------------------------

""")
print(f"""
The EMI for Loan of Rs.{principle};
at interest rate of {rate*100} % for {time} years;
would be: Rs.""", EMI)

print("""

---------------------------------------------------------------------

""")

다음은 Numpy 기능을 사용하는 코드 스 니펫입니다. 이것은 매달 지불, 교장,이자, 할부 및 Total_amount를 보여줍니다. 그것을 실행하고 출력을보십시오. 인수에 대한 자세한 설명을 위해 Excel "ipmt ()"및 "ppmt ()"함수의 구문을 확인할 수도 있습니다.https://docs.scipy.org/doc/numpy-1.13.0/reference/generated/numpy.pmt.html#numpy.pmt

import math
import numpy as np
rate = 0.08
start_amount = 100000.0
end_amount = 50000.0
diff_amount = start_amount - end_amount
# nr_years = 4
payment_frequency = int (12)
nr_months = 70 # = nr_years * payment_frequency
per_np = np.arange (nr_months) + 1 # +1 because index starts with 1 here
pay_b = rate / payment_frequency * end_amount
ipmt_np = np.ipmt (rate / payment_frequency, per_np, nr_months, diff_amount) - pay_b
ppmt_np = np.ppmt (rate / payment_frequency, per_np, nr_months, diff_amount)
for payment in per_np:
    idx = payment - 1
    principal = math.fabs (ppmt_np [idx])
    start_amount = start_amount - principal
    interest = math.fabs (ipmt_np [idx])
    instalment = principal + interest
    print payment, "\t", principal, "\t", interest, "\t\t", instalment, "\t\t", start_amount
print np.sum (ipmt_np)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top