{"id":4736,"library":"pyxirr","title":"PyXIRR Financial Functions","description":"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.","status":"active","version":"0.10.8","language":"en","source_language":"en","source_url":"https://github.com/Anexen/pyxirr","tags":["finance","xirr","xnpv","financial-functions","rust-bindings","performance","investment"],"install":[{"cmd":"pip install pyxirr","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Optional, for numpy array input types and vectorized operations.","package":"numpy","optional":true},{"reason":"Optional, for pandas DataFrame and Series input types.","package":"pandas","optional":true}],"imports":[{"symbol":"xirr","correct":"from pyxirr import xirr"},{"note":"Used for specifying day count conventions like ACT_360 or 30E/360.","symbol":"DayCount","correct":"from pyxirr import DayCount"},{"symbol":"All functions (e.g., fv, npv)","correct":"import pyxirr\npyxirr.fv(...)"}],"quickstart":{"code":"from datetime import date\nfrom pyxirr import xirr\n\ndates = [\n    date(2020, 1, 1),\n    date(2021, 1, 1),\n    date(2022, 1, 1)\n]\namounts = [-1000, 750, 500]\n\n# Calculate XIRR with columnar data\nresult = xirr(dates, amounts)\nprint(f\"Calculated XIRR: {result:.4f}\")\n\n# XIRR also accepts iterables of tuples or pandas DataFrames\n# from pyxirr import xnpv\n# npv_result = xnpv(0.05, dates, amounts)\n# print(f\"Calculated XNPV: {npv_result:.2f}\")","lang":"python","description":"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."},"warnings":[{"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)`.","message":"XIRR 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.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"All versions"},{"fix":"If exact Excel compatibility for `npv` is required, use the `start_from_zero=False` parameter: `pyxirr.npv(rate, values, start_from_zero=False)`.","message":"The `npv` function in PyXIRR defaults to starting from zero (NumPy compatible). Excel's `NPV` function, however, typically starts summation from the first period.","severity":"gotcha","affected_versions":"All versions"},{"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.","message":"While 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.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}