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 pyxirrVerified import paths — ran on the pinned version, not inferred.
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.
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)`.
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.
If exact Excel compatibility for `npv` is required, use the `start_from_zero=False` parameter: `pyxirr.npv(rate, values, start_from_zero=False)`.
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.
Install the module using pip: 'pip install pyxirr'.
Ensure you have the latest version of pyxirr installed: 'pip install --upgrade pyxirr'.
Check the input data to ensure all required fields are provided and correctly formatted.
Verify that the cashflows list includes at least one positive and one negative value.
Use the correct function name, such as 'xirr', provided by the 'pyxirr' module.