Python numpy.pv() Examples

The following are 30 code examples of numpy.pv(). 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: supply_technologies.py    From EnergyPATHWAYS with MIT License 6 votes vote down vote up
def levelize_costs(self):
        if hasattr(self, 'is_levelized'):
            inflation = cfg.getParamAsFloat('inflation_rate')
            try:
                rate = self.cost_of_capital - inflation
            except:
                pdb.set_trace()
            if self.is_levelized == 0:
                self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values
                util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
            elif self.is_levelized==1:
                self.values_level = self.values.copy()
                util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
                self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values
            elif self.definition == 'relative':
                self.values_level = self.values.copy()
                util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
            else:
                raise ValueError("no specification of whether the technology cost is levelized")

        else:
            raise ValueError('Supply Technology id %s needs to indicate whether costs are levelized ' %self.name) 
Example #2
Source File: financial.py    From Fluid-Designer 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 #3
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 #4
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 #5
Source File: financial.py    From elasticintel with GNU 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 #6
Source File: demand_measures.py    From EnergyPATHWAYS with MIT License 5 votes vote down vote up
def levelize_costs(self):
        if self.is_levelized == 1:
            inflation = cfg.getParamAsFloat('inflation_rate')
            rate = self.cost_of_capital - inflation
            if self.is_levelized == 0:
                self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values
                util.convert_age(self, attr_from='values_level', attr_to='values_level', reverse=False,
                                 vintages=self.vintages, years=self.years)
            else:
                self.values_level = self.values.copy()
                util.convert_age(self, attr_from='values_level', attr_to='values_level', reverse=False,
                                 vintages=self.vintages, years=self.years)
                self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values
        else:
            util.convert_age(self, reverse=False, vintages=self.vintages, years=self.years) 
Example #7
Source File: demand_technologies.py    From EnergyPATHWAYS with MIT License 5 votes vote down vote up
def levelize_costs(self):
        if hasattr(self, 'is_levelized') and (self.definition=='absolute' or (self.definition=='relative' and self.reference_tech_operation=='add')):
            inflation = cfg.getParamAsFloat('inflation_rate')
            rate = self.cost_of_capital - inflation
            if self.is_levelized == 0:
                self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values
                util.convert_age(self, attr_from='values_level', attr_to='values_level', reverse=False,
                                 vintages=self.vintages, years=self.years)
            else:
                self.values_level = self.values.copy()
                util.convert_age(self, attr_from='values_level', attr_to='value_level', reverse=False,
                                 vintages=self.vintages, years=self.years)
                self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values
        else:
            util.convert_age(self, attr_from='values', attr_to='values_level', reverse=False, vintages=self.vintages, years=self.years) 
Example #8
Source File: test_financial.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_pv(self):
        assert_almost_equal(np.pv(0.07, 20, 12000, 0), -127128.17, 2) 
Example #9
Source File: test_financial.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def test_pv_decimal(self):
        assert_equal(np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0')),
                     Decimal('-127128.1709461939327295222005')) 
Example #10
Source File: financial.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def _fv_dispatcher(rate, nper, pmt, pv, when=None):
    return (rate, nper, pmt, pv) 
Example #11
Source File: financial.py    From coffeegrindsize with MIT License 5 votes vote down vote up
def _pmt_dispatcher(rate, nper, pv, fv=None, when=None):
    return (rate, nper, pv, fv) 
Example #12
Source File: test_financial.py    From elasticintel with GNU General Public License v3.0 5 votes vote down vote up
def test_pv(self):
        assert_almost_equal(np.pv(0.07, 20, 12000, 0), -127128.17, 2) 
Example #13
Source File: financial.py    From pySINDy 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 #14
Source File: test_financial.py    From pySINDy with MIT License 5 votes vote down vote up
def test_pv_decimal(self):
        assert_equal(np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0')),
                     Decimal('-127128.1709461939327295222005')) 
Example #15
Source File: test_financial.py    From pySINDy with MIT License 5 votes vote down vote up
def test_pv(self):
        assert_almost_equal(np.pv(0.07, 20, 12000, 0), -127128.17, 2) 
Example #16
Source File: financial.py    From Fluid-Designer with GNU 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 #17
Source File: financial.py    From pySINDy with MIT License 5 votes vote down vote up
def ppmt(rate, per, nper, pv, fv=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 #18
Source File: financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def _rate_dispatcher(nper, pmt, pv, fv, when=None, guess=None, tol=None,
                     maxiter=None):
    return (nper, pmt, pv, fv)


# Use Newton's iteration until the change is less than 1e-6
#  for all values or a maximum of 100 iterations is reached.
#  Newton's rule is
#  r_{n+1} = r_{n} - g(r_n)/g'(r_n)
#     where
#  g(r) is the formula
#  g'(r) is the derivative with respect to r. 
Example #19
Source File: financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def _pv_dispatcher(rate, nper, pmt, fv=None, when=None):
    return (rate, nper, nper, pv, fv) 
Example #20
Source File: financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def ppmt(rate, per, nper, pv, fv=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 #21
Source File: financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def _ppmt_dispatcher(rate, per, nper, pv, fv=None, when=None):
    return (rate, per, nper, pv, fv) 
Example #22
Source File: financial.py    From predictive-maintenance-using-machine-learning 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 #23
Source File: financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def _nper_dispatcher(rate, pmt, pv, fv=None, when=None):
    return (rate, pmt, pv, fv) 
Example #24
Source File: financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def _pmt_dispatcher(rate, nper, pv, fv=None, when=None):
    return (rate, nper, pv, fv) 
Example #25
Source File: financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def _fv_dispatcher(rate, nper, pmt, pv, when=None):
    return (rate, nper, pmt, pv) 
Example #26
Source File: test_financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_pv_decimal(self):
        assert_equal(np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0')),
                     Decimal('-127128.1709461939327295222005')) 
Example #27
Source File: test_financial.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 5 votes vote down vote up
def test_pv(self):
        assert_almost_equal(np.pv(0.07, 20, 12000, 0), -127128.17, 2) 
Example #28
Source File: test_financial.py    From recruit with Apache License 2.0 5 votes vote down vote up
def test_pv(self):
        assert_almost_equal(np.pv(0.07, 20, 12000, 0), -127128.17, 2) 
Example #29
Source File: financial.py    From GraphicDesignPatternByPython 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 #30
Source File: test_financial.py    From GraphicDesignPatternByPython with MIT License 5 votes vote down vote up
def test_pv_decimal(self):
        assert_equal(np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0')),
                     Decimal('-127128.1709461939327295222005'))