Python numpy.pv()
numpy.fv(rate, nper, pmt, fv, when = ‘end’) :这个金融函数帮助用户计算未来的价值。
参数 :
rate :[array_like] 每期的利率为小数(而不是百分比)。
nper :[array_like] 总复利期
pmt :[array_like] 固定付款
fv :[array_like, optional] 未来值。默认=0.0
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 pv() function
import numpy as np
'''
Question :
What is the present value (e.g., the initial investment)
of an investment that needs to total 15692.93 after 10
years of saving100 every month?
Assume the interest rate is 5% (annually) compounded monthly.
'''
# rate np pmt fv
Solution = np.pv(0.05/12, 10*12, -100, 15692.93)
print("present value (fv) : ", Solution)
输出 :
present value (fv) : -100.000671316