Skip to main content

Rust-powered collection of financial functions for Python.

Project description

rust-lang.org License pypi versions

PyXIRR

Rust-powered collection of financial functions.

Features:

  • correct
  • blazingly fast
  • works with iterators
  • works with unordered input
  • no external dependencies

PyXIRR contains many functions from numpy-financial, such as IRR, NPV, etc.

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).

bench

PyXIRR is ~10-20x faster in XIRR calculation than another implementations.

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

  • Improve docs, add more tests
  • Other functions from numpy-financial
  • Compile library for rust/javascript/python

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 --features tests

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyxirr-0.6.1.tar.gz (78.5 kB view details)

Uploaded Source

Built Distributions

pyxirr-0.6.1-cp39-none-win_amd64.whl (128.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

pyxirr-0.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (183.1 kB view details)

Uploaded CPython 3.9 manylinux: glibc 2.5+ x86-64

pyxirr-0.6.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (346.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

pyxirr-0.6.1-cp38-none-win_amd64.whl (128.7 kB view details)

Uploaded CPython 3.8 Windows x86-64

pyxirr-0.6.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (183.1 kB view details)

Uploaded CPython 3.8 manylinux: glibc 2.5+ x86-64

pyxirr-0.6.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (346.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

pyxirr-0.6.1-cp37-none-win_amd64.whl (128.7 kB view details)

Uploaded CPython 3.7 Windows x86-64

pyxirr-0.6.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (183.1 kB view details)

Uploaded CPython 3.7m manylinux: glibc 2.5+ x86-64

pyxirr-0.6.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (346.4 kB view details)

Uploaded CPython 3.7m macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

pyxirr-0.6.1-cp36-none-win_amd64.whl (128.9 kB view details)

Uploaded CPython 3.6 Windows x86-64

pyxirr-0.6.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (183.5 kB view details)

Uploaded CPython 3.6m manylinux: glibc 2.5+ x86-64

pyxirr-0.6.1-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl (346.4 kB view details)

Uploaded CPython 3.6m macOS 10.9+ universal2 (ARM64, x86-64) macOS 10.9+ x86-64 macOS 11.0+ ARM64

File details

Details for the file pyxirr-0.6.1.tar.gz.

File metadata

  • Download URL: pyxirr-0.6.1.tar.gz
  • Upload date:
  • Size: 78.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.11.2

File hashes

Hashes for pyxirr-0.6.1.tar.gz
Algorithm Hash digest
SHA256 c3cd08d9febe230af1a13c19b39e448f747c11bf273ce19b0df5d9bab1513bcd
MD5 cf3a9cc3d4db3bd11fe1206744418cfe
BLAKE2b-256 4b494c4780e4e6eec7f1878edbd690da3032f06b965365aca815b6e98a429cc2

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp39-none-win_amd64.whl.

File metadata

  • Download URL: pyxirr-0.6.1-cp39-none-win_amd64.whl
  • Upload date:
  • Size: 128.7 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.11.2

File hashes

Hashes for pyxirr-0.6.1-cp39-none-win_amd64.whl
Algorithm Hash digest
SHA256 5b816f032302ebcbcc9c99b07fdc2dac504ce1d3634916104ce6f0a5ec75c6e5
MD5 139af0e81d0db07cf80072b6e8525043
BLAKE2b-256 51ce3a149920ad79297cf21b111e2cb93f4ea7590f5179d532a0422b6c6e6af1

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3bbc1e2bf8334dbeb9ea14a0dd7799809d78e0851160d4a363c80a595604b164
MD5 1c7c82757569e5ee63aa2772cc8883e0
BLAKE2b-256 25c4164fe205d15817710a72da267ff7f4bfa77144b747247dfc1e8d871cc545

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp39-cp39-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c209200ec2f7828fdb8cab7dee1472e72b465c50a9b5389c7d48b9a60f8aab3b
MD5 3719d8d7691636094362faed28a806cd
BLAKE2b-256 c4e59e1f5bd5d32d2f28b2560b1bb402bba38f9c7873cbfb26025dcd8bd0fd9f

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp38-none-win_amd64.whl.

File metadata

  • Download URL: pyxirr-0.6.1-cp38-none-win_amd64.whl
  • Upload date:
  • Size: 128.7 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.11.2

File hashes

Hashes for pyxirr-0.6.1-cp38-none-win_amd64.whl
Algorithm Hash digest
SHA256 a8fee0e7a8e5d101261af1e23676fdbd9a5d54b41f236f31146f19a3974c7dae
MD5 fee5dae2dc1f1cade309a5538c1bf020
BLAKE2b-256 02132d811c846e5437aea49d1d36770348560ffd8eb5a62d7a715b5f1a2b0ba8

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 61ac143eb0d72f1012fa51b3c7e3764137165f338ea1e88463789e5344061b1c
MD5 e804417487aa1076c1ca3967d0f804ab
BLAKE2b-256 57fa13204e41c14bd8766bd214976f6823187c91a8887bbfc274eae0e14beb10

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp38-cp38-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 8975e35d4d6e80d3f17dd2aa87f69208db45888ae89381dc677cc89a9cfca91b
MD5 9eddc5866690cdd347b4a6e8633b8102
BLAKE2b-256 519fe24e17652925d0db01a05143c1cc9630630880b770f1c43c6a13bdc01f59

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp37-none-win_amd64.whl.

File metadata

  • Download URL: pyxirr-0.6.1-cp37-none-win_amd64.whl
  • Upload date:
  • Size: 128.7 kB
  • Tags: CPython 3.7, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.11.2

File hashes

Hashes for pyxirr-0.6.1-cp37-none-win_amd64.whl
Algorithm Hash digest
SHA256 f81cbe30a8757b6b69d76b621ccf485e89a98c7e40130fe5c822a6fa2a67bbb8
MD5 bc3628a26c2c1114bb80a7bb27925cae
BLAKE2b-256 2ba2d6fb69cc9f4e34072d86122704e4541ff0b03f1f8d046056cbbfa5badb1d

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 632e346090e2eb735787802e6e3a484476a600916d63853e03e8b699fee47122
MD5 4256b098c8504cb87f692794c5c3b92d
BLAKE2b-256 a4d57b5855d8f87a1383ec4891b5f32cb4e22e7d5e8a722e64b2c7d180c8b9d6

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp37-cp37m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 51ef55467e3a14825820c51b78044c5529049e47566bb2ad665cc8e2c8483c61
MD5 e08201c618d6fb48db64f55c4e4abc5c
BLAKE2b-256 ddfc9e3877cc0fd290469b6439b104e76cb014acd8281994efe57b404d475526

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp36-none-win_amd64.whl.

File metadata

  • Download URL: pyxirr-0.6.1-cp36-none-win_amd64.whl
  • Upload date:
  • Size: 128.9 kB
  • Tags: CPython 3.6, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/0.11.2

File hashes

Hashes for pyxirr-0.6.1-cp36-none-win_amd64.whl
Algorithm Hash digest
SHA256 7a4eee4f34f19be552aef70fff6038672b4786ebb04e4ab45f00fc9fda30608e
MD5 dd9fb06ec5e2ee881d41821ca03f5ec7
BLAKE2b-256 3046022c3a4cfc9caaefabb47733dc14a6f85f15fca68a119c601493ea9a6366

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 b22ed1917e765226be16105fac3a55c605ef119baf4eae6b37d4470a1797491f
MD5 bc728f4c0d7636d4afe3376637724ce6
BLAKE2b-256 90cd338b3fd56f7412527baf45783e5d430130f19dac082d67fb9ec1e1b1146c

See more details on using hashes here.

File details

Details for the file pyxirr-0.6.1-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl.

File metadata

File hashes

Hashes for pyxirr-0.6.1-cp36-cp36m-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl
Algorithm Hash digest
SHA256 c2f5337c0856cd421273ef46babc6248aa0d1557152edc088c91e318a7bcd2be
MD5 18dacf2f0a242af098a12d50691cd190
BLAKE2b-256 bb31f9fb77b8891b265688c14ad934573cb049a9038696e4461f39a7b4fdb71d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page