tvm.py

Created by cesphoto

Created on December 13, 2021

997 Bytes

TVM Solver: Time Value of Money Solver. Solves for PMT, FV, PV, or N. Run tvm() or press the var button and select tvm(). Select the variable to solve for, and the inputs are similar to the TI calculators.


from math import *
def tvm():
  print("Select variable to solve:")
  print("1:PMT 2:FV 3:PV 4:N")
  solv=int(input("?"))
  
  if solv != 4:
    N=int(input("  N= "))
    
  r=float(input(" I%= "))
  
  if solv != 3:
    pv=float(input(" PV= "))
  
  if solv != 1:
    pmt=float(input("PMT= "))
  
  if solv != 2:
    fv=float(input(" FV= "))
  
  ppy=int(input("P/Y= "))
  
  if r > 1:
    r=r/100
    
  if solv == 1:
    pmt=-r/ppy*(fv+pv*(1+r/ppy)**N)/((1+r/ppy)**N-1)
    print("")
    print("Periodic Payment:")
    print("pmt=",pmt)
    
  if solv == 2:
    fv=(ppy*pmt-ppy*pmt*(1+r/ppy)**N-pv*r*(1+r/ppy)**N)/r
    print("")
    print("Future Value:")
    print("FV=",fv)
    
  if solv == 3:
    pv=((1+r/ppy)**(-N)*(ppy*pmt-fv*r-ppy*pmt*(1+r/ppy)**N)/r)
    print("")
    print("Present Value:")
    print("PV=",pv)
    
  if solv == 4:
      N=log((ppy*pmt-fv*r)/(ppy*pmt+pv*r))/log(1+r/ppy)
      print("")
      print("Number of Payments:")
      print("N=",N)
      
      

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 cookies policy.