The Maxwell School
Syracuse University
Syracuse University
""" irr.py Spring 2022 PJW Compute the NPV of several cash flows stored as text files. """ import scipy.optimize as opt import npvtools as nt # # Define a function to do all the work for a given file # def analyze(filename): # Read the cash flow cashflow = nt.read_cashflow(filename,splitter=',') # Compute its NPV at 5% npv = nt.npv(0.05,cashflow)/1e6 # Compute the IRR of the cash flow irr = opt.newton( nt.npv, 0.05, maxiter=20, args=[cashflow])*100 # Print all the results print(f"\nfile {filename}:") print(f" NPV at 5% = ${round(npv,1)}M, IRR = {round(irr,1)}%") # Return the NPV return npv # # Call the function on each of the files. # files = ['std_notax.csv','std_tax.csv','std_ev.csv','ccs.csv'] for filename in files: analyze(filename)