Skip to main content

MoneyWarp – Bend time. Model cash.

Project description

MoneyWarp

Bend time. Model cash.

Release Build status codecov License

Development Stage Notice -- MoneyWarp is in active development (alpha). Core classes are stable and covered by 5700+ tests, but the API may evolve.

MoneyWarp is a Python library for working with the time value of money. It treats loans, annuities, and investments as cash flows through time -- and gives you the tools to warp them back and forth between present, future, and everything in between.

Features

  • Time Machine (Warp) -- travel to any date and see loan state as of that moment
  • PMT, NPV, IRR, MIRR -- core finance functions powered by scipy
  • Loan tracking -- payments, fines, mora interest, grace periods
  • High-precision Money -- Decimal arithmetic, never floats
  • Amortization schedules -- French (Price) and SAC (Inverted Price)
  • Flexible dates -- irregular due dates, smart month-end handling
  • Type-safe interest rates -- explicit percentage handling, frequency conversions
  • Percentage type -- non-temporal flat percentages for fees, fines, MDR
  • Installments and Settlements -- first-class repayment plan and payment allocation
  • Payment waivers -- waive fines, mora, or overdue interest per payment
  • Working day calendars -- business day awareness for penalty deadlines
  • Tax module -- Brazilian IOF, grossup, pluggable tax strategy
  • Timezone-aware -- UTC by default, configurable globally
  • Marshmallow extension -- custom fields for serialization
  • SQLAlchemy extension -- column types + loan/settlement bridge with SQL-queryable balance

Installation

pip install money-warp

With optional extensions:

pip install money-warp[marshmallow]   # Marshmallow fields
pip install money-warp[sa]            # SQLAlchemy types + bridge

Quick Start

from datetime import datetime, timezone
from money_warp import Money, InterestRate, Loan, generate_monthly_dates
from money_warp.tz import to_date

principal = Money("10000.00")
rate = InterestRate("5% a")  # 5% annually

start_date = datetime(2024, 1, 15, tzinfo=timezone.utc)
due_dates = [to_date(d) for d in generate_monthly_dates(start_date, 12)]

loan = Loan(principal, rate, due_dates)

schedule = loan.get_amortization_schedule()
print(f"Monthly payment: {schedule[0].payment_amount}")
print(f"Total interest: {schedule.total_interest}")

loan.record_payment(Money("856.07"), datetime(2024, 2, 1, tzinfo=timezone.utc))
print(f"Remaining balance: {loan.current_balance}")

Time Machine

Travel to any date and see the loan exactly as it was -- payments, interest, fines, everything filtered to that moment:

from money_warp import Warp, Loan, Money, InterestRate
from datetime import date, datetime

loan = Loan(Money("10000"), InterestRate("5% a"), [date(2024, 1, 15)])
loan.record_payment(Money("500"), datetime(2024, 1, 10))
loan.record_payment(Money("600"), datetime(2024, 2, 10))
loan.record_payment(Money("700"), datetime(2024, 3, 10))

# Warp to the past -- only payments made by that date are visible
with Warp(loan, datetime(2024, 1, 20)) as past_loan:
    print(f"Balance on Jan 20: {past_loan.current_balance}")

# Warp to the future
with Warp(loan, datetime(2025, 1, 1)) as future_loan:
    print(f"Balance in 2025: {future_loan.current_balance}")

# Original loan is unchanged
print(f"Present balance: {loan.current_balance}")

Documentation

Full guides, examples, and API reference at tomascorrea.github.io/money-warp.

Contributing

Contributions are welcome! See the Contributing Guide for details.

License

MIT -- see LICENSE.

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

money_warp-0.29.1.tar.gz (83.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

money_warp-0.29.1-py3-none-any.whl (108.1 kB view details)

Uploaded Python 3

File details

Details for the file money_warp-0.29.1.tar.gz.

File metadata

  • Download URL: money_warp-0.29.1.tar.gz
  • Upload date:
  • Size: 83.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for money_warp-0.29.1.tar.gz
Algorithm Hash digest
SHA256 3eeecca0a534aef9296d3a720515494141dbdf28018d1fcd93ed59a2eab5682f
MD5 a610a84011f24dee591ecccf33cd63a4
BLAKE2b-256 e4a0bb855a29b5a4b870c8b6ff0d9b47e229fee993a87848a34b458f5dbedbbb

See more details on using hashes here.

Provenance

The following attestation bundles were made for money_warp-0.29.1.tar.gz:

Publisher: on-release-pypi.yml on tomascorrea/money-warp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file money_warp-0.29.1-py3-none-any.whl.

File metadata

  • Download URL: money_warp-0.29.1-py3-none-any.whl
  • Upload date:
  • Size: 108.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for money_warp-0.29.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a5f61c5c1064f55bffc0aab1f097f49f0963e19661c71287017f4e2f42496f91
MD5 ee694903003c04c300e28ab7dcd95ed1
BLAKE2b-256 8646d9dc7736c7b9948ed20f073fc16a61ed8f61766006229a25a5972a7d0086

See more details on using hashes here.

Provenance

The following attestation bundles were made for money_warp-0.29.1-py3-none-any.whl:

Publisher: on-release-pypi.yml on tomascorrea/money-warp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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