当前位置: 首页>>代码示例>>Python>>正文


Python numpy.nper函数代码示例

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


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

示例1: impact_calculator_total

def impact_calculator_total(present_value, annual_rate, payments, lump_sum, future_value=0):
    # Calculate the impact (time) in throwing more money at a single debt
    annual_rate /= 12
    t0 = np.nper([annual_rate], [-payments], [present_value], [future_value])
    t1 = np.nper([annual_rate], [-payments], [present_value - lump_sum], [future_value])

    time_saved = t1 - t0
    print('t {} - {} = {}'.format(t1, t0, time_saved))

    impact_rate = ((annual_rate / 12 + 1) ** (t0 * 12)) - 1
    money_saved = impact_rate * lump_sum

    return -round(time_saved[0] * 365/12), round(money_saved[0], 2)
开发者ID:shabscan,项目名称:debtfree,代码行数:13,代码来源:simulator.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_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

示例4: test_nper2

 def test_nper2(self):
     assert_almost_equal(np.nper(0.0,-2000,0,100000.),
                         50.0, 1)
开发者ID:BlackEarth,项目名称:portable-python-win32,代码行数:3,代码来源:test_financial.py

示例5: test_nper

 def test_nper(self):
     assert_almost_equal(np.nper(0.075,-2000,0,100000.),
                         21.54, 2)
开发者ID:BlackEarth,项目名称:portable-python-win32,代码行数:3,代码来源:test_financial.py

示例6: 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

示例7:

print u"现值"
#pv函数参数为利率,参数,每期支付金额,终值
print "Present value",np.pv(0.03/4,5*4,-10,1376.09633204)
#npv参数为利率和一个表示现金流的数组.
cashflows = np.random.randint(100,size=5)
cashflows = np.insert(cashflows,0,-100)
print "Cashflows",cashflows
print "Net present value",np.npv(0.03,cashflows)
print u"内部收益率"
print "Internal rate of return",np.irr([-100, 38, 48,90 ,17,36])

print u"分期付款"
#pmt输入为利率和期数,总价,输出每期钱数
print "Payment",np.pmt(0.10/12,12*30,100000)
#nper参数为贷款利率,固定的月供和贷款额,输出付款期数
print "Number of payments", np.nper(0.10/12,-100,9000)
#rate参数为付款期数,每期付款资金,现值和终值计算利率
print "Interest rate",12*np.rate(167,-100,9000,0)

print u"窗函数"
#bartlett函数可以计算巴特利特窗
window = np.bartlett(42)
print "bartlett",window
#blackman函数返回布莱克曼窗。该函数唯一的参数为输出点的数量。如果数量
#为0或小于0,则返回一个空数组。
window = np.blackman(10)
print "blackman",window
# hamming函数返回汉明窗。该函数唯一的参数为输出点的数量。如果数量为0或
# 小于0,则返回一个空数组。
window = np.hamming(42)
print "hamming",window
开发者ID:moonlmq,项目名称:Tools,代码行数:31,代码来源:Learn_TypicalFunction.py

示例8: myfnc

@author: ESAccount24
"""

# -*- coding: utf-8 -*-
"""
Created on Sat Sep 26 11:34:21 2015

@author: ESAccount24
"""
#financial institutions
import numpy as np
import scipy.optimize as sp
def myfnc(x):
    return np.pv(x,2,0,125.44)+100.0
    
futval=np.fv(0.12,2,0,-100.0)
print futval
prval=np.pv(0.12,2,0,125.44)
print prval

nperiods=np.nper(0.12,0,-100.0,125.44)
print nperiods

intrate=np.rate(2,0,-100,125.44)
print intrate

initialRateGuess=0.134

#goalseek
#find interest rate that satisfies euqation connecting pv, fv, and nper
print sp.fsolve(myfnc,initialRateGuess)
开发者ID:cbasurto,项目名称:Intro-to-Python-Coursework,代码行数:31,代码来源:financial.institution.goal.seek.py

示例9: peab

 * when : string 'begin' või 'end', valikultine
   Millal makse sooritama peab (alguses või lõpus)

Näide 3
Kui laenu tagasimakse suurus on 330€ kuus, siis kui kaua kulub 68000€ suuruse
laenu maksmiseks aastase intressimäära 2.8% juures?
------------------------------------------------------------------------------
"""

print("\nNäide 3\n-------\n")

RATE = 0.03 / 12  # 4% aastas, 3.5%/12 kuus
PAYMENT = -330  # maksame 330€ kuus, '-' tähendab raha väljavoolu
PV = 68000  # laenu suurus

PERIOD_COUNT = np.nper(RATE, PAYMENT, PV)
print("{0}€ tasumiseks kulub {1:.2f} kuud ehk {2:.0f} aastat."
      .format(PV, PERIOD_COUNT, PERIOD_COUNT/12)
      )

PAYMENTS = np.arange(300, 350, 10)
PERIOD_COUNTS = np.nper(RATE, -PAYMENTS, PV)
for pmt, period in zip(PAYMENTS, PERIOD_COUNTS):
    print("{0}€ suuruse tagasimaksega kulub {1:.2f} kuud ehk {2:.0f} aastat."
          .format(pmt, period, period/12)
          )

"""
------------------------------------------------------------------------------
rate -- perioodi intressimäära arvutamine
rate(nper, pmt, pv, fv, when='end', guess=0.1, tol=1e-06, maxiter=100)
开发者ID:priitlatt,项目名称:sissejuhatus-finantsmatemaatikasse,代码行数:31,代码来源:sfm_yl1_intresside_rehkendamine_priit_latt.py

示例10: test_nper

 def test_nper(self):
     assert_almost_equal(np.nper(-.01,-100,1000),9.483283066, 3)
开发者ID:radovankavicky,项目名称:econpy,代码行数:2,代码来源:test_finance.py

示例11: round

import numpy as np

print
round(np.nper(0.07 / 12, -150, 8000), 5)
np.nper(*(np.ogrid[0.07 / 12: 0.08 / 12: 0.01 / 12,
          -150: -99: 50,
          8000: 9001: 1000]))
开发者ID:yzozulya,项目名称:numpy_test_examples,代码行数:7,代码来源:numpy.nper.py


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