Python numpy.ipmt() Examples

The following are 30 code examples of numpy.ipmt(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module numpy , or try the search function .
Example #1
Source File: test_financial.py    From lambda-packs with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                                -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                                -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                                -76.88882405, -76.88882405], 4) 
Example #2
Source File: test_financial.py    From vnpy_crypto with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #3
Source File: test_financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #4
Source File: test_financial.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #5
Source File: test_financial.py    From Mastering-Elasticsearch-7.0 with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #6
Source File: test_financial.py    From ImageFusion with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                                -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                                -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                                -76.88882405, -76.88882405], 4) 
Example #7
Source File: test_financial.py    From auto-alt-text-lambda-api with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                                -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                                -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                                -76.88882405, -76.88882405], 4) 
Example #8
Source File: test_financial.py    From elasticintel with GNU General Public License v3.0 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                                -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                                -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                                -76.88882405, -76.88882405], 4) 
Example #9
Source File: test_financial.py    From coffeegrindsize with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #10
Source File: test_financial.py    From twitter-stock-recommendation with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #11
Source File: test_financial.py    From GraphicDesignPatternByPython with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #12
Source File: test_financial.py    From mxnet-lambda with Apache License 2.0 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                                -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                                -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                                -76.88882405, -76.88882405], 4) 
Example #13
Source File: test_financial.py    From pySINDy with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #14
Source File: test_financial.py    From keras-lambda with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                                -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                                -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                                -76.88882405, -76.88882405], 4) 
Example #15
Source File: test_financial.py    From recruit with Apache License 2.0 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [21.5449442, 20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                             -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                             -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1 / 12, list(range(5)), 24, 2000, 0,
                                    [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                             -76.88882405, -76.88882405], 4) 
Example #16
Source File: test_financial.py    From Computable with MIT License 6 votes vote down vote up
def test_broadcast(self):
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000., [0, 1]),
                            [ 21.5449442,  20.76156441], 4)

        assert_almost_equal(np.ipmt(0.1/12, list(range(5)), 24, 2000),
                            [-17.29165168, -16.66666667, -16.03647345,
                                -15.40102862, -14.76028842], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000),
                            [-74.998201, -75.62318601, -76.25337923,
                                -76.88882405, -77.52956425], 4)

        assert_almost_equal(np.ppmt(0.1/12, list(range(5)), 24, 2000, 0,
            [0, 0, 1, 'end', 'begin']),
                            [-74.998201, -75.62318601, -75.62318601,
                                -76.88882405, -76.88882405], 4) 
Example #17
Source File: financial.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def _rbl(rate, per, pmt, pv, when):
    """
    This function is here to simply have a different name for the 'fv'
    function to not interfere with the 'fv' keyword argument within the 'ipmt'
    function.  It is the 'remaining balance on loan' which might be useful as
    it's own function, but is easily calculated with the 'fv' function.
    """
    return fv(rate, (per - 1), pmt, pv, when) 
Example #18
Source File: test_financial.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_ipmt(self):
        assert_almost_equal(np.round(np.ipmt(0.1 / 12, 1, 24, 2000), 2), -16.67) 
Example #19
Source File: financial.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 5 votes vote down vote up
def _rbl(rate, per, pmt, pv, when):
    """
    This function is here to simply have a different name for the 'fv'
    function to not interfere with the 'fv' keyword argument within the 'ipmt'
    function.  It is the 'remaining balance on loan' which might be useful as
    it's own function, but is easily calculated with the 'fv' function.
    """
    return fv(rate, (per - 1), pmt, pv, when) 
Example #20
Source File: test_financial.py    From twitter-stock-recommendation with MIT License 5 votes vote down vote up
def test_ipmt_decimal(self):
        result = np.ipmt(Decimal('0.1') / Decimal('12'), 1, 24, 2000)
        assert_equal(result.flat[0], Decimal('-16.66666666666666666666666667')) 
Example #21
Source File: test_financial.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_broadcast_decimal(self):
        # Use almost equal because precision is tested in the explicit tests, this test is to ensure
        # broadcast with Decimal is not broken.
        assert_almost_equal(np.ipmt(Decimal('0.1') / Decimal('12'), list(range(5)), Decimal('24'), Decimal('2000')),
                            [Decimal('-17.29165168'), Decimal('-16.66666667'), Decimal('-16.03647345'),
                             Decimal('-15.40102862'), Decimal('-14.76028842')], 4)

        assert_almost_equal(np.ppmt(Decimal('0.1') / Decimal('12'), list(range(5)), Decimal('24'), Decimal('2000')),
                            [Decimal('-74.998201'), Decimal('-75.62318601'), Decimal('-76.25337923'),
                             Decimal('-76.88882405'), Decimal('-77.52956425')], 4)

        assert_almost_equal(np.ppmt(Decimal('0.1') / Decimal('12'), list(range(5)), Decimal('24'), Decimal('2000'),
                                    Decimal('0'), [Decimal('0'), Decimal('0'), Decimal('1'), 'end', 'begin']),
                            [Decimal('-74.998201'), Decimal('-75.62318601'), Decimal('-75.62318601'),
                             Decimal('-76.88882405'), Decimal('-76.88882405')], 4) 
Example #22
Source File: test_financial.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_ipmt(self):
        np.round(np.ipmt(0.1/12, 1, 24, 2000), 2) == 16.67 
Example #23
Source File: financial.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def ppmt(rate, per, nper, pv, fv=0.0, when='end'):
    """
    Compute the payment against loan principal.

    Parameters
    ----------
    rate : array_like
        Rate of interest (per period)
    per : array_like, int
        Amount paid against the loan changes.  The `per` is the period of
        interest.
    nper : array_like
        Number of compounding periods
    pv : array_like
        Present value
    fv : array_like, optional
        Future value
    when : {{'begin', 1}, {'end', 0}}, {string, int}
        When payments are due ('begin' (1) or 'end' (0))

    See Also
    --------
    pmt, pv, ipmt

    """
    total = pmt(rate, nper, pv, fv, when)
    return total - ipmt(rate, per, nper, pv, fv, when) 
Example #24
Source File: financial.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def _rbl(rate, per, pmt, pv, when):
    """
    This function is here to simply have a different name for the 'fv'
    function to not interfere with the 'fv' keyword argument within the 'ipmt'
    function.  It is the 'remaining balance on loan' which might be useful as
    it's own function, but is easily calculated with the 'fv' function.
    """
    return fv(rate, (per - 1), pmt, pv, when) 
Example #25
Source File: financial.py    From ImageFusion with MIT License 5 votes vote down vote up
def ppmt(rate, per, nper, pv, fv=0.0, when='end'):
    """
    Compute the payment against loan principal.

    Parameters
    ----------
    rate : array_like
        Rate of interest (per period)
    per : array_like, int
        Amount paid against the loan changes.  The `per` is the period of
        interest.
    nper : array_like
        Number of compounding periods
    pv : array_like
        Present value
    fv : array_like, optional
        Future value
    when : {{'begin', 1}, {'end', 0}}, {string, int}
        When payments are due ('begin' (1) or 'end' (0))

    See Also
    --------
    pmt, pv, ipmt

    """
    total = pmt(rate, nper, pv, fv, when)
    return total - ipmt(rate, per, nper, pv, fv, when) 
Example #26
Source File: financial.py    From ImageFusion with MIT License 5 votes vote down vote up
def _rbl(rate, per, pmt, pv, when):
    """
    This function is here to simply have a different name for the 'fv'
    function to not interfere with the 'fv' keyword argument within the 'ipmt'
    function.  It is the 'remaining balance on loan' which might be useful as
    it's own function, but is easily calculated with the 'fv' function.
    """
    return fv(rate, (per - 1), pmt, pv, when) 
Example #27
Source File: test_financial.py    From ImageFusion with MIT License 5 votes vote down vote up
def test_ipmt(self):
        np.round(np.ipmt(0.1/12, 1, 24, 2000), 2) == 16.67 
Example #28
Source File: financial.py    From mxnet-lambda with Apache License 2.0 5 votes vote down vote up
def ppmt(rate, per, nper, pv, fv=0.0, when='end'):
    """
    Compute the payment against loan principal.

    Parameters
    ----------
    rate : array_like
        Rate of interest (per period)
    per : array_like, int
        Amount paid against the loan changes.  The `per` is the period of
        interest.
    nper : array_like
        Number of compounding periods
    pv : array_like
        Present value
    fv : array_like, optional
        Future value
    when : {{'begin', 1}, {'end', 0}}, {string, int}
        When payments are due ('begin' (1) or 'end' (0))

    See Also
    --------
    pmt, pv, ipmt

    """
    total = pmt(rate, nper, pv, fv, when)
    return total - ipmt(rate, per, nper, pv, fv, when) 
Example #29
Source File: financial.py    From mxnet-lambda with Apache License 2.0 5 votes vote down vote up
def _rbl(rate, per, pmt, pv, when):
    """
    This function is here to simply have a different name for the 'fv'
    function to not interfere with the 'fv' keyword argument within the 'ipmt'
    function.  It is the 'remaining balance on loan' which might be useful as
    it's own function, but is easily calculated with the 'fv' function.
    """
    return fv(rate, (per - 1), pmt, pv, when) 
Example #30
Source File: test_financial.py    From mxnet-lambda with Apache License 2.0 5 votes vote down vote up
def test_ipmt(self):
        np.round(np.ipmt(0.1/12, 1, 24, 2000), 2) == 16.67