Python numpy.fv()
numpy.fv(rate, nper, pmt, pv, when = ‘end’) :这个金融函数帮助用户计算未来的价值。
参数 :
rate :[标量或(M,)数组] 每期的利率为小数(不是百分比)。
nper :[标量或(M,)数组]总复利周期
pmt :[标量或(M, )数组] 固定付款
pv :[标量或(M, )数组] 现值
when :在每个周期的开始(when = {‘begin’, 1})或结束(when = {‘end’, 0})。默认是{‘结束’, 0}。
返回 :
每期结束时的价值
求解方程:
fv + pv*(1+rate)**nper +
pmt*(1 + rate*when)/rate*((1 + rate)**nper - 1) == 0
或 当速率==0时
fv + pv + pmt * nper == 0
代码1:
# Python program explaining fv() function
import numpy as np
'''
Question :
Future value after 10 years of saving 100 now,
with an additional monthly savings of100.
Assume the interest rate is 5% (annually)
compounded monthly ?
'''
# rate np pmt pv
Solution = np.fv(0.05/12, 10*12, -100, -100)
print("Solution : ", Solution)
输出 :
Solution : 15692.9288943