finance.py

Created by ews31415

Created on April 12, 2020

1018 Bytes

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)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our <a href="https://www.numworks.com/legal/cookies-policy/">cookies policy</a>.