Rust-powered collection of financial functions for Python.
Project description
PyXIRR
Rust-powered collection of financial functions for Python.
Features:
- correct
- blazingly fast
- works with iterators
- works with unordered input
- no external dependencies
Installation
pip install pyxirr
Benchmarks
Rust implementation has been tested against existing xirr package (uses scipy.optimize under the hood) and the implementation from the Stack Overflow (pure python).
PyXIRR is ~10-20x faster in XIRR calculation. More than 10x faster than numpy-financial.
Powered by github-action-benchmark and plotly.js.
Live benchmarks are hosted on Github Pages.
Examples
from datetime import date
from pyxirr import xirr
dates = [date(2020, 1, 1), date(2021, 1, 1), date(2022, 1, 1)]
amounts = [-1000, 1000, 1000]
# feed columnar data
xirr(dates, amounts)
# feed iterators
xirr(iter(dates), (x for x in amounts))
# feed an iterable of tuples
xirr(zip(dates, amounts))
# feed a dictionary
xirr(dict(zip(dates, amounts)))
Numpy and Pandas support
import numpy as np
import pandas as pd
# feed numpy array
xirr(np.array([dates, amounts]))
xirr(np.array(dates), np.array(amounts))
# feed DataFrame (columns names doesn't matter; ordering matters)
xirr(pd.DataFrame({"a": dates, "b": amounts}))
API reference
See the docs
Roadmap
- NumPy support
- XIRR
- XNPV
- NPV
- IRR
- FV
- PV
- MIRR
- Improve docs, add more tests
- other functions from numpy-financial
Development
Running tests with pyo3 is a bit tricky. In short, you need to compile your tests without extension-module
feature to avoid linking errors.
See the following issues for the details: #341, #771.
If you are using pyenv
, make sure you have the shared library installed (check for ${PYENV_ROOT}/versions/<version>/lib/libpython3.so
file).
$ PYTHON_CONFIGURE_OPTS="--enable-shared" pyenv install <version>
Install dev-requirements
$ pip install -r dev-requirements.txt
Building
$ maturin develop
Testing
$ LD_LIBRARY_PATH=${PYENV_ROOT}/versions/3.8.6/lib cargo test --no-default-features
Building and distribution
This library uses maturin to build and distribute python wheels.
$ docker run --rm -v $(pwd):/io konstin2/maturin build --release --manylinux 2010 --strip
$ maturin upload target/wheels/pyxirr-${version}*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file pyxirr-0.5.2.tar.gz
.
File metadata
- Download URL: pyxirr-0.5.2.tar.gz
- Upload date:
- Size: 198.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b4b9652e8fbbe8af03ea32abd11b2a3f830c74150cc464be02ca70a90cc6630 |
|
MD5 | 7399d0609d88da294cb6bde5e89f7a23 |
|
BLAKE2b-256 | 923c556ddb67755f82dfea420a898ae6f1f22465e16e00aba991170c155b3237 |
File details
Details for the file pyxirr-0.5.2-cp39-none-win_amd64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp39-none-win_amd64.whl
- Upload date:
- Size: 122.3 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3abb9ac3d6cec772e9cca02dabb933cc7a91653f99057e16f38da41585927d3 |
|
MD5 | f0e46f7b8bf7a506e6769c88825483e9 |
|
BLAKE2b-256 | 1503c6aae5b97c1ba5fae7c2ece8b89e4d998ba5dfb207aa9ea97af27990dbfc |
File details
Details for the file pyxirr-0.5.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 179.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de4ae55738f1afeb822600b45f940b067edbe91a774397bd1712125f73ec2e83 |
|
MD5 | 2118025c0b1afd50c72b9ccbb27650fc |
|
BLAKE2b-256 | 9607d211fe29b68cd1f4f09ad79640a09d2231315c80904622ba52909f3a401c |
File details
Details for the file pyxirr-0.5.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 339.3 kB
- Tags: CPython 3.9, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c05980cf70a228019545179ae328362a2c6a6fc2241f9d1cfdadd7620d79667f |
|
MD5 | 5be02c51829cd9c83977ed5d42ad627e |
|
BLAKE2b-256 | 340cba97a53f704fd09d0c6c7c3a17d93b60f5e0008ad38e1226633cc2d3cee1 |
File details
Details for the file pyxirr-0.5.2-cp38-none-win_amd64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp38-none-win_amd64.whl
- Upload date:
- Size: 122.3 kB
- Tags: CPython 3.8, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdd3767728976bbf3e30e571c520f13025bbbded9a2515188449415e592b3050 |
|
MD5 | eed1501101220ec0138b37eae01e511b |
|
BLAKE2b-256 | 2f2dea3064408e5c0e04ce80596a0d818cc237e2f4646382e435a86cbadaef26 |
File details
Details for the file pyxirr-0.5.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 179.9 kB
- Tags: CPython 3.8, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | da7f1adcc95b601c0876967f76c33897adf41559c9a006466d6d5789be7dd900 |
|
MD5 | 01282306aa21eaa2928a6c87b2535215 |
|
BLAKE2b-256 | 3902cda162c2df646e5d19247ad07f83003df14df2d6a05383c26d8ce4c300de |
File details
Details for the file pyxirr-0.5.2-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 339.4 kB
- Tags: CPython 3.8, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bcdcb3bce5fffa54e495ddb2c77ce753a0da9946bf2c185f8b60885c5773485 |
|
MD5 | acc7f218743c9bfea15c3d62c139585d |
|
BLAKE2b-256 | 2d06b801821e15ce9c2ec1b15d15f8330f69e18692ad8285fdb81596d92b9448 |
File details
Details for the file pyxirr-0.5.2-cp37-none-win_amd64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp37-none-win_amd64.whl
- Upload date:
- Size: 122.3 kB
- Tags: CPython 3.7, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 699c7d84640b0cf374262f56797e4e2902608f52d2d1b5b18e82281a6b3dce82 |
|
MD5 | 04eb3d8b4d9da65853cbb421a7281f79 |
|
BLAKE2b-256 | 96f78e70de6412d7ae6b87c051f3f0d03e8ac6effdda44d0519234f6fb1248bd |
File details
Details for the file pyxirr-0.5.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 179.9 kB
- Tags: CPython 3.7m, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed3a9e2281951b4f7162f881c6710040552a375a4834c78896d1997efe4dac2e |
|
MD5 | 9f2bbfa5b7025b9ba93071c5aabc15bf |
|
BLAKE2b-256 | 0cb57d408ae096146b21bfc0cf62992a140bdc5f89373567b27fc2af7d4a5ef4 |
File details
Details for the file pyxirr-0.5.2-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 339.4 kB
- Tags: CPython 3.7m, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23790f78f66598a9f38a238e04c9210936982816b8ae129e4a7579a5d0ed6181 |
|
MD5 | 6e590cd3e6682ad803a44b37489361ed |
|
BLAKE2b-256 | 4a62a58cd7f9212f4f72f522f616b0ee9df6af26826e7c9b998c788ac0195ef9 |
File details
Details for the file pyxirr-0.5.2-cp36-none-win_amd64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp36-none-win_amd64.whl
- Upload date:
- Size: 122.3 kB
- Tags: CPython 3.6, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a40c9d62015551633629da13aa32c4768811071693ba3c95b15aab748d73658 |
|
MD5 | 5724eb46742160bddd17e0851c935c79 |
|
BLAKE2b-256 | 4ccacd71a8a40b4cc31868b809517544fe8eb4b22b0f04b6646796c87e6438cb |
File details
Details for the file pyxirr-0.5.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
- Upload date:
- Size: 180.0 kB
- Tags: CPython 3.6m, manylinux: glibc 2.5+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30d98cb64f21f67721a41188657895f281b8598c6780d1797c36b582fbebd736 |
|
MD5 | 70a7f110270d97eb14ef36ec9e3e531d |
|
BLAKE2b-256 | f3b6eb9a919a615c97181f0c9bde981905c223ee65b9ea80ce70cee732844ae4 |
File details
Details for the file pyxirr-0.5.2-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
.
File metadata
- Download URL: pyxirr-0.5.2-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
- Upload date:
- Size: 339.5 kB
- Tags: CPython 3.6m, macOS 10.9+ universal2 (ARM64, x86-64), macOS 10.9+ x86-64, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/0.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6eafb7f731c7a95dcc60e1475f2a2d22e3fc3ba1cd9d13b5e6d8da73794b78e2 |
|
MD5 | f75ffe51642a71b901cf1c351fce6142 |
|
BLAKE2b-256 | 0c30ca6a78ec5f46cce044084c4ff8e51d8378f707bc7818d78c8d3e6da88234 |