|
| 1 | +<!DOCTYPE html> |
| 2 | +<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang=""> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" /> |
| 6 | + <title>numpy-financial</title> |
| 7 | + <style type="text/css"> |
| 8 | + code{white-space: pre-wrap;} |
| 9 | + span.smallcaps{font-variant: small-caps;} |
| 10 | + span.underline{text-decoration: underline;} |
| 11 | + div.column{display: inline-block; vertical-align: top; width: 50%;} |
| 12 | + </style> |
| 13 | + <link rel="stylesheet" href="css/home.css" /> |
| 14 | + <!--[if lt IE 9]> |
| 15 | + <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script> |
| 16 | + <![endif]--> |
| 17 | + <title> |
| 18 | + numpy-financial |
| 19 | + </title> |
| 20 | + <link rel="icon" type="image/png" href="images/numpy_financial_favicon.png" /> |
| 21 | +</head> |
| 22 | +<body> |
| 23 | +<h1 id="logo"><img src="images/numpy_financial_logoh.svg" title="numpy-financial logo" alt="logo" /></h1> |
| 24 | +<aside id="asidelinks"> |
| 25 | + <h3>Reference Documentation</h3> |
| 26 | + <a href="https://numpy/numpy_financial/latest/" class="link2">Latest release</a> |
| 27 | + <a href="https://numpy/numpy_financial/dev/" class="link2">Development version</a> |
| 28 | + <h3>Source Code on GitHub</h3> |
| 29 | + <a href="https://github.com/numpy/numpy-financial" class="link2">numpy-financial</a> |
| 30 | +</aside> |
| 31 | +<p> |
| 32 | +The numpy-financial Python package is a collection of elementary |
| 33 | +financial functions. These functions were copied to this package |
| 34 | +from version 1.17 of NumPy. |
| 35 | +</p> |
| 36 | +<p>The <a href="https://numpy.org/doc/1.17/reference/routines.financial.html">financial functions in NumPy</a> |
| 37 | +are deprecated and eventually will be removed from NumPy; see |
| 38 | +<a href="https://numpy.org/neps/nep-0032-remove-financial-functions.html">NEP-32</a> |
| 39 | +for more information. This package is the replacement for the deprecated |
| 40 | +NumPy financial functions. |
| 41 | +</p> |
| 42 | + |
| 43 | +<h2 id="installation">Installation</h2> |
| 44 | +<p> |
| 45 | +The package is available on <a href="https://pypi.org/project/numpy-financial">PyPI</a>, and may be installed |
| 46 | +with <code>pip</code>: |
| 47 | + |
| 48 | +<pre> |
| 49 | + $ pip install numpy-financial |
| 50 | +</pre> |
| 51 | + |
| 52 | +The package requires NumPy version 1.17 or later. |
| 53 | +</p> |
| 54 | + |
| 55 | +<h2 id="using">Using <code>numpy_financial</code></h2> |
| 56 | +<p> |
| 57 | +The importable name of the package is <code>numpy_financial</code>. |
| 58 | +The recommended alias is <code>npf</code>. For example, |
| 59 | +</p> |
| 60 | +<pre> |
| 61 | +>>> import numpy_financial as npf |
| 62 | +>>> npf.irr([-250000, 100000, 150000, 200000, 250000, 300000]) |
| 63 | +0.5672303344358536 |
| 64 | +</pre> |
| 65 | + |
| 66 | +<h2 id="replacing">Switching from <code>numpy</code> to <code>numpy_financial</code></h2> |
| 67 | +<ul> |
| 68 | +<li> |
| 69 | +<p>Code that imports the function names like this |
| 70 | +<pre> |
| 71 | + from numpy import npv, irr |
| 72 | +</pre> |
| 73 | +requires only that the import be changed to |
| 74 | +<pre> |
| 75 | + from numpy_financial import npv, irr |
| 76 | +</pre> |
| 77 | +</p> |
| 78 | +</li> |
| 79 | +<li> |
| 80 | +<p>For code that uses the <code>numpy</code> namespace like this |
| 81 | +<pre> |
| 82 | + import numpy as np |
| 83 | + |
| 84 | + x = np.array([-250000, 100000, 150000, 200000, 250000, 300000]) |
| 85 | + r = np.irr(x) |
| 86 | +</pre> |
| 87 | +the import statement for the numpy-financial package must be added, |
| 88 | +and the calls of the financial functions must be changed to use |
| 89 | +the <code>npf</code> namespace: |
| 90 | +<pre> |
| 91 | + import numpy as np |
| 92 | + import numpy_financial as npf |
| 93 | + |
| 94 | + x = np.array([-250000, 100000, 150000, 200000, 250000, 300000]) |
| 95 | + r = npf.irr(x) |
| 96 | +</pre> |
| 97 | +</p> |
| 98 | +</li> |
| 99 | +</ul> |
| 100 | + |
| 101 | +<div id="footer"> |
| 102 | + © 2019 NumPy-Financial Developers</a> |
| 103 | +</div> |
| 104 | +</body> |
| 105 | +</html> |
0 commit comments