I am looking for a financial library for Python that will enable me to do a discounted cash flow analysis. I have looked around and found the QuantLib, which is overkill for what I want to do. I just need a small library that I can use to input a series of cash flows and have it output a net present value and internal rate of return. Anyone have something like this or know where I can find it?
numpy - NumPy is the fundamental package for scientific computing with Python. It is a first-rate library for numerical programming and is widely used in academia, finance, and industry.
Python is an ideal programming language for the financial industry. Widespread across the investment banking and hedge fund industries, banks are using Python to solve quantitative problems for pricing, trade management, and risk management platforms.
Financial modeling using Python is a method of building a model using the Python programming language. The language allows coders to modify and analyze Excel spreadsheets and automate certain tasks.
The Python Standard Library contains the exact syntax, semantics, and tokens of Python. It contains built-in modules that provide access to basic system functionality like I/O and some other core modules. Most of the Python Libraries are written in the C programming language.
Just for completeness, since I'm late: numpy has some functions for (very) basic financial calculations. numpy, scipy could also be used, to do the calculations from the basic formulas as in R.
net present value of cashflow
>>> cashflow = 2*np.ones(6)
>>> cashflow[-1] +=100
>>> cashflow
array([ 2., 2., 2., 2., 2., 102.])
>>> np.npv(0.01, cashflow)
105.79547647457932
get internal rate or return
>>> n = np.npv(0.01, cashflow)
>>> np.irr(np.r_[-n, cashflow])
0.010000000000000231
just the basics:
>>> [f for f in dir(np.lib.financial) if not f[0] == '_']
['fv', 'ipmt', 'irr', 'mirr', 'np', 'nper', 'npv', 'pmt', 'ppmt', 'pv', 'rate']
and it's necessary to watch out what the timing is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With