I have a Panadas dataframe which encompasses 4 columns (company, price today, cash flow y1, cash flow y2, cash flow y3 (i.e. a terminal value)):
Code | Price | 0 | 1 | 2 |
---|---|---|---|---|
GOOGL-US | -2380 | 0 | 0 | 4074.94 |
AMZN-US | -3265 | 0 | 0 | 5765.09 |
FB-US | -327 | 0 | 0 | 513.819 |
etc for ~100 tickers
Is there a way to do a simple IRR calc using the data from the columns price, 0, 1, 2 as at annual periods (i.e. t0, t1, t2, t3)
?
Thank you!
I don't have concrete solution but could give you some hint and direction to look for. There had been a Numpy function
Numpy.irr()
supporting IRR calculation in Numpy / Pandas. However, it had been deprecated since Numpy version 1.18 and moved to separate module at NumPy Financial where you can still install it e.g. by:Then use it as, e.g.
You can refer to this article Calculating IRR in Python for some usage examples.