Paul McGuire wrote: > Here's > a simple loan amortization schedule generator: > > def amortizationSchedule( principal, term, rate ): > pmt = ( principal * rate * ( 1 + rate)**term ) / (( 1 + rate)**term - 1)
Simpliciter: pmt = principal * rate / (1 - (1 + rate)**(-term)) > pmt = round(pmt,2) # people rarely pay in fractional pennies > remainingPrincipal = principal > for pd in range(1,term+1): > if pd < term: > pdInterest = rate * remainingPrincipal > pdInterest = round(pdInterest,2) > pdPmt = pmt > else: Huh? You don't charge interest in the last period? I'd like to apply for a loan of $1B for a term of one month with monthly repayments. > pdInterest = 0 > pdPmt = remainingPrincipal > pdPrincipal = pdPmt - pdInterest > remainingPrincipal -= pdPrincipal > yield pd, pdPmt, pdInterest, pdPrincipal, remainingPrincipal > -- http://mail.python.org/mailman/listinfo/python-list