atoti.experimental.finance.irr module#
- atoti.experimental.finance.irr(*, cash_flows, market_value, date, precision=0.001)#
Return the Internal Rate of Return based on the underlying cash flows and market values.
The IRR is the rate
r
that nullifies the Net Present Value:With:
the total number of days since the beginning the number of days since the beginning for date the enhanced cashflow for dateCF of the first day is the opposite of the market value for this day:
.CF of the last day is increased by the market value for this day:
.Otherwise CF is the input cash flow:
.
This equation is solved using the Newton’s method.
- Parameters:
cash_flows (NonConstantMeasureConvertible) – The measure representing the cash flows.
market_value (NonConstantMeasureConvertible) – The measure representing the market value, used to enhanced the cashflows first and last value. If the cash flows don’t need to be enhanced then
0
can be used.date (Hierarchy) – The date hierarchy. It must have a single date level.
precision (float) – The precision of the IRR value.
- Return type:
MeasureDescription
See also
The IRR Wikipedia page.
Example
With the following data:
Date
MarketValue
CashFlows
2020-01-01
1042749.90
2020-01-02
1099720.01
2020-01-03
1131220.24
2020-01-04
1130904.32
2020-01-05
1748358.77
-582786.257893061
2020-01-06
1791552.54
The IRR can be defined like this:
m["irr"] = irr(cash_flows=m["CashFlow.SUM"], market_value=m["MarketValue.SUM"], date=h["Date"]) cube.query(m["irr"]) >>> 0.14397