本文整理汇总了Python中numpy.fv函数的典型用法代码示例。如果您正苦于以下问题:Python fv函数的具体用法?Python fv怎么用?Python fv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fv函数的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)])
开发者ID:bansalr,项目名称:fund_allocation,代码行数:14,代码来源:rate_of_return.py
示例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
开发者ID:travis6888,项目名称:wealthy,代码行数:28,代码来源:utils.py
示例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
开发者ID:travis6888,项目名称:wealthy,代码行数:8,代码来源:utils.py
示例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)
开发者ID:Rockyzsu,项目名称:base_function,代码行数:18,代码来源:finace_book.py
示例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)
开发者ID:Xatpy,项目名称:echomesh,代码行数:42,代码来源:test_financial.py
示例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'))
开发者ID:Horta,项目名称:numpy,代码行数:3,代码来源:test_financial.py
示例7: test_fv
def test_fv(self):
assert_equal(np.fv(0.075, 20, -2000, 0, 0), 86609.362673042924)
开发者ID:Horta,项目名称:numpy,代码行数:2,代码来源:test_financial.py
示例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])
开发者ID:Horta,项目名称:numpy,代码行数:73,代码来源:test_financial.py
示例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'))
开发者ID:Horta,项目名称:numpy,代码行数:63,代码来源:test_financial.py
示例10: sta001
def sta001(k, nyear, xd):
d2 = np.fv(k, nyear, -xd, -xd);
d2 = round(d2)
return d2
开发者ID:Chiva-Zhao,项目名称:pproject,代码行数:4,代码来源:k101.py
示例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参数为贷款利率,固定的月供和贷款额,输出付款期数
开发者ID:moonlmq,项目名称:Tools,代码行数:30,代码来源:Learn_TypicalFunction.py
示例12: test_fv
def test_fv(self):
assert_almost_equal(np.fv(.10,12,-100,100),1824.59, 2)
开发者ID:radovankavicky,项目名称:econpy,代码行数:2,代码来源:test_finance.py
示例13:
#!/usr/bin/python
import numpy
print "Future value", numpy.fv(0.03/4, 5 * 4, -10, -1000)
开发者ID:xenron,项目名称:sandbox-da-python,代码行数:5,代码来源:futurevalue.py
示例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()
开发者ID:DanielEColi,项目名称:python_ebook,代码行数:12,代码来源:futurevalue.py
示例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
示例16: 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
示例17: test_fv
def test_fv(self):
assert_almost_equal(np.fv(0.075, 20, -2000,0,0),
86609.36, 2)
开发者ID:BlackEarth,项目名称:portable-python-win32,代码行数:3,代码来源:test_financial.py
示例18:
import numpy as np
np.fv(0.05 / 12, 10 * 12, -100, -100)
a = np.array((0.05, 0.06, 0.07)) / 12
np.fv(a, 10 * 12, -100, -100)
开发者ID:yzozulya,项目名称:numpy_test_examples,代码行数:5,代码来源:numpy.fv.py
注:本文中的numpy.fv函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论