• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python numpy.ppmt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中numpy.ppmt函数的典型用法代码示例。如果您正苦于以下问题:Python ppmt函数的具体用法?Python ppmt怎么用?Python ppmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ppmt函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_broadcast_decimal

    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)
开发者ID:Horta,项目名称:numpy,代码行数:15,代码来源:test_financial.py


示例2: test_broadcast

    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)
开发者ID:BlackEarth,项目名称:portable-python-win32,代码行数:16,代码来源:test_financial.py


示例3: test_ppmt_special_rate_decimal

    def test_ppmt_special_rate_decimal(self):
        # When rounded out to 8 decimal places like the float based test, this should not equal the same value
        # as the float, substituted for the decimal
        def raise_error_because_not_equal():
            assert_equal(
                round(np.ppmt(Decimal('0.23') / Decimal('12'), 1, 60, Decimal('10000000000')), 8),
                Decimal('-90238044.232277036'))

        assert_raises(AssertionError, raise_error_because_not_equal)
        assert_equal(np.ppmt(Decimal('0.23') / Decimal('12'), 1, 60, Decimal('10000000000')),
                     Decimal('-90238044.2322778884413969909'))
开发者ID:Horta,项目名称:numpy,代码行数:11,代码来源:test_financial.py


示例4: test_when

    def test_when(self):
        # begin
        assert_almost_equal(np.rate(10, 20, -3500, 10000, 1), np.rate(10, 20, -3500, 10000, "begin"), 4)
        # end
        assert_almost_equal(np.rate(10, 20, -3500, 10000), np.rate(10, 20, -3500, 10000, "end"), 4)
        assert_almost_equal(np.rate(10, 20, -3500, 10000, 0), np.rate(10, 20, -3500, 10000, "end"), 4)

        # begin
        assert_almost_equal(np.pv(0.07, 20, 12000, 0, 1), np.pv(0.07, 20, 12000, 0, "begin"), 2)
        # end
        assert_almost_equal(np.pv(0.07, 20, 12000, 0), np.pv(0.07, 20, 12000, 0, "end"), 2)
        assert_almost_equal(np.pv(0.07, 20, 12000, 0, 0), np.pv(0.07, 20, 12000, 0, "end"), 2)

        # begin
        assert_almost_equal(np.fv(0.075, 20, -2000, 0, 1), np.fv(0.075, 20, -2000, 0, "begin"), 4)
        # end
        assert_almost_equal(np.fv(0.075, 20, -2000, 0), np.fv(0.075, 20, -2000, 0, "end"), 4)
        assert_almost_equal(np.fv(0.075, 20, -2000, 0, 0), np.fv(0.075, 20, -2000, 0, "end"), 4)

        # begin
        assert_almost_equal(np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, 1), np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, "begin"), 4)
        # end
        assert_almost_equal(np.pmt(0.08 / 12, 5 * 12, 15000.0, 0), np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, "end"), 4)
        assert_almost_equal(np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, 0), np.pmt(0.08 / 12, 5 * 12, 15000.0, 0, "end"), 4)

        # begin
        assert_almost_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0, 1), np.ppmt(0.1 / 12, 1, 60, 55000, 0, "begin"), 4)
        # end
        assert_almost_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0), np.ppmt(0.1 / 12, 1, 60, 55000, 0, "end"), 4)
        assert_almost_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0, 0), np.ppmt(0.1 / 12, 1, 60, 55000, 0, "end"), 4)

        # begin
        assert_almost_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0, 1), np.ipmt(0.1 / 12, 1, 24, 2000, 0, "begin"), 4)
        # end
        assert_almost_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0), np.ipmt(0.1 / 12, 1, 24, 2000, 0, "end"), 4)
        assert_almost_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0, 0), np.ipmt(0.1 / 12, 1, 24, 2000, 0, "end"), 4)

        # begin
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000.0, 1), np.nper(0.075, -2000, 0, 100000.0, "begin"), 4)
        # end
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000.0), np.nper(0.075, -2000, 0, 100000.0, "end"), 4)
        assert_almost_equal(np.nper(0.075, -2000, 0, 100000.0, 0), np.nper(0.075, -2000, 0, 100000.0, "end"), 4)
开发者ID:Xatpy,项目名称:echomesh,代码行数:42,代码来源:test_financial.py


示例5: test_ppmt

 def test_ppmt(self):
     np.round(np.ppmt(0.1/12,1,60,55000),2) == 710.25
开发者ID:BlackEarth,项目名称:portable-python-win32,代码行数:2,代码来源:test_financial.py


示例6: test_ppmt_special_rate

 def test_ppmt_special_rate(self):
     assert_equal(np.round(np.ppmt(0.23 / 12, 1, 60, 10000000000), 8), -90238044.232277036)
开发者ID:Horta,项目名称:numpy,代码行数:2,代码来源:test_financial.py


示例7: test_ppmt_decimal

 def test_ppmt_decimal(self):
     assert_equal(np.ppmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('60'), Decimal('55000')),
                  Decimal('-710.2541257864217612489830917'))
开发者ID:Horta,项目名称:numpy,代码行数:3,代码来源:test_financial.py


示例8: test_ppmt

 def test_ppmt(self):
     assert_equal(np.round(np.ppmt(0.1 / 12, 1, 60, 55000), 2), -710.25)
开发者ID:Horta,项目名称:numpy,代码行数:2,代码来源:test_financial.py


示例9: test_decimal_with_when

    def test_decimal_with_when(self):
        """Test that decimals are still supported if the when argument is passed"""
        # begin
        assert_equal(np.rate(Decimal('10'), Decimal('20'), Decimal('-3500'), Decimal('10000'), Decimal('1')),
                     np.rate(Decimal('10'), Decimal('20'), Decimal('-3500'), Decimal('10000'), 'begin'))
        # end
        assert_equal(np.rate(Decimal('10'), Decimal('20'), Decimal('-3500'), Decimal('10000')),
                     np.rate(Decimal('10'), Decimal('20'), Decimal('-3500'), Decimal('10000'), 'end'))
        assert_equal(np.rate(Decimal('10'), Decimal('20'), Decimal('-3500'), Decimal('10000'), Decimal('0')),
                     np.rate(Decimal('10'), Decimal('20'), Decimal('-3500'), Decimal('10000'), 'end'))

        # begin
        assert_equal(np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0'), Decimal('1')),
                     np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0'), 'begin'))
        # end
        assert_equal(np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0')),
                     np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0'), 'end'))
        assert_equal(np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0'), Decimal('0')),
                     np.pv(Decimal('0.07'), Decimal('20'), Decimal('12000'), Decimal('0'), 'end'))

        # begin
        assert_equal(np.fv(Decimal('0.075'), Decimal('20'), Decimal('-2000'), Decimal('0'), Decimal('1')),
                     np.fv(Decimal('0.075'), Decimal('20'), Decimal('-2000'), Decimal('0'), 'begin'))
        # end
        assert_equal(np.fv(Decimal('0.075'), Decimal('20'), Decimal('-2000'), Decimal('0')),
                     np.fv(Decimal('0.075'), Decimal('20'), Decimal('-2000'), Decimal('0'), 'end'))
        assert_equal(np.fv(Decimal('0.075'), Decimal('20'), Decimal('-2000'), Decimal('0'), Decimal('0')),
                     np.fv(Decimal('0.075'), Decimal('20'), Decimal('-2000'), Decimal('0'), 'end'))

        # begin
        assert_equal(np.pmt(Decimal('0.08') / Decimal('12'), Decimal('5') * Decimal('12'), Decimal('15000.'),
                            Decimal('0'), Decimal('1')),
                     np.pmt(Decimal('0.08') / Decimal('12'), Decimal('5') * Decimal('12'), Decimal('15000.'),
                            Decimal('0'), 'begin'))
        # end
        assert_equal(np.pmt(Decimal('0.08') / Decimal('12'), Decimal('5') * Decimal('12'), Decimal('15000.'),
                            Decimal('0')),
                     np.pmt(Decimal('0.08') / Decimal('12'), Decimal('5') * Decimal('12'), Decimal('15000.'),
                            Decimal('0'), 'end'))
        assert_equal(np.pmt(Decimal('0.08') / Decimal('12'), Decimal('5') * Decimal('12'), Decimal('15000.'),
                            Decimal('0'), Decimal('0')),
                     np.pmt(Decimal('0.08') / Decimal('12'), Decimal('5') * Decimal('12'), Decimal('15000.'),
                            Decimal('0'), 'end'))

        # begin
        assert_equal(np.ppmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('60'), Decimal('55000'),
                             Decimal('0'), Decimal('1')),
                     np.ppmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('60'), Decimal('55000'),
                             Decimal('0'), 'begin'))
        # end
        assert_equal(np.ppmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('60'), Decimal('55000'),
                             Decimal('0')),
                     np.ppmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('60'), Decimal('55000'),
                             Decimal('0'), 'end'))
        assert_equal(np.ppmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('60'), Decimal('55000'),
                             Decimal('0'), Decimal('0')),
                     np.ppmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('60'), Decimal('55000'),
                             Decimal('0'), 'end'))

        # begin
        assert_equal(np.ipmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('24'), Decimal('2000'),
                             Decimal('0'), Decimal('1')).flat[0],
                     np.ipmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('24'), Decimal('2000'),
                             Decimal('0'), 'begin').flat[0])
        # end
        assert_equal(np.ipmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('24'), Decimal('2000'),
                             Decimal('0')).flat[0],
                     np.ipmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('24'), Decimal('2000'),
                             Decimal('0'), 'end').flat[0])
        assert_equal(np.ipmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('24'), Decimal('2000'),
                             Decimal('0'), Decimal('0')).flat[0],
                     np.ipmt(Decimal('0.1') / Decimal('12'), Decimal('1'), Decimal('24'), Decimal('2000'),
                             Decimal('0'), 'end').flat[0])
开发者ID:Horta,项目名称:numpy,代码行数:73,代码来源:test_financial.py


示例10: test_when

    def test_when(self):
        # begin
        assert_equal(np.rate(10, 20, -3500, 10000, 1),
                     np.rate(10, 20, -3500, 10000, 'begin'))
        # end
        assert_equal(np.rate(10, 20, -3500, 10000),
                     np.rate(10, 20, -3500, 10000, 'end'))
        assert_equal(np.rate(10, 20, -3500, 10000, 0),
                     np.rate(10, 20, -3500, 10000, 'end'))

        # begin
        assert_equal(np.pv(0.07, 20, 12000, 0, 1),
                     np.pv(0.07, 20, 12000, 0, 'begin'))
        # end
        assert_equal(np.pv(0.07, 20, 12000, 0),
                     np.pv(0.07, 20, 12000, 0, 'end'))
        assert_equal(np.pv(0.07, 20, 12000, 0, 0),
                     np.pv(0.07, 20, 12000, 0, 'end'))

        # begin
        assert_equal(np.fv(0.075, 20, -2000, 0, 1),
                     np.fv(0.075, 20, -2000, 0, 'begin'))
        # end
        assert_equal(np.fv(0.075, 20, -2000, 0),
                     np.fv(0.075, 20, -2000, 0, 'end'))
        assert_equal(np.fv(0.075, 20, -2000, 0, 0),
                     np.fv(0.075, 20, -2000, 0, 'end'))

        # begin
        assert_equal(np.pmt(0.08 / 12, 5 * 12, 15000., 0, 1),
                     np.pmt(0.08 / 12, 5 * 12, 15000., 0, 'begin'))
        # end
        assert_equal(np.pmt(0.08 / 12, 5 * 12, 15000., 0),
                     np.pmt(0.08 / 12, 5 * 12, 15000., 0, 'end'))
        assert_equal(np.pmt(0.08 / 12, 5 * 12, 15000., 0, 0),
                     np.pmt(0.08 / 12, 5 * 12, 15000., 0, 'end'))

        # begin
        assert_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0, 1),
                     np.ppmt(0.1 / 12, 1, 60, 55000, 0, 'begin'))
        # end
        assert_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0),
                     np.ppmt(0.1 / 12, 1, 60, 55000, 0, 'end'))
        assert_equal(np.ppmt(0.1 / 12, 1, 60, 55000, 0, 0),
                     np.ppmt(0.1 / 12, 1, 60, 55000, 0, 'end'))

        # begin
        assert_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0, 1),
                     np.ipmt(0.1 / 12, 1, 24, 2000, 0, 'begin'))
        # end
        assert_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0),
                     np.ipmt(0.1 / 12, 1, 24, 2000, 0, 'end'))
        assert_equal(np.ipmt(0.1 / 12, 1, 24, 2000, 0, 0),
                     np.ipmt(0.1 / 12, 1, 24, 2000, 0, 'end'))

        # begin
        assert_equal(np.nper(0.075, -2000, 0, 100000., 1),
                     np.nper(0.075, -2000, 0, 100000., 'begin'))
        # end
        assert_equal(np.nper(0.075, -2000, 0, 100000.),
                     np.nper(0.075, -2000, 0, 100000., 'end'))
        assert_equal(np.nper(0.075, -2000, 0, 100000., 0),
                     np.nper(0.075, -2000, 0, 100000., 'end'))
开发者ID:Horta,项目名称:numpy,代码行数:63,代码来源:test_financial.py


示例11: raise_error_because_not_equal

 def raise_error_because_not_equal():
     assert_equal(
         round(np.ppmt(Decimal('0.23') / Decimal('12'), 1, 60, Decimal('10000000000')), 8),
         Decimal('-90238044.232277036'))
开发者ID:Horta,项目名称:numpy,代码行数:4,代码来源:test_financial.py


示例12: cashflows

    def cashflows(self):
        """
        Construct a dataframe with projections of balances and cashflows for a loan portfolio
        in an homogeneous loan pool, where the loans share the same origination period.
        :rtype: pandas dataframe
        """
        loss_rates = self._credit_model.get('loss')
        nonperforming_rates = self._credit_model.get('nonperforming')
        provision_rates = self._credit_model.get('provision')
        prepayment_rates = self._prepayment_vector
        rates = self._rates_vector
        index_to_apply = list(range(self.origination_month(), self.origination_month() + self._nper + 1))

        ans_df = pd.DataFrame(0.,
                              index = index_to_apply,
                              columns = ('saldo_inicial',
                                         'desembolsos',
                                         'amortizacion',
                                         'prepago',
                                         'castigo',
                                         'saldo_final',
                                         'interes',
                                         'improductiva',
                                         'saldo_provision'))

        ans_df.loc[self.origination_month()] = [0,
                                                self._origination,
                                                0,
                                                0,
                                                0,
                                                self._origination,
                                                0,
                                                0,
                                                self._origination * provision_rates[0]]

        rounding = 6
        min_balance = 0.01
        initial_balance = self._origination
        for payment in range(self._nper):
            index = payment + self.origination_month()
            loss = np.round(initial_balance * loss_rates[payment], rounding)
            prepayment = np.round(initial_balance * prepayment_rates[payment], rounding)
            nonperforming = np.round(initial_balance * nonperforming_rates[payment], rounding)
            provision = np.round((provision_rates[payment] * (initial_balance - nonperforming)) + nonperforming,
                                 rounding)
            ipmt = np.round((initial_balance - nonperforming) * rates[payment], rounding)

            contractual_ppmt = np.round(-(np.ppmt(rates[payment],
                                                  payment + 1, self._nper, self._origination)), rounding)
            if contractual_ppmt > (initial_balance - prepayment - loss):
                ppmt = np.round(initial_balance - prepayment - loss, rounding)
            else:
                ppmt = contractual_ppmt

            ending_balance = np.round(initial_balance - ppmt - prepayment - loss, rounding)
            if ending_balance < min_balance:
                ending_balance = 0.

            origination = np.round(0., rounding)

            ans_df.loc[index + 1] = [initial_balance,
                                     origination,
                                     ppmt,
                                     prepayment,
                                     loss,
                                     ending_balance,
                                     ipmt,
                                     nonperforming,
                                     provision]

            initial_balance = ending_balance
        return ans_df
开发者ID:JavierGarciaD,项目名称:mini_projects,代码行数:72,代码来源:cartera.py


示例13: loans

               'default': 'ls_default'}

df = df.rename(columns=rename_dict)
df = df.rename(columns=purpose_dict)

# identify good loans and bad loans (might include the 31 to 120 day late category later)
df.loc[df['ls_default'] == 1, 'bad_loan'] = 1
df.loc[df['ls_chargeoff'] == 1, 'bad_loan'] = 1
df.loc[df['bad_loan'] != 1, 'bad_loan'] = 0
df.loc[df['bad_loan'] != 1, 'good_loan'] = 1
df.loc[df['good_loan'] != 1, 'good_loan'] = 0

# add columns related to debt service and debt service coverage

# calculate annual debt service payments for Lending Club loans
df['annual_prin'] = sum([np.ppmt(df['int_rate'] / 12, i, df['term'], -df['loan_amnt'], 0) for i in range(1, 13)])
df['annual_prin'] = df['annual_prin'].round(2)
df['annual_int'] = sum([np.ipmt(df['int_rate'] / 12, i, df['term'], -df['loan_amnt'], 0) for i in range(1, 13)])
df['annual_int'] = df['annual_int'].round(2)
df['annual_debt_svc'] = df['annual_prin'] + df['annual_int']
df['annual_debt_svc'] = df['annual_debt_svc'].round(2)

# total revolving debt NOT attributable to Lending Club loans
df['other_rev_debt'] = df['total_bal_ex_mort'] - df['out_prncp']
df.loc[df['other_rev_debt'] < 0, 'other_rev_debt'] = 0

# total mortgage/installment debt (also not Lending Club)
df['other_mort_debt'] = df['tot_cur_bal'] - df['other_rev_debt']
df.loc[df['other_mort_debt'] < 0, 'other_mort_debt'] = 0

# estimated annual debt service requirement on non-Lending-Club revolving debt (at Lending Club int_rate, 5yr amort)
开发者ID:mgd34msu,项目名称:detanokagaku,代码行数:31,代码来源:credit.py



注:本文中的numpy.ppmt函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python numpy.prod函数代码示例发布时间:2022-05-27
下一篇:
Python numpy.power函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap