Finance Functions: Python Script Edward Shore - 4/12/2020
# 2020-04-12 EWS from math import * # percent change def pchg(old,new): pch=(new-old)/old*100 return pch # add sales tax def taxplus(amt,tax): total=amt*(1+0.01*tax) return round(total,2) # uniform pv factor pv=pmt*uspv def uspv(n,i): factor=(1-(1+0.01*i)**(-n))/(0.01*i) return factor # uniform fv factor fv=pmt*usfv def usfv(n,i): factor=((1+0.01*i)**n-1)/(0.01*i) return factor # monthly payment def mopmt(yrs,rate,loan): pymt=loan/uspv(yrs*12,rate/12) return round(pymt,2) # equivalent annual rate def annrate(ppy,cpy,rate): irate=cpy*100*((1+0.01*rate)**(ppy/cpy)-1) return irate # sinking fund def sinkfund(yrs,rate,pymt): sink=pymt*usfv(yrs*12,rate/12) return round(sink,2) # piti def piti(yrs,rate,loan,tax,insur): pymt=loan/uspv(yrs*12,rate/12)+(tax+insur)/12 return round(pymt,2) # qualifying income 28:36 ratio def qualinc(inc,debt,taxins,rate,yrs): a=min(inc*0.36-debt,inc*0.28)-taxins qual=a*uspv(yrs*12,rate/12) return round(qual,2)