本文整理汇总了Python中numpy.fv函数的典型用法代码示例。如果您正苦于以下问题:Python fv函数的具体用法?Python fv怎么用?Python fv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: calc_compounding
def calc_compounding ( _rate, _periods, _principal, _contribution, _delta, _inflation ) :
in_rate = 0.01 * _rate
in_delta = 0.01 * _delta
in_contrib = -1* _contribution
in_princ = -1* _principal
in_inflation = 0.01* inflation
print("rate %g, periods %g, principal %g, contribution %g, delta %g, inflation %g" %( _rate, _periods, in_princ, in_contrib, _delta, _inflation))
cf1 = np.array([round(np.fv(in_rate, i, in_contrib, in_princ, when='end'),2) for i in range(1,periods+1)])
cf2 = np.array([round(np.fv((in_rate-in_delta), i, in_contrib, in_princ, when='end'),2) for i in range(1,periods+1)])
if _inflation == 0:
return(np.subtract(cf1,cf2))
else:
diff = np.subtract(cf1,cf2)
return np.array([round(np.pv(in_inflation, i, 0, (-1*diff[i])),2) for i in range(_periods)])
示例2: portfolio_return_calc
def portfolio_return_calc(age, investment, risk_portfolio, investor):
portfolio_attr = []
portfolio_list = Portfolio.objects.filter(name=risk_portfolio)
stock_list = Investment.objects.filter(portfolios__name=risk_portfolio)
stock_name = []
stock_info_list = []
for stock in stock_list:
stock_name.append(stock.name)
stock_description = {
'name': stock.name,
'info': stock.description}
stock_info_list.append(stock_description)
for portfolio in portfolio_list:
portfolio_attr.append(portfolio.name)
portfolio_attr.append(portfolio.expected_return)
inv_return = numpy.fv((float(portfolio_attr[1]) / 12), ((65 - (int(age))) * 12), -(int(investment)), -investment)
investment_return = '{:20,.2f}'.format(float(inv_return))
inv_rt = '{:.20}'.format(inv_return)
data2 = {'stocksp': {'stock1p': 25, 'stock2p': 25, 'stock3p': 20, 'stock4p': 20, 'stock5p': 10},
'stocksn': {'stock1n': stock_name[0], 'stock2n': stock_name[1], 'stock3n': stock_name[2],
'stock4n': stock_name[3], 'stock5n': stock_name[4]},
'portfolio': portfolio_attr[0],
'expected': portfolio_attr[1],
'return': investment_return, 'stock_list': stock_info_list}
investor.portfolio_name = risk_portfolio
investor.expected_return = inv_rt
investor.save()
return data2
示例3: demo_age_calc
def demo_age_calc(age):
percent_month = (float(4000) * .70)
investment_month = (float(4000) - float(percent_month))
inv_return = numpy.fv((.058 / 12), ((65 - (int(age))) * 12), -(int(investment_month)), -investment_month)
investment_return = '{:20,.2f}'.format(float(inv_return))
vistior_age = {'investment': investment_month, 'age': age, 'return': investment_return,
"percent_mon": percent_month}
return vistior_age
示例4: fuli
def fuli(self):
d1 = [np.fv(0.2, i, -1.4, -1.4) for i in range(1, 40)]
# print(d1)
d2 = [np.fv(0.15, i, -1.4, -1.4) for i in range(1, 40)]
d3 = [np.fv(0.1, i, -1.4, -1.4) for i in range(1, 40)]
d4 = [np.fv(0.05, i, -1.4, -1.4) for i in range(1, 40)]
df = pd.DataFrame(columns=['d1','d2','d3','d4'])
df['d1']=d1
df['d2']=d2
df['d3']=d3
df['d4']=d4
#print(df.tail())
#df.plot()
#plt.show()
#
#plt.savefig('data/fv1.png')
#self.plot_style(df)
self.style_color(df)
示例5: 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)
示例6: test_fv_decimal
def test_fv_decimal(self):
assert_equal(np.fv(Decimal('0.075'), Decimal('20'), Decimal('-2000'), 0, 0),
Decimal('86609.36267304300040536731624'))
示例7: test_fv
def test_fv(self):
assert_equal(np.fv(0.075, 20, -2000, 0, 0), 86609.362673042924)
示例8: 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])
示例9: 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'))
示例10: sta001
def sta001(k, nyear, xd):
d2 = np.fv(k, nyear, -xd, -xd);
d2 = round(d2)
return d2
示例11:
print u"金融函数"
# fv函数计算所谓的终值(future value),即基于一些假设给出的某个金融资产在未来某一
# 时间点的价值。
# pv函数计算现值(present value),即金融资产当前的价值。
# npv函数返回的是净现值(net present value),即按折现率计算的净现金流之和。
# pmt函数根据本金和利率计算每期需支付的金额。
# irr函数计算内部收益率(internal rate of return)。内部收益率是是净现值为0时的有效利
# 率,不考虑通胀因素。
# mirr函数计算修正后内部收益率(modified internal rate of return),是内部收益率的改进
# 版本。
# nper函数计算定期付款的期数。
# rate函数计算利率(rate of interest)。
print u"终值"
#fv函数参数为利率,参数,每期支付金额,现值
print "Future value",np.fv(0.03/4, 5*4,-10,1000)
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参数为贷款利率,固定的月供和贷款额,输出付款期数
示例12: test_fv
def test_fv(self):
assert_almost_equal(np.fv(.10,12,-100,100),1824.59, 2)
示例13:
#!/usr/bin/python
import numpy
print "Future value", numpy.fv(0.03/4, 5 * 4, -10, -1000)
示例14: xrange
import numpy as np
from matplotlib.pyplot import plot, show
print "Future value", np.fv(0.03/4, 5 * 4, -10, -1000)
fvals = []
for i in xrange(1, 10):
fvals.append(np.fv(.03/4, i * 4, -10, -1000))
plot(fvals, 'bo')
show()
示例15: alguses
Näide 1
Mis on tulevikuväärtus 100€ alginvesteeringu korral 10 aasta pärast, kui
aastane intressimäär on 3.5% ning me lisame igal kuu alguses (lõpus)
investeeringule 100€?
------------------------------------------------------------------------------
"""
print("Näide 1\n-------\n")
RATE = 0.035 / 12 # 3.5% aastas, 3.5%/12 perioodis
PERIOD = 10*12 # 10 aastat
PAYMENT = -100 # maksame 100€ kuus, '-' tähendab raha väljavoolu
PRESENT_VALUE = -100 # alginvesteering 100€, '-' tähendab raha väljavoolu
FV_1 = np.fv(RATE, PERIOD, PAYMENT, PRESENT_VALUE, when='end')
FV_2 = np.fv(RATE, PERIOD, PAYMENT, PRESENT_VALUE, when='begin')
print("Kuu lõpus makstes koguneb 10 aastaga %.2f€." % FV_1)
print("Kuu alguses makstes koguneb 10 aastaga %.2f€." % FV_2)
"""
Sisestades intressimäära järjendina, saame võrrelda erinevate
määrade korral saadavaid tulemusi.
"""
RATES = np.array([0.02, 0.03, 0.035, 0.04, 0.045])
FUTURE_VALUES = np.fv(RATES/12, PERIOD, PAYMENT, PRESENT_VALUE, when='end')
for rate, fv in zip(RATES, FUTURE_VALUES):
print("Intressimäära {0:.1f}% korral on tulevikuväärtus {1:.2f}€."
.format(rate*100, fv)
开发者ID:priitlatt,项目名称:sissejuhatus-finantsmatemaatikasse,代码行数:30,代码来源:sfm_yl1_intresside_rehkendamine_priit_latt.py