NumPy Financial

1.0.0 · active · verified Thu Apr 09

NumPy Financial is a Python library providing a collection of elementary financial functions. It serves as the standalone replacement for the financial functions that were deprecated and subsequently removed from the main NumPy library. Currently at version 1.0.0, the package aims for stability and maintains compatibility with NumPy, with releases typically occurring as needed for maintenance or feature parity.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to calculate the present value (pv) of an annuity using common financial parameters. It shows the recommended import alias and a basic function call.

import numpy_financial as npf

# Calculate the present value (pv) of an annuity
# A loan of 200,000, paid back over 30 years with monthly payments
# at an annual interest rate of 5%.

rate = 0.05 / 12     # Monthly interest rate (annual rate / 12)
nper = 30 * 12       # Total number of payments (30 years * 12 months)
pmt = -1073.64       # Monthly payment (negative as it's an outflow)
fv = 0               # Future value (loan is fully paid off)
when = 'end'         # Payments at the end of each period

present_value = npf.pv(rate, nper, pmt, fv, when)

print(f"The present value of the annuity is: ${present_value:,.2f}")

view raw JSON →