PyXIRR Financial Functions

0.10.8 · active · verified Sun Apr 12

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.

Warnings

Install

Imports

Quickstart

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}")

view raw JSON →