xirr package

Submodules

xirr.math module

xirr.math.cleanXirr(valuesPerDate: dict[datetime.date, float]) Optional[float][source]

A “cleaned” version of the xirr which avoids returning a xirr for some extreme cases and ignores amounts which are almost 0.

xirr.math.listsXirr(dates: list[datetime.date], values: list[float], whichXirr: typing.Callable[[dict[datetime.date, float]], typing.Optional[float]] = <function xirr>) Optional[float][source]

A convenience function that takes two lists of dates and values rather than a combined dictionary.

Use whichXirr to select the actuall xirr function to use.

Anti-pattern: Using a simple dictionary comprehension would not work, e.g. xirr({d: v for d, v in zip(dates, values)}) Because this overwrites entries with identical dates.

xirr.math.xirr(valuesPerDate: dict[datetime.date, float]) Optional[float][source]

Calculate the irregular internal rate of return.

>>> from datetime import date
>>> valuesPerDate = {date(2019, 12, 31): -80005.8, date(2020, 3, 12): 65209.6}
>>> xirr(valuesPerDate)
-0.645363882724717
xirr.math.xnpv(valuesPerDate: dict[datetime.date, float], rate: float) float[source]

Calculate the irregular net present value.

>>> from datetime import date
>>> valuesPerDate = {date(2019, 12, 31): -100, date(2020, 12, 31): 110}
>>> xnpv(valuesPerDate, -0.10)
22.257507852701295

Module contents