Registry / data / pyxirr

pyxirr

JSON →
library0.10.8pypypi✓ verified 24d ago

PyXIRR is a Rust-powered Python library offering a fast and precise collection of financial functions, including XIRR, XNPV, IRR, FV, NPV, and more. It is actively maintained with frequent minor releases, currently at version 0.10.8.

pip install pyxirr
INSTALL
IMPORT
SIG · PYXIRR
P
pyxirr
datapythonv0.10.8
Install
1.7s avg
Import
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.10.8 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 19.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.000s · 20MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

xirr
from pyxirr import xirr
DayCount
from pyxirr import DayCount
Used for specifying day count conventions like ACT_360 or 30E/360.
All functions (e.g., fv, npv)
import pyxirr pyxirr.fv(...)

This example demonstrates how to calculate the Extended Internal Rate of Return (XIRR) using a list of dates and corresponding cash flow amounts. PyXIRR functions can accept various input formats, including separate lists, iterables of tuples, NumPy arrays, or pandas DataFrames.

from datetime import date from pyxirr import xirr dates = [ date(2020, 1, 1), date(2021, 1, 1), date(2022, 1, 1) ] amounts = [-1000, 750, 500] # Calculate XIRR with columnar data result = xirr(dates, amounts) print(f"Calculated XIRR: {result:.4f}") # XIRR also accepts iterables of tuples or pandas DataFrames # from pyxirr import xnpv # npv_result = xnpv(0.05, dates, amounts) # print(f"Calculated XNPV: {npv_result:.2f}")
Debug
Known issues
gotchaXIRR calculation requires both positive and negative cash flows. If a series of cash flows contains only positive or only negative values, the `xirr` function will raise an exception.
fix
Ensure your input cash flows include at least one positive and one negative value. You can suppress the exception by using the `silent=True` parameter: `xirr(dates, amounts, silent=True)`.
affects: All versions
gotchaThe Multiple IRR problem can occur when cash flow signs change more than once. PyXIRR attempts to find a solution around a default guess (0.1, similar to Excel) and, if unsuccessful, tries other attempts, ultimately selecting the lowest IRR to be conservative.
fix
Be aware of this behavior for non-conventional cash flow series. If specific IRR solutions are expected, manual inspection or alternative initial guesses might be necessary, though PyXIRR's approach often yields a reasonable result.
affects: All versions
gotchaThe `npv` function in PyXIRR defaults to starting from zero (NumPy compatible). Excel's `NPV` function, however, typically starts summation from the first period.
fix
If exact Excel compatibility for `npv` is required, use the `start_from_zero=False` parameter: `pyxirr.npv(rate, values, start_from_zero=False)`.
affects: All versions
gotchaWhile PyXIRR provides high performance, it might have a 'certain conversion cost' compared to direct NumPy operations, especially when passing large amounts of data between Python and the Rust core.
fix
For optimal performance with large datasets, consider passing data in formats that minimize conversion overhead, such as NumPy arrays or pandas DataFrames, as PyXIRR is optimized to work efficiently with these.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'pyxirr'
The 'pyxirr' module is not installed in the Python environment.
fix
Install the module using pip: 'pip install pyxirr'.
ImportError: cannot import name 'xirr' from 'pyxirr'
The function 'xirr' is not available in the 'pyxirr' module, possibly due to an outdated version.
fix
Ensure you have the latest version of pyxirr installed: 'pip install --upgrade pyxirr'.
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'
A None value is being added to a float, likely due to missing or incorrect input data.
fix
Check the input data to ensure all required fields are provided and correctly formatted.
ValueError: cashflows must contain at least one positive and one negative value
The cashflows provided to the function do not include both positive and negative values, which is required for IRR calculations.
fix
Verify that the cashflows list includes at least one positive and one negative value.
AttributeError: module 'pyxirr' has no attribute 'calculate_irr'
The function 'calculate_irr' does not exist in the 'pyxirr' module, possibly due to a typo or incorrect function name.
fix
Use the correct function name, such as 'xirr', provided by the 'pyxirr' module.
Upgrade
Version history
0.10.8latest on PyPI · released Nov 3, 2025
Audit
Dependencies
numpyoptionalOptional, for numpy array input types and vectorized operations.
pandasoptionalOptional, for pandas DataFrame and Series input types.
Agent activity
15 hits · last 30 days
node
10
Resources
pyxirr — pip install pyxirr · libregistry